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

Side by Side Diff: content/browser/webui/web_ui_data_source_impl.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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui.cc ('k') | ui/base/template_expressions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/webui/web_ui_data_source_impl.h" 5 #include "content/browser/webui/web_ui_data_source_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 int ids) { 129 int ids) {
130 localized_strings_.SetString( 130 localized_strings_.SetString(
131 name, GetContentClient()->GetLocalizedString(ids)); 131 name, GetContentClient()->GetLocalizedString(ids));
132 replacements_[name] = 132 replacements_[name] =
133 base::UTF16ToUTF8(GetContentClient()->GetLocalizedString(ids)); 133 base::UTF16ToUTF8(GetContentClient()->GetLocalizedString(ids));
134 } 134 }
135 135
136 void WebUIDataSourceImpl::AddLocalizedStrings( 136 void WebUIDataSourceImpl::AddLocalizedStrings(
137 const base::DictionaryValue& localized_strings) { 137 const base::DictionaryValue& localized_strings) {
138 localized_strings_.MergeDictionary(&localized_strings); 138 localized_strings_.MergeDictionary(&localized_strings);
139 139 ui::TemplateReplacementsFromDictionaryValue(localized_strings,
140 for (base::DictionaryValue::Iterator it(localized_strings); !it.IsAtEnd(); 140 &replacements_);
141 it.Advance()) {
142 if (it.value().IsType(base::Value::Type::STRING)) {
143 std::string value;
144 it.value().GetAsString(&value);
145 replacements_[it.key()] = value;
146 }
147 }
148 } 141 }
149 142
150 void WebUIDataSourceImpl::AddBoolean(const std::string& name, bool value) { 143 void WebUIDataSourceImpl::AddBoolean(const std::string& name, bool value) {
151 localized_strings_.SetBoolean(name, value); 144 localized_strings_.SetBoolean(name, value);
152 // TODO(dschuyler): Change name of |localized_strings_| to |load_time_data_| 145 // TODO(dschuyler): Change name of |localized_strings_| to |load_time_data_|
153 // or similar. These values haven't been found as strings for 146 // or similar. These values haven't been found as strings for
154 // localization. The boolean values are not added to |replacements_| 147 // localization. The boolean values are not added to |replacements_|
155 // for the same reason, that they are used as flags, rather than string 148 // for the same reason, that they are used as flags, rather than string
156 // replacements. 149 // replacements.
157 } 150 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 287 }
295 288
296 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( 289 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON(
297 const URLDataSource::GotDataCallback& callback) { 290 const URLDataSource::GotDataCallback& callback) {
298 std::string template_data; 291 std::string template_data;
299 webui::AppendJsonJS(&localized_strings_, &template_data); 292 webui::AppendJsonJS(&localized_strings_, &template_data);
300 callback.Run(base::RefCountedString::TakeString(&template_data)); 293 callback.Run(base::RefCountedString::TakeString(&template_data));
301 } 294 }
302 295
303 } // namespace content 296 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/options_ui.cc ('k') | ui/base/template_expressions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698