OLD | NEW |
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 replacements_[name] = | 124 replacements_[name] = |
125 base::UTF16ToUTF8(GetContentClient()->GetLocalizedString(ids)); | 125 base::UTF16ToUTF8(GetContentClient()->GetLocalizedString(ids)); |
126 } | 126 } |
127 | 127 |
128 void WebUIDataSourceImpl::AddLocalizedStrings( | 128 void WebUIDataSourceImpl::AddLocalizedStrings( |
129 const base::DictionaryValue& localized_strings) { | 129 const base::DictionaryValue& localized_strings) { |
130 localized_strings_.MergeDictionary(&localized_strings); | 130 localized_strings_.MergeDictionary(&localized_strings); |
131 | 131 |
132 for (base::DictionaryValue::Iterator it(localized_strings); !it.IsAtEnd(); | 132 for (base::DictionaryValue::Iterator it(localized_strings); !it.IsAtEnd(); |
133 it.Advance()) { | 133 it.Advance()) { |
134 if (it.value().IsType(base::Value::TYPE_STRING)) { | 134 if (it.value().IsType(base::Value::Type::STRING)) { |
135 std::string value; | 135 std::string value; |
136 it.value().GetAsString(&value); | 136 it.value().GetAsString(&value); |
137 replacements_[it.key()] = value; | 137 replacements_[it.key()] = value; |
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 void WebUIDataSourceImpl::AddBoolean(const std::string& name, bool value) { | 142 void WebUIDataSourceImpl::AddBoolean(const std::string& name, bool value) { |
143 localized_strings_.SetBoolean(name, value); | 143 localized_strings_.SetBoolean(name, value); |
144 // TODO(dschuyler): Change name of |localized_strings_| to |load_time_data_| | 144 // TODO(dschuyler): Change name of |localized_strings_| to |load_time_data_| |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 286 } |
287 | 287 |
288 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( | 288 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( |
289 const URLDataSource::GotDataCallback& callback) { | 289 const URLDataSource::GotDataCallback& callback) { |
290 std::string template_data; | 290 std::string template_data; |
291 webui::AppendJsonJS(&localized_strings_, &template_data); | 291 webui::AppendJsonJS(&localized_strings_, &template_data); |
292 callback.Run(base::RefCountedString::TakeString(&template_data)); | 292 callback.Run(base::RefCountedString::TakeString(&template_data)); |
293 } | 293 } |
294 | 294 |
295 } // namespace content | 295 } // namespace content |
OLD | NEW |