Commit 4ee390d4 authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[WebLayer] Update UrlBarView when active tab changes.

Before this change, when the active tab was changed but
it's webcontents not updated (we switched to a quiescent tab),
the UrlBar wasn't getting updated.

After this change, it is always updated when active tab changes.
Tested manually, and added a browsertest to verify behavior.

Bug: 1025607

Change-Id: I085b4748f25d3f2f483a5d9964bb767ed178f1de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2139707
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757134}
parent 713d020b
......@@ -275,6 +275,7 @@ void BrowserImpl::SetActiveTab(Tab* tab) {
AttachCurrentThread(), java_impl_,
active_tab_ ? active_tab_->GetJavaTab() : nullptr);
#endif
VisibleSecurityStateOfActiveTabChanged();
for (BrowserObserver& obs : browser_observers_)
obs.OnActiveTabChanged(active_tab_);
if (active_tab_)
......
......@@ -24,10 +24,13 @@ class UrlBarBrowserTest : public WebLayerBrowserTest {
ASSERT_TRUE(embedded_test_server()->Start());
browser_ = Browser::Create(GetProfile(), nullptr);
tab_ = static_cast<TabImpl*>(browser_->AddTab(Tab::Create(GetProfile())));
another_tab_ =
static_cast<TabImpl*>(browser_->AddTab(Tab::Create(GetProfile())));
browser_->SetActiveTab(tab_);
}
void PostRunTestOnMainThread() override {
tab_ = nullptr;
another_tab_ = nullptr;
browser_.reset();
WebLayerBrowserTest::PostRunTestOnMainThread();
}
......@@ -42,8 +45,11 @@ class UrlBarBrowserTest : public WebLayerBrowserTest {
std::move(closure));
}
void SetActiveTab(TabImpl* tab) { browser_->SetActiveTab(tab); }
protected:
TabImpl* tab_ = nullptr;
TabImpl* another_tab_ = nullptr;
private:
std::unique_ptr<Browser> browser_;
......@@ -69,4 +75,20 @@ IN_PROC_BROWSER_TEST_F(UrlBarBrowserTest, CanceledNavigationsUpdateUrl) {
}
}
IN_PROC_BROWSER_TEST_F(UrlBarBrowserTest, ChangingActiveTabUpdatesUrlBarView) {
NavigateAndWaitForCompletion(real_url(), tab_);
NavigateAndWaitForCompletion(real_url(), another_tab_);
{
base::RunLoop run_loop;
SetVisibleSecurityStateChangedCallback(run_loop.QuitClosure());
SetActiveTab(another_tab_);
// The test won't finish until
// BrowserImpl::VisibleSecurityStateOfActiveTabChanged() gets called.
run_loop.Run();
}
}
} // namespace weblayer
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment