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

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

Issue 7256002: Multi-Profiles: New Profile Setup UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: show product logo at bottom 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::AddLocalizedString(const std::string& name, 21 void ChromeWebUIDataSource::AddLocalizedString(const std::string& name,
22 int ids) { 22 int ids) {
23 localized_strings_.SetString(name, l10n_util::GetStringUTF16(ids)); 23 localized_strings_.SetString(name, l10n_util::GetStringUTF16(ids));
24 } 24 }
25 25
26 void ChromeWebUIDataSource::AddLocalizedString(
27 const std::string& name,
28 const string16& localized_string) {
29 localized_strings_.SetString(name, localized_string);
30 }
31
26 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) { 32 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) {
27 std::string template_data; 33 std::string template_data;
28 scoped_refptr<RefCountedBytes> response(new RefCountedBytes); 34 scoped_refptr<RefCountedBytes> response(new RefCountedBytes);
29 SetFontAndTextDirection(&localized_strings_); 35 SetFontAndTextDirection(&localized_strings_);
30 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data); 36 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data);
31 response->data.resize(template_data.size()); 37 response->data.resize(template_data.size());
32 std::copy(template_data.begin(), template_data.end(),response->data.begin()); 38 std::copy(template_data.begin(), template_data.end(),response->data.begin());
33 SendResponse(request_id, response); 39 SendResponse(request_id, response);
34 } 40 }
35 41
36 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { 42 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) {
37 scoped_refptr<RefCountedStaticMemory> response( 43 scoped_refptr<RefCountedStaticMemory> response(
38 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); 44 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr));
39 SendResponse(request_id, response); 45 SendResponse(request_id, response);
40 } 46 }
41 47
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698