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

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

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 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 "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 result = path_to_idr_map_.find(path); 47 result = path_to_idr_map_.find(path);
48 if (result != path_to_idr_map_.end()) 48 if (result != path_to_idr_map_.end())
49 resource_id = result->second; 49 resource_id = result->second;
50 DCHECK_NE(resource_id, -1); 50 DCHECK_NE(resource_id, -1);
51 SendFromResourceBundle(request_id, resource_id); 51 SendFromResourceBundle(request_id, resource_id);
52 } 52 }
53 } 53 }
54 54
55 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) { 55 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) {
56 std::string template_data; 56 std::string template_data;
57 scoped_refptr<RefCountedBytes> response(new RefCountedBytes);
58 SetFontAndTextDirection(&localized_strings_); 57 SetFontAndTextDirection(&localized_strings_);
59 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data); 58 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data);
60 response->data.resize(template_data.size()); 59 SendResponse(request_id, base::RefCountedString::TakeString(&template_data));
61 std::copy(template_data.begin(), template_data.end(),response->data.begin());
62 SendResponse(request_id, response);
63 } 60 }
64 61
65 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { 62 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) {
66 scoped_refptr<RefCountedStaticMemory> response( 63 scoped_refptr<RefCountedStaticMemory> response(
67 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); 64 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr));
68 SendResponse(request_id, response); 65 SendResponse(request_id, response);
69 } 66 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/bug_report_ui.cc ('k') | chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698