Commit b1e0f2ce authored by Caroline Rising's avatar Caroline Rising Committed by Commit Bot

Fix bug where tab hover card's title and domain could refer to different pages.

Tab renderer data's visible url will show the domain of the page the user is navigating to before there is a title. So at times the title would be for the page the user is navigating from while the url was for the page the user was navigating to. Using the last committed url will prevent this title and domain from being out of sync.

Bug: 910739
Change-Id: I19f88d3a96ec950d37476f3287381ec2409ec17b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1632593
Commit-Queue: Caroline Rising <corising@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663940}
parent c1eae0fa
......@@ -564,6 +564,7 @@ TabRendererData BrowserTabStripController::TabRendererDataFromModel(
data.network_state = TabNetworkStateForWebContents(contents);
data.title = tab_ui_helper->GetTitle();
data.visible_url = contents->GetVisibleURL();
data.last_committed_url = contents->GetLastCommittedURL();
data.crashed_status = contents->GetCrashedStatus();
data.incognito = contents->GetBrowserContext()->IsOffTheRecord();
data.pinned = model_->IsTabPinned(model_index);
......
......@@ -478,7 +478,7 @@ void TabHoverCardBubbleView::UpdateCardContent(TabRendererData data) {
title_label_->SetText(data.title);
base::string16 domain = url_formatter::FormatUrl(
data.visible_url,
data.last_committed_url,
url_formatter::kFormatUrlOmitDefaults |
url_formatter::kFormatUrlOmitHTTPS |
url_formatter::kFormatUrlOmitTrivialSubdomains |
......
......@@ -203,10 +203,11 @@ IN_PROC_BROWSER_TEST_F(TabHoverCardBubbleViewBrowserTest,
IN_PROC_BROWSER_TEST_F(TabHoverCardBubbleViewBrowserTest, WidgetDataUpdate) {
TabStrip* tab_strip =
BrowserView::GetBrowserViewForBrowser(browser())->tabstrip();
TabRendererData newTabData = TabRendererData();
newTabData.title = base::UTF8ToUTF16("Test Tab 2");
newTabData.visible_url = GURL("http://example.com/this/should/not/be/seen");
tab_strip->AddTabAt(1, newTabData, false);
TabRendererData new_tab_data = TabRendererData();
new_tab_data.title = base::UTF8ToUTF16("Test Tab 2");
new_tab_data.last_committed_url =
GURL("http://example.com/this/should/not/be/seen");
tab_strip->AddTabAt(1, new_tab_data, false);
ShowUi("default");
TabHoverCardBubbleView* hover_card = GetHoverCard(tab_strip);
......
......@@ -22,6 +22,7 @@ bool TabRendererData::operator==(const TabRendererData& other) const {
thumbnail.BackedBySameObjectAs(other.thumbnail) &&
network_state == other.network_state && title == other.title &&
visible_url == other.visible_url &&
last_committed_url == other.last_committed_url &&
crashed_status == other.crashed_status &&
incognito == other.incognito && show_icon == other.show_icon &&
pinned == other.pinned && blocked == other.blocked &&
......
......@@ -35,6 +35,8 @@ struct TabRendererData {
base::string16 title;
// This corresponds to WebContents::GetVisibleUrl().
GURL visible_url;
// This corresponds to WebContents::GetLastCommittedUrl().
GURL last_committed_url;
base::TerminationStatus crashed_status =
base::TERMINATION_STATUS_STILL_RUNNING;
bool incognito = false;
......
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