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

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

Issue 10141005: switch ntp to jstemplate v2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update test Created 8 years, 8 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) 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 "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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (result != path_to_idr_map_.end()) 68 if (result != path_to_idr_map_.end())
69 resource_id = result->second; 69 resource_id = result->second;
70 DCHECK_NE(resource_id, -1); 70 DCHECK_NE(resource_id, -1);
71 SendFromResourceBundle(request_id, resource_id); 71 SendFromResourceBundle(request_id, resource_id);
72 } 72 }
73 } 73 }
74 74
75 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) { 75 void ChromeWebUIDataSource::SendLocalizedStringsAsJSON(int request_id) {
76 std::string template_data; 76 std::string template_data;
77 SetFontAndTextDirection(&localized_strings_); 77 SetFontAndTextDirection(&localized_strings_);
78
79 scoped_ptr<jstemplate_builder::UseVersion2> version2;
78 if (json_js_format_v2_) 80 if (json_js_format_v2_)
79 jstemplate_builder::AppendJsonJS2(&localized_strings_, &template_data); 81 version2.reset(new jstemplate_builder::UseVersion2);
80 else 82
81 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data); 83 jstemplate_builder::AppendJsonJS(&localized_strings_, &template_data);
82 SendResponse(request_id, base::RefCountedString::TakeString(&template_data)); 84 SendResponse(request_id, base::RefCountedString::TakeString(&template_data));
83 } 85 }
84 86
85 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) { 87 void ChromeWebUIDataSource::SendFromResourceBundle(int request_id, int idr) {
86 scoped_refptr<base::RefCountedStaticMemory> response( 88 scoped_refptr<base::RefCountedStaticMemory> response(
87 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr)); 89 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(idr));
88 SendResponse(request_id, response); 90 SendResponse(request_id, response);
89 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698