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

Unified Diff: chrome/browser/ui/webui/options/options_ui.cc

Issue 7003007: Apply content-security-policy to the HTML options page. This is a (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/options_ui.cc
===================================================================
--- chrome/browser/ui/webui/options/options_ui.cc (revision 84688)
+++ chrome/browser/ui/webui/options/options_ui.cc (working copy)
@@ -110,22 +110,34 @@
void OptionsUIHTMLSource::StartDataRequest(const std::string& path,
bool is_incognito,
int request_id) {
+ scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
abarth-chromium 2011/05/10 21:11:45 It seems odd to call this html_bytes because somet
SetFontAndTextDirection(localized_strings_.get());
- static const base::StringPiece options_html(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_OPTIONS_HTML));
- const std::string full_html = jstemplate_builder::GetI18nTemplateHtml(
- options_html, localized_strings_.get());
+ if (path == "strings")
abarth-chromium 2011/05/10 21:11:45 I'm not sure whether this is the best name. Maybe
+ {
abarth-chromium 2011/05/10 21:11:45 This { should be on the previous line per the styl
+ std::string template_data;
+ jstemplate_builder::AppendJsonJS(localized_strings_.get(), &template_data);
+ html_bytes->data.resize(template_data.size());
+ std::copy(template_data.begin(),
+ template_data.end(),
+ html_bytes->data.begin());
+ } else {
+ static const base::StringPiece options_html(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_OPTIONS_HTML));
+ html_bytes->data.resize(options_html.size());
+ std::copy(options_html.begin(),
+ options_html.end(),
+ html_bytes->data.begin());
+ }
- scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
- html_bytes->data.resize(full_html.size());
- std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
-
SendResponse(request_id, html_bytes);
}
-std::string OptionsUIHTMLSource::GetMimeType(const std::string&) const {
+std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const {
+ if (path == "strings")
abarth-chromium 2011/05/10 21:11:45 This string appears twice. Maybe make it a named
+ return "application/javascript";
+
return "text/html";
}

Powered by Google App Engine
This is Rietveld 408576698