Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: chrome/browser/ui/webui/chrome_web_ui_data_source.cc

Issue 7148023: Add content-security-policy (CSP) to chrome://flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/base/resource/resource_bundle.h" 12 #include "ui/base/resource/resource_bundle.h"
13 13
14 ChromeWebUIDataSource::ChromeWebUIDataSource(const std::string& source_name) 14 ChromeWebUIDataSource::ChromeWebUIDataSource(const std::string& source_name)
15 : DataSource(source_name, MessageLoop::current()) { 15 : DataSource(source_name, MessageLoop::current()) {
16 } 16 }
17 17
18 ChromeWebUIDataSource::~ChromeWebUIDataSource() { 18 ChromeWebUIDataSource::~ChromeWebUIDataSource() {
19 } 19 }
20 20
21 void ChromeWebUIDataSource::AddString(const std::string& name,
22 const string16& value) {
23 localized_strings_.SetString(name, value);
24 }
25
21 void ChromeWebUIDataSource::AddLocalizedString(const std::string& name, 26 void ChromeWebUIDataSource::AddLocalizedString(const std::string& name,
22 int ids) { 27 int ids) {
23 localized_strings_.SetString(name, l10n_util::GetStringUTF16(ids)); 28 localized_strings_.SetString(name, l10n_util::GetStringUTF16(ids));
24 } 29 }
25 30
26 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) { 31 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) {
27 std::string template_data; 32 std::string template_data;
28 scoped_refptr<RefCountedBytes> response(new RefCountedBytes); 33 scoped_refptr<RefCountedBytes> response(new RefCountedBytes);
29 SetFontAndTextDirection(&localized_strings_); 34 SetFontAndTextDirection(&localized_strings_);
30 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data); 35 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data);
31 response->data.resize(template_data.size()); 36 response->data.resize(template_data.size());
32 std::copy(template_data.begin(), template_data.end(),response->data.begin()); 37 std::copy(template_data.begin(), template_data.end(),response->data.begin());
33 SendResponse(request_id, response); 38 SendResponse(request_id, response);
34 } 39 }
35 40
36 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { 41 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) {
37 scoped_refptr<RefCountedStaticMemory> response( 42 scoped_refptr<RefCountedStaticMemory> response(
38 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); 43 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr));
39 SendResponse(request_id, response); 44 SendResponse(request_id, response);
40 } 45 }
41 46
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698