| 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 | 9 |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/bind.h" | 12 #include "base/bind.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "content/grit/content_resources.h" | 17 #include "content/grit/content_resources.h" |
| 17 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 135 |
| 135 void WebUIDataSourceImpl::AddBoolean(const std::string& name, bool value) { | 136 void WebUIDataSourceImpl::AddBoolean(const std::string& name, bool value) { |
| 136 localized_strings_.SetBoolean(name, value); | 137 localized_strings_.SetBoolean(name, value); |
| 137 // TODO(dschuyler): Change name of |localized_strings_| to |load_time_data_| | 138 // TODO(dschuyler): Change name of |localized_strings_| to |load_time_data_| |
| 138 // or similar. These values haven't been found as strings for | 139 // or similar. These values haven't been found as strings for |
| 139 // localization. The boolean values are not added to |replacements_| | 140 // localization. The boolean values are not added to |replacements_| |
| 140 // for the same reason, that they are used as flags, rather than string | 141 // for the same reason, that they are used as flags, rather than string |
| 141 // replacements. | 142 // replacements. |
| 142 } | 143 } |
| 143 | 144 |
| 145 void WebUIDataSourceImpl::AddInteger(const std::string& name, int32_t value) { |
| 146 localized_strings_.SetInteger(name, value); |
| 147 } |
| 148 |
| 144 void WebUIDataSourceImpl::SetJsonPath(const std::string& path) { | 149 void WebUIDataSourceImpl::SetJsonPath(const std::string& path) { |
| 145 json_path_ = path; | 150 json_path_ = path; |
| 146 } | 151 } |
| 147 | 152 |
| 148 void WebUIDataSourceImpl::AddResourcePath(const std::string &path, | 153 void WebUIDataSourceImpl::AddResourcePath(const std::string &path, |
| 149 int resource_id) { | 154 int resource_id) { |
| 150 path_to_idr_map_[path] = resource_id; | 155 path_to_idr_map_[path] = resource_id; |
| 151 } | 156 } |
| 152 | 157 |
| 153 void WebUIDataSourceImpl::SetDefaultResource(int resource_id) { | 158 void WebUIDataSourceImpl::SetDefaultResource(int resource_id) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 266 } |
| 262 | 267 |
| 263 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( | 268 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( |
| 264 const URLDataSource::GotDataCallback& callback) { | 269 const URLDataSource::GotDataCallback& callback) { |
| 265 std::string template_data; | 270 std::string template_data; |
| 266 webui::AppendJsonJS(&localized_strings_, &template_data); | 271 webui::AppendJsonJS(&localized_strings_, &template_data); |
| 267 callback.Run(base::RefCountedString::TakeString(&template_data)); | 272 callback.Run(base::RefCountedString::TakeString(&template_data)); |
| 268 } | 273 } |
| 269 | 274 |
| 270 } // namespace content | 275 } // namespace content |
| OLD | NEW |