| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "chrome/common/jstemplate_builder.h" | 10 #include "chrome/common/jstemplate_builder.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 void ChromeWebUIDataSource::AddString(const std::string& name, | 21 void ChromeWebUIDataSource::AddString(const std::string& name, |
| 22 const string16& value) { | 22 const string16& value) { |
| 23 localized_strings_.SetString(name, value); | 23 localized_strings_.SetString(name, value); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void ChromeWebUIDataSource::AddLocalizedString(const std::string& name, | 26 void ChromeWebUIDataSource::AddLocalizedString(const std::string& name, |
| 27 int ids) { | 27 int ids) { |
| 28 localized_strings_.SetString(name, l10n_util::GetStringUTF16(ids)); | 28 localized_strings_.SetString(name, l10n_util::GetStringUTF16(ids)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void ChromeWebUIDataSource::AddLocalizedString( | |
| 32 const std::string& name, | |
| 33 const string16& localized_string) { | |
| 34 localized_strings_.SetString(name, localized_string); | |
| 35 } | |
| 36 | |
| 37 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) { | 31 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) { |
| 38 std::string template_data; | 32 std::string template_data; |
| 39 scoped_refptr<RefCountedBytes> response(new RefCountedBytes); | 33 scoped_refptr<RefCountedBytes> response(new RefCountedBytes); |
| 40 SetFontAndTextDirection(&localized_strings_); | 34 SetFontAndTextDirection(&localized_strings_); |
| 41 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data); | 35 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data); |
| 42 response->data.resize(template_data.size()); | 36 response->data.resize(template_data.size()); |
| 43 std::copy(template_data.begin(), template_data.end(),response->data.begin()); | 37 std::copy(template_data.begin(), template_data.end(),response->data.begin()); |
| 44 SendResponse(request_id, response); | 38 SendResponse(request_id, response); |
| 45 } | 39 } |
| 46 | 40 |
| 47 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { | 41 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { |
| 48 scoped_refptr<RefCountedStaticMemory> response( | 42 scoped_refptr<RefCountedStaticMemory> response( |
| 49 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); | 43 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); |
| 50 SendResponse(request_id, response); | 44 SendResponse(request_id, response); |
| 51 } | 45 } |
| 52 | 46 |
| OLD | NEW |