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

Unified Diff: chrome/common/jstemplate_builder.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
« chrome/common/jstemplate_builder.h ('K') | « chrome/common/jstemplate_builder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/jstemplate_builder.cc
===================================================================
--- chrome/common/jstemplate_builder.cc (revision 84688)
+++ chrome/common/jstemplate_builder.cc (working copy)
@@ -47,6 +47,12 @@
}
void AppendJsonHtml(const DictionaryValue* json, std::string* output) {
+ output->append("<script>");
+ AppendJsonJS(json, output);
+ output->append("</script>");
+}
+
+void AppendJsonJS(const DictionaryValue* json, std::string* output) {
// Convert the template data to a json string.
DCHECK(json) << "must include json data structure";
@@ -57,11 +63,9 @@
// replace </ with <\/. The extra \ will be ignored by the JS engine.
ReplaceSubstringsAfterOffset(&jstext, 0, "</", "<\\/");
abarth-chromium 2011/05/10 21:11:45 This escaping actually isn't allowed in JSON. Thi
- output->append("<script>");
output->append("var templateData = ");
output->append(jstext);
output->append(";");
- output->append("</script>");
}
void AppendJsTemplateSourceHtml(std::string* output) {
@@ -107,8 +111,17 @@
}
void AppendI18nTemplateProcessHtml(std::string* output) {
+ static const base::StringPiece i18n_process_src(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_I18N_PROCESS_JS));
+
+ if (i18n_process_src.empty()) {
+ NOTREACHED() << "Unable to get i18n process src";
+ return;
+ }
+
output->append("<script>");
- output->append("i18nTemplate.process(document, templateData);");
+ output->append(i18n_process_src.data(), i18n_process_src.size());
output->append("</script>");
}
« chrome/common/jstemplate_builder.h ('K') | « chrome/common/jstemplate_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698