Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1683)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 78443005: New Tab: fix tab title flickering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 950490043140f1c9594b2cb3aabc20394d415c81..a48dfd7a6e6cd1300350d18ae55695100ef6a496 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -756,11 +756,22 @@ const string16& WebContentsImpl::GetTitle() const {
// title.
entry = controller_.GetLastCommittedEntry();
- // We make an exception for initial navigations, because we can have a
- // committed entry for an initial navigation when doing a history navigation
- // in a new tab, such as Ctrl+Back.
- if (entry && controller_.IsInitialNavigation())
- entry = controller_.GetVisibleEntry();
+ // We make an exception for initial navigations.
+ if (controller_.IsInitialNavigation()) {
+ // We only want to use the title from the visible entry in one of two cases:
+ // 1. There's already a committed entry for an initial navigation, in which
+ // case we are doing a history navigation in a new tab (e.g., Ctrl+Back).
+ // 2. The pending entry has been explicitly assigned a title to display.
+ //
+ // If there's no last committed entry and no assigned title, we should fall
+ // back to |page_title_when_no_navigation_entry_| rather than showing the
+ // URL.
+ if (entry ||
+ (controller_.GetVisibleEntry() &&
+ !controller_.GetVisibleEntry()->GetTitle().empty())) {
+ entry = controller_.GetVisibleEntry();
+ }
+ }
if (entry) {
return entry->GetTitleForDisplay(accept_languages);
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper_unittest.cc ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698