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

Unified Diff: chrome/browser/ui/webui/options/options_ui.cc

Issue 2607843002: [MD settings] i18n template replacements in shared HTML resources (Closed)
Patch Set: nits Created 3 years, 11 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 | « no previous file | content/browser/webui/web_ui_data_source_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/options_ui.cc
diff --git a/chrome/browser/ui/webui/options/options_ui.cc b/chrome/browser/ui/webui/options/options_ui.cc
index b6ffe6efe463af5e3a7adca3919934e7234fc0ba..cbbe557b5ec01cbd7fa2e4d49cd88c0a7ae0b361 100644
--- a/chrome/browser/ui/webui/options/options_ui.cc
+++ b/chrome/browser/ui/webui/options/options_ui.cc
@@ -175,7 +175,6 @@ class OptionsUIHTMLSource : public content::URLDataSource {
private:
~OptionsUIHTMLSource() override;
void CreateDataSourceMap();
- void AddReplacements(base::DictionaryValue* localized_strings);
// Localized strings collection.
std::unique_ptr<base::DictionaryValue> localized_strings_;
@@ -188,7 +187,6 @@ class OptionsUIHTMLSource : public content::URLDataSource {
OptionsUIHTMLSource::OptionsUIHTMLSource(
base::DictionaryValue* localized_strings) {
DCHECK(localized_strings);
- AddReplacements(localized_strings);
localized_strings_.reset(localized_strings);
CreateDataSourceMap();
}
@@ -204,6 +202,8 @@ void OptionsUIHTMLSource::StartDataRequest(
scoped_refptr<base::RefCountedMemory> response_bytes;
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, localized_strings_.get());
+ ui::TemplateReplacementsFromDictionaryValue(*localized_strings_,
+ &replacements_);
std::map<std::string, int>::iterator result;
result = path_to_idr_map_.find(path);
@@ -287,18 +287,6 @@ void OptionsUIHTMLSource::CreateDataSourceMap() {
#endif
}
-void OptionsUIHTMLSource::AddReplacements(
- base::DictionaryValue* localized_strings) {
- for (auto it = base::DictionaryValue::Iterator(*localized_strings);
- !it.IsAtEnd(); it.Advance()) {
- std::string str_value;
- if (!it.value().GetAsString(&str_value)) {
- continue;
- }
- replacements_[it.key()] = str_value;
- }
-}
-
////////////////////////////////////////////////////////////////////////////////
//
// OptionsPageUIHandler
« no previous file with comments | « no previous file | content/browser/webui/web_ui_data_source_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698