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

Side by Side Diff: content/browser/webui/web_ui_data_source_impl.cc

Issue 2311223003: [chromecast] Add ResourceBundle::LoadLocalizedResourceBytes(). (Closed)
Patch Set: [chromecast] Add ResourceBundle::LoadLocalizedResourceBytes() to to get binary data from locale_res… Created 4 years, 3 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
« no previous file with comments | « chromecast/common/cast_content_client.cc ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/webui/web_ui_data_source_impl.h" 5 #include "content/browser/webui/web_ui_data_source_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 result = path_to_idr_map_.find(file_path); 245 result = path_to_idr_map_.find(file_path);
246 if (result != path_to_idr_map_.end()) 246 if (result != path_to_idr_map_.end())
247 resource_id = result->second; 247 resource_id = result->second;
248 DCHECK_NE(resource_id, -1); 248 DCHECK_NE(resource_id, -1);
249 scoped_refptr<base::RefCountedMemory> response( 249 scoped_refptr<base::RefCountedMemory> response(
250 GetContentClient()->GetDataResourceBytes(resource_id)); 250 GetContentClient()->GetDataResourceBytes(resource_id));
251 251
252 // TODO(dschuyler): improve filtering of which resource to run template 252 // TODO(dschuyler): improve filtering of which resource to run template
253 // expansion upon. TODO(dbeam): make a streaming filter that works on gzipped 253 // expansion upon. TODO(dbeam): make a streaming filter that works on gzipped
254 // content. 254 // content.
255 if (GetMimeType(path) == "text/html" && !source()->IsGzipped(path)) { 255 if (response.get() && GetMimeType(path) == "text/html" &&
256 !source()->IsGzipped(path)) {
256 std::string replaced = ui::ReplaceTemplateExpressions( 257 std::string replaced = ui::ReplaceTemplateExpressions(
257 base::StringPiece(response->front_as<char>(), response->size()), 258 base::StringPiece(response->front_as<char>(), response->size()),
258 replacements_); 259 replacements_);
259 response = base::RefCountedString::TakeString(&replaced); 260 response = base::RefCountedString::TakeString(&replaced);
260 } 261 }
261 262
262 callback.Run(response.get()); 263 callback.Run(response.get());
263 } 264 }
264 265
265 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON( 266 void WebUIDataSourceImpl::SendLocalizedStringsAsJSON(
266 const URLDataSource::GotDataCallback& callback) { 267 const URLDataSource::GotDataCallback& callback) {
267 std::string template_data; 268 std::string template_data;
268 webui::AppendJsonJS(&localized_strings_, &template_data); 269 webui::AppendJsonJS(&localized_strings_, &template_data);
269 callback.Run(base::RefCountedString::TakeString(&template_data)); 270 callback.Run(base::RefCountedString::TakeString(&template_data));
270 } 271 }
271 272
272 } // namespace content 273 } // namespace content
OLDNEW
« no previous file with comments | « chromecast/common/cast_content_client.cc ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698