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

Unified Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 17022009: Force set the new tab title in instant extended. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months 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
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/search_tab_helper.cc
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc
index 4cbbd8aa2dfe33e1049e180d742d98c106842fdc..0bff5eb7c9d9b52c2117ba5300f293dfccead1f9 100644
--- a/chrome/browser/ui/search/search_tab_helper.cc
+++ b/chrome/browser/ui/search/search_tab_helper.cc
@@ -10,6 +10,8 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(SearchTabHelper);
@@ -93,6 +95,28 @@ void SearchTabHelper::Observe(
last_known_most_visited_items_.clear();
}
+void SearchTabHelper::DidNavigateMainFrame(
+ const content::LoadCommittedDetails& details,
+ const content::FrameNavigateParams& params) {
+ // Always set the title on the new tab page to be the one from our UI
+ // resources. Normally, we set the title when we begin a NTP load, but it
+ // can get reset in several places (like when you press Reload). This check
+ // ensures that the title is properly set to the string defined by the Chrome
+ // UI language (rather than the server language) in all cases.
+ //
+ // We only override the title when it's nonempty to allow the page to set the
+ // title if it really wants. An empty title means to use the default. There's
+ // also a race condition between this code and the page's SetTitle call which
+ // this rule avoids.
+ content::NavigationEntry* entry =
+ web_contents_->GetController().GetActiveEntry();
+ if (entry && entry->GetTitle().empty() &&
+ (entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL) ||
+ chrome::NavEntryIsInstantNTP(web_contents_, entry))) {
+ entry->SetTitle(l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
+ }
+}
+
bool SearchTabHelper::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(SearchTabHelper, message)
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698