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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "content/grit/content_resources.h" | 12 #include "content/grit/content_resources.h" |
| 13 #include "content/public/browser/content_browser_client.h" |
13 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
14 #include "third_party/mojo/src/mojo/public/js/constants.h" | 15 #include "third_party/mojo/src/mojo/public/js/constants.h" |
15 #include "ui/base/webui/jstemplate_builder.h" | 16 #include "ui/base/webui/jstemplate_builder.h" |
16 #include "ui/base/webui/web_ui_util.h" | 17 #include "ui/base/webui/web_ui_util.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 // static | 21 // static |
21 WebUIDataSource* WebUIDataSource::Create(const std::string& source_name) { | 22 WebUIDataSource* WebUIDataSource::Create(const std::string& source_name) { |
22 return new WebUIDataSourceImpl(source_name); | 23 return new WebUIDataSourceImpl(source_name); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 result = path_to_idr_map_.find(path); | 225 result = path_to_idr_map_.find(path); |
225 if (result != path_to_idr_map_.end()) | 226 if (result != path_to_idr_map_.end()) |
226 resource_id = result->second; | 227 resource_id = result->second; |
227 DCHECK_NE(resource_id, -1); | 228 DCHECK_NE(resource_id, -1); |
228 SendFromResourceBundle(callback, resource_id); | 229 SendFromResourceBundle(callback, resource_id); |
229 } | 230 } |
230 | 231 |
231 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( | 232 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( |
232 const URLDataSource::GotDataCallback& callback) { | 233 const URLDataSource::GotDataCallback& callback) { |
233 std::string template_data; | 234 std::string template_data; |
234 if (!disable_set_font_strings_) | 235 if (!disable_set_font_strings_) { |
235 webui::SetFontAndTextDirection(&localized_strings_); | 236 std::string locale = GetContentClient()->browser()->GetApplicationLocale(); |
| 237 webui::SetLoadTimeDataDefaults(locale, &localized_strings_); |
| 238 } |
236 | 239 |
237 webui::AppendJsonJS(&localized_strings_, &template_data); | 240 webui::AppendJsonJS(&localized_strings_, &template_data); |
238 callback.Run(base::RefCountedString::TakeString(&template_data)); | 241 callback.Run(base::RefCountedString::TakeString(&template_data)); |
239 } | 242 } |
240 | 243 |
241 void WebUIDataSourceImpl::SendFromResourceBundle( | 244 void WebUIDataSourceImpl::SendFromResourceBundle( |
242 const URLDataSource::GotDataCallback& callback, int idr) { | 245 const URLDataSource::GotDataCallback& callback, int idr) { |
243 scoped_refptr<base::RefCountedStaticMemory> response( | 246 scoped_refptr<base::RefCountedStaticMemory> response( |
244 GetContentClient()->GetDataResourceBytes(idr)); | 247 GetContentClient()->GetDataResourceBytes(idr)); |
245 callback.Run(response.get()); | 248 callback.Run(response.get()); |
246 } | 249 } |
247 | 250 |
248 } // namespace content | 251 } // namespace content |
OLD | NEW |