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

Unified Diff: chrome/browser/ui/browser_navigator.cc

Issue 78443005: New Tab: fix tab title flickering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use pending entry. 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: chrome/browser/ui/browser_navigator.cc
diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc
index ed4626879e66d24f9ecf09775b73b4898ddcc1b7..e3e6e8f494837f51042b55c0ba7a768d20cc4597 100644
--- a/chrome/browser/ui/browser_navigator.cc
+++ b/chrome/browser/ui/browser_navigator.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/prerender/prerender_manager_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search/search.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -34,11 +35,14 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_url_handler.h"
+#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "extensions/common/extension.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
#if defined(USE_AURA)
#include "ui/aura/window.h"
@@ -268,6 +272,21 @@ void LoadURLInContents(WebContents* target_contents,
params->browser_initiated_post_data;
}
target_contents->GetController().LoadURLWithParams(load_url_params);
+
+ // For Instant Extended NTPs, explicitly set the title to "New Tab" on the
+ // pending entry.
+ //
+ // This ensures that the title is set even before we get a title from the
+ // page, preventing a potential flicker of the URL or "Loading...", and also
+ // ensures that (unless overridden by the page) the new tab title matches the
+ // browser UI locale.
+ content::NavigationController* controller = &target_contents->GetController();
+ content::NavigationEntry* entry = controller->GetVisibleEntry();
+ if (chrome::IsNTPURL(
Charlie Reis 2013/11/22 18:54:18 Hmm, this call happens for almost every URL. (Soo
samarth 2013/11/22 20:03:19 Agreed, this doesn't seem ideal. I don't know wher
Charlie Reis 2013/11/22 20:33:47 That sounds perfect-- thanks.
samarth 2013/11/22 21:54:41 Done.
+ entry->GetURL(),
+ Profile::FromBrowserContext(target_contents->GetBrowserContext()))) {
+ entry->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
+ }
}
// This class makes sure the Browser object held in |params| is made visible
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | content/browser/web_contents/web_contents_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698