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

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
« no previous file with comments | « chrome/common/jstemplate_builder.h ('k') | tools/grit/resource_ids » ('j') | 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 84887)
+++ chrome/common/jstemplate_builder.cc (working copy)
@@ -47,21 +47,28 @@
}
void AppendJsonHtml(const DictionaryValue* json, std::string* output) {
+ std::string javascript_string;
+ AppendJsonJS(json, &javascript_string);
+
+ // </ confuses the HTML parser because it could be a </script> tag. So we
+ // replace </ with <\/. The extra \ will be ignored by the JS engine.
+ ReplaceSubstringsAfterOffset(&javascript_string, 0, "</", "<\\/");
+
+ output->append("<script>");
+ output->append(javascript_string);
+ 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";
std::string jstext;
JSONStringValueSerializer serializer(&jstext);
serializer.Serialize(*json);
- // </ confuses the HTML parser because it could be a </script> tag. So we
- // replace </ with <\/. The extra \ will be ignored by the JS engine.
- ReplaceSubstringsAfterOffset(&jstext, 0, "</", "<\\/");
-
- output->append("<script>");
output->append("var templateData = ");
output->append(jstext);
output->append(";");
- output->append("</script>");
}
void AppendJsTemplateSourceHtml(std::string* output) {
@@ -107,8 +114,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>");
}
« no previous file with comments | « chrome/common/jstemplate_builder.h ('k') | tools/grit/resource_ids » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698