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

Unified Diff: chrome/browser/search/local_ntp_source.cc

Issue 19054012: Reload Local NTP on default search provider change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 7 years, 5 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
Index: chrome/browser/search/local_ntp_source.cc
diff --git a/chrome/browser/search/local_ntp_source.cc b/chrome/browser/search/local_ntp_source.cc
index 84f63817ae5e5c1ee3c4b6d38976e7a9a926ecab..766f7d3b98245c325f63b30018b375cb8d8f94eb 100644
--- a/chrome/browser/search/local_ntp_source.cc
+++ b/chrome/browser/search/local_ntp_source.cc
@@ -26,7 +26,7 @@ namespace {
// Signifies a locally constructed resource, i.e. not from grit/.
const int kLocalResource = -1;
-const char kTranslatedStringsFilename[] = "translated-strings.js";
+const char kLoadTimeDataFilename[] = "load-time-data.js";
const struct Resource{
const char* filename;
@@ -35,7 +35,7 @@ const struct Resource{
} kResources[] = {
{ "local-ntp.html", IDR_LOCAL_NTP_HTML, "text/html" },
{ "local-ntp.js", IDR_LOCAL_NTP_JS, "application/javascript" },
- { kTranslatedStringsFilename, kLocalResource, "application/javascript" },
+ { kLoadTimeDataFilename, kLocalResource, "application/javascript" },
{ "local-ntp.css", IDR_LOCAL_NTP_CSS, "text/css" },
{ "images/close_2.png", IDR_CLOSE_2, "image/png" },
{ "images/close_2_hover.png", IDR_CLOSE_2_H, "image/png" },
@@ -67,30 +67,32 @@ void AddString(base::DictionaryValue* dictionary,
dictionary->SetString(key, l10n_util::GetStringUTF16(resource_id));
}
-// Returns a JS dictionary of translated strings for the local NTP.
-std::string GetTranslatedStrings() {
- base::DictionaryValue translated_strings;
+// Returns a JS dictionary of load time data for the local NTP.
+std::string GetLoadTimeData(Profile* profile) {
+ base::DictionaryValue load_time_data;
if (chrome::ShouldShowRecentTabsOnNTP())
- AddString(&translated_strings, "recentTabs", IDS_RECENT_TABS_MENU);
- AddString(&translated_strings, "thumbnailRemovedNotification",
+ AddString(&load_time_data, "recentTabs", IDS_RECENT_TABS_MENU);
+ AddString(&load_time_data, "thumbnailRemovedNotification",
IDS_NEW_TAB_THUMBNAIL_REMOVED_NOTIFICATION);
- AddString(&translated_strings, "removeThumbnailTooltip",
+ AddString(&load_time_data, "removeThumbnailTooltip",
IDS_NEW_TAB_REMOVE_THUMBNAIL_TOOLTIP);
- AddString(&translated_strings, "undoThumbnailRemove",
+ AddString(&load_time_data, "undoThumbnailRemove",
IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE);
- AddString(&translated_strings, "restoreThumbnailsShort",
+ AddString(&load_time_data, "restoreThumbnailsShort",
IDS_NEW_TAB_RESTORE_THUMBNAILS_SHORT_LINK);
- AddString(&translated_strings, "attributionIntro",
+ AddString(&load_time_data, "attributionIntro",
IDS_NEW_TAB_ATTRIBUTION_INTRO);
- AddString(&translated_strings, "title", IDS_NEW_TAB_TITLE);
- std::string translated_strings_js;
- webui::AppendJsonJS(&translated_strings, &translated_strings_js);
- return translated_strings_js;
+ AddString(&load_time_data, "title", IDS_NEW_TAB_TITLE);
+ load_time_data.SetBoolean("isGooglePage",
samarth 2013/07/12 17:16:06 Rather than mixing these fields, please create a c
kmadhusu 2013/07/15 22:21:51 Done.
+ chrome::DefaultSearchProviderIsGoogle(profile));
+ std::string load_time_data_js;
+ webui::AppendJsonJS(&load_time_data, &load_time_data_js);
samarth 2013/07/12 17:16:06 AppendJsonJS [1] sets a variable called "templateD
kmadhusu 2013/07/15 22:21:51 Done.
+ return load_time_data_js;
}
} // namespace
-LocalNtpSource::LocalNtpSource() {
+LocalNtpSource::LocalNtpSource(Profile* profile) : profile_(profile) {
}
LocalNtpSource::~LocalNtpSource() {
@@ -106,9 +108,9 @@ void LocalNtpSource::StartDataRequest(
int render_view_id,
const content::URLDataSource::GotDataCallback& callback) {
const std::string stripped_path = StripParameters(path);
- if (stripped_path == kTranslatedStringsFilename) {
- std::string translated_strings_js = GetTranslatedStrings();
- callback.Run(base::RefCountedString::TakeString(&translated_strings_js));
+ if (stripped_path == kLoadTimeDataFilename) {
+ std::string load_time_data_js = GetLoadTimeData(profile_);
+ callback.Run(base::RefCountedString::TakeString(&load_time_data_js));
return;
}
for (size_t i = 0; i < arraysize(kResources); ++i) {

Powered by Google App Engine
This is Rietveld 408576698