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) |