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

Unified Diff: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc

Issue 2826643002: Convert Incognito New Tab Page from i18n-* (JS) to $i18n{} (C++) (Closed)
Patch Set: todo Created 3 years, 8 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/resources/ntp4/incognito_tab.html ('k') | chrome/browser/ui/webui/theme_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 393ef9d3125bf6149d2d70fafc3ea8e09dde107a..0410f2868b3ce6697c161f58f3a93baaadb6ecff 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -272,52 +272,38 @@ void NTPResourceCache::Invalidate() {
}
void NTPResourceCache::CreateNewTabIncognitoHTML() {
- base::DictionaryValue localized_strings;
- localized_strings.SetString("title",
- l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
- int new_tab_description_ids = IDS_NEW_TAB_OTR_DESCRIPTION;
- int new_tab_heading_ids = IDS_NEW_TAB_OTR_HEADING;
- int new_tab_link_ids = IDS_NEW_TAB_OTR_LEARN_MORE_LINK;
- int new_tab_warning_ids = IDS_NEW_TAB_OTR_MESSAGE_WARNING;
- int new_tab_html_idr = IDR_INCOGNITO_TAB_HTML;
- const char* new_tab_link = kLearnMoreIncognitoUrl;
-
- if (profile_->IsGuestSession()) {
- localized_strings.SetString("guestTabDescription",
- l10n_util::GetStringUTF16(new_tab_description_ids));
- localized_strings.SetString("guestTabHeading",
- l10n_util::GetStringUTF16(new_tab_heading_ids));
- } else {
- localized_strings.SetString("incognitoTabDescription",
- l10n_util::GetStringUTF16(new_tab_description_ids));
- localized_strings.SetString("incognitoTabHeading",
- l10n_util::GetStringUTF16(new_tab_heading_ids));
- localized_strings.SetString("incognitoTabWarning",
- l10n_util::GetStringUTF16(new_tab_warning_ids));
- }
-
- localized_strings.SetString("learnMore",
- l10n_util::GetStringUTF16(new_tab_link_ids));
- localized_strings.SetString("learnMoreLink", new_tab_link);
-
- bool bookmark_bar_attached =
- profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar);
- localized_strings.SetBoolean("bookmarkbarattached", bookmark_bar_attached);
+ ui::TemplateReplacements replacements;
+ // Note: there's specific rules in CSS that look for this attribute's content
+ // being equal to "true" as a string.
+ replacements["bookmarkbarattached"] =
+ profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar)
+ ? "true"
+ : "false";
+ replacements["incognitoTabDescription"] =
+ l10n_util::GetStringUTF8(IDS_NEW_TAB_OTR_DESCRIPTION);
+ replacements["incognitoTabHeading"] =
+ l10n_util::GetStringUTF8(IDS_NEW_TAB_OTR_HEADING);
+ replacements["incognitoTabWarning"] =
+ l10n_util::GetStringUTF8(IDS_NEW_TAB_OTR_MESSAGE_WARNING);
+ replacements["learnMore"] =
+ l10n_util::GetStringUTF8(IDS_NEW_TAB_OTR_LEARN_MORE_LINK);
+ replacements["learnMoreLink"] = kLearnMoreIncognitoUrl;
+ replacements["title"] = l10n_util::GetStringUTF8(IDS_NEW_TAB_TITLE);
const ui::ThemeProvider& tp =
ThemeService::GetThemeProviderForProfile(profile_);
- localized_strings.SetBoolean("hasCustomBackground",
- tp.HasCustomImage(IDR_THEME_NTP_BACKGROUND));
+ replacements["hasCustomBackground"] =
+ tp.HasCustomImage(IDR_THEME_NTP_BACKGROUND) ? "true" : "false";
const std::string& app_locale = g_browser_process->GetApplicationLocale();
- webui::SetLoadTimeDataDefaults(app_locale, &localized_strings);
+ webui::SetLoadTimeDataDefaults(app_locale, &replacements);
static const base::StringPiece incognito_tab_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(
- new_tab_html_idr));
+ IDR_INCOGNITO_TAB_HTML));
- std::string full_html = webui::GetI18nTemplateHtml(
- incognito_tab_html, &localized_strings);
+ std::string full_html =
+ ui::ReplaceTemplateExpressions(incognito_tab_html, replacements);
new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html);
}
@@ -391,8 +377,9 @@ void NTPResourceCache::CreateNewTabHTML() {
// profile is not the default.
PrefService* prefs = profile_->GetPrefs();
base::DictionaryValue load_time_data;
- load_time_data.SetBoolean("bookmarkbarattached",
- prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar));
+ load_time_data.SetString(
+ "bookmarkbarattached",
+ prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar) ? "true" : "false");
load_time_data.SetBoolean("showAppLauncherPromo",
ShouldShowAppLauncherPromo());
load_time_data.SetString("title",
« no previous file with comments | « chrome/browser/resources/ntp4/incognito_tab.html ('k') | chrome/browser/ui/webui/theme_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698