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 "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 5 #include "content/browser/webui/web_ui_data_source.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/string_util.h" | 11 #include "base/string_util.h" |
12 #include "content/public/common/content_client.h" | 12 #include "content/public/common/content_client.h" |
13 #include "ui/base/l10n/l10n_util.h" | |
14 #include "ui/webui/jstemplate_builder.h" | 13 #include "ui/webui/jstemplate_builder.h" |
15 #include "ui/webui/web_ui_util.h" | 14 #include "ui/webui/web_ui_util.h" |
16 | 15 |
17 // Internal class to hide the fact that ChromeWebUIDataSource implements | 16 // Internal class to hide the fact that ChromeWebUIDataSource implements |
18 // content::URLDataSource. | 17 // content::URLDataSource. |
19 class ChromeWebUIDataSource::InternalDataSource | 18 class ChromeWebUIDataSource::InternalDataSource |
20 : public content::URLDataSource { | 19 : public content::URLDataSource { |
21 public: | 20 public: |
22 InternalDataSource(ChromeWebUIDataSource* parent) : parent_(parent) { | 21 InternalDataSource(ChromeWebUIDataSource* parent) : parent_(parent) { |
23 } | 22 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 localized_strings_.SetString(name, value); | 84 localized_strings_.SetString(name, value); |
86 } | 85 } |
87 | 86 |
88 void ChromeWebUIDataSource::AddString(const std::string& name, | 87 void ChromeWebUIDataSource::AddString(const std::string& name, |
89 const std::string& value) { | 88 const std::string& value) { |
90 localized_strings_.SetString(name, value); | 89 localized_strings_.SetString(name, value); |
91 } | 90 } |
92 | 91 |
93 void ChromeWebUIDataSource::AddLocalizedString(const std::string& name, | 92 void ChromeWebUIDataSource::AddLocalizedString(const std::string& name, |
94 int ids) { | 93 int ids) { |
95 localized_strings_.SetString(name, l10n_util::GetStringUTF16(ids)); | 94 localized_strings_.SetString( |
| 95 name, content::GetContentClient()->GetLocalizedString(ids)); |
96 } | 96 } |
97 | 97 |
98 void ChromeWebUIDataSource::AddLocalizedStrings( | 98 void ChromeWebUIDataSource::AddLocalizedStrings( |
99 const DictionaryValue& localized_strings) { | 99 const DictionaryValue& localized_strings) { |
100 localized_strings_.MergeDictionary(&localized_strings); | 100 localized_strings_.MergeDictionary(&localized_strings); |
101 } | 101 } |
102 | 102 |
103 void ChromeWebUIDataSource::AddBoolean(const std::string& name, bool value) { | 103 void ChromeWebUIDataSource::AddBoolean(const std::string& name, bool value) { |
104 localized_strings_.SetBoolean(name, value); | 104 localized_strings_.SetBoolean(name, value); |
105 } | 105 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 webui::AppendJsonJS(&localized_strings_, &template_data); | 198 webui::AppendJsonJS(&localized_strings_, &template_data); |
199 callback.Run(base::RefCountedString::TakeString(&template_data)); | 199 callback.Run(base::RefCountedString::TakeString(&template_data)); |
200 } | 200 } |
201 | 201 |
202 void ChromeWebUIDataSource::SendFromResourceBundle( | 202 void ChromeWebUIDataSource::SendFromResourceBundle( |
203 const content::URLDataSource::GotDataCallback& callback, int idr) { | 203 const content::URLDataSource::GotDataCallback& callback, int idr) { |
204 scoped_refptr<base::RefCountedStaticMemory> response( | 204 scoped_refptr<base::RefCountedStaticMemory> response( |
205 content::GetContentClient()->GetDataResourceBytes(idr)); | 205 content::GetContentClient()->GetDataResourceBytes(idr)); |
206 callback.Run(response); | 206 callback.Run(response); |
207 } | 207 } |
OLD | NEW |