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

Unified Diff: chrome/browser/resources/flags.html

Issue 7148023: Add content-security-policy (CSP) to chrome://flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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/resources/flags.html
===================================================================
--- chrome/browser/resources/flags.html (revision 88884)
+++ chrome/browser/resources/flags.html (working copy)
@@ -2,6 +2,11 @@
<html i18n-values="dir:textdirection;">
<head>
<meta charset="utf-8">
+<!-- X-WebKit-CSP is our development name for Content-Security-Policy.
+ The 'unsafe-eval' is required for jstemplate_compiled.js.
+ TODO(tsepez) rename when Content-security-policy is done.
+-->
+<meta http-equiv="X-WebKit-CSP" content="object-src 'none'; script-src chrome://resources 'self' 'unsafe-eval'">
Evan Stade 2011/06/18 00:37:25 80 (I think you can just wrap strings in html like
<style>
body {
Evan Stade 2011/06/18 00:37:25 while you are at it, could you please move the sty
margin: 10px;
@@ -149,98 +154,6 @@
}
</style>
-<script>
-
-/**
- * This variable structure is here to document the structure that the template
- * expects to correctly populate the page.
- */
-var flagsExperimentsDataFormat = {
- 'flagsExperiments': [
- {
- 'internal_name': 'Experiment ID string',
- 'name': 'Experiment Name',
- 'description': 'description',
- /* enabled is only set if the experiment is single valued */
- 'enabled': true,
- /* choices is only set if the experiment has multiple values */
- 'choices': [
- {
- 'internal_name': 'Experiment ID string',
- 'description': 'description',
- 'selected': true
- }
- ]
- }
- ],
- 'needsRestart': false
-};
-
-/**
- * Takes the |flagsExperimentsData| input argument which represents data about
- * the currently available experiments and populates the html jstemplate
- * with that data. It expects an object structure like the above.
- * @param {Object} flagsExperimentsData Information about available experiments
- */
-function renderTemplate(flagsExperimentsData) {
- // This is the javascript code that processes the template:
- var input = new JsEvalContext(flagsExperimentsData);
- var output = document.getElementById('flagsExperimentTemplate');
- jstProcess(input, output);
-}
-
-/**
- * Asks the C++ FlagsDOMHandler to get details about the available experiments
- * and return detailed data about the configuration. The FlagsDOMHandler
- * should reply to returnFlagsExperiments() (below).
- */
-function requestFlagsExperimentsData() {
- chrome.send('requestFlagsExperiments', []);
-}
-
-/**
- * Asks the C++ FlagsDOMHandler to restart the browser (restoring tabs).
- */
-function restartBrowser() {
- chrome.send('restartBrowser', []);
-}
-
-/**
- * Called by the WebUI to re-populate the page with data representing the
- * current state of installed experiments.
- */
-function returnFlagsExperiments(flagsExperimentsData){
- var bodyContainer = document.getElementById('body-container');
- renderTemplate(flagsExperimentsData);
- bodyContainer.style.visibility = 'visible';
-}
-
-/**
- * Handles a 'enable' or 'disable' button getting clicked.
- */
-function handleEnableExperiment(node, enable) {
- // Tell the C++ FlagsDOMHandler to enable/disable the experiment.
- chrome.send('enableFlagsExperiment', [String(node.internal_name),
- String(enable)]);
- requestFlagsExperimentsData();
-}
-
-/**
- * Invoked when the selection of a multi-value choice is changed to the
- * specified index.
- */
-function handleSelectChoiceExperiment(node, index) {
- // Tell the C++ FlagsDOMHandler to enable the selected choice.
- chrome.send('enableFlagsExperiment',
- [String(node.internal_name) + "@" + index, "true"]);
- requestFlagsExperimentsData();
-}
-
-// Get data and have it displayed upon loading.
-document.addEventListener('DOMContentLoaded', requestFlagsExperimentsData);
-
-</script>
-</head>
<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
<div id="body-container" style="visibility:hidden">
@@ -290,8 +203,9 @@
<span jsvalues=".innerHTML:description">
</div>
<div jsdisplay="choices && choices.length > 0">
- <select jsvalues=".internal_name:internal_name;.disabled:!enabled"
- onchange="handleSelectChoiceExperiment(this, this.selectedIndex)">
+ <select
+ classs="experiment-select"
Evan Stade 2011/06/18 00:37:25 s/classs/class also 4 space indent rather than 2
+ jsvalues=".internal_name:internal_name;.disabled:!enabled">
<option jsvalues=".selected:selected"
jsselect="choices"
jscontent="description">NAME
@@ -305,18 +219,18 @@
then both jsdisplay tests fail, and we get no
rendering from this section. -->
<span>
- <a
+ <a
+ class="experiment-disable-link"
jsvalues=".internal_name:internal_name"
jsdisplay="enabled"
- onclick="handleEnableExperiment(this, false)"
- href="javascript:void(0);"
+ href="#"
i18n-content="disable"
>DISABLE</a>
<a
+ class="experiment-enable-link"
jsvalues=".internal_name:internal_name"
jsdisplay="!enabled"
- onclick="handleEnableExperiment(this, true)"
- href="javascript:void(0);"
+ href="#"
i18n-content="enable"
>ENABLE</a>
</span>
@@ -329,12 +243,17 @@
<div class="needs-restart" jsdisplay="needsRestart">
<div i18n-content="flagsRestartNotice">NEEDS_RESTART</div>
- <button type="button"
- onclick="restartBrowser();"
+ <button class="experiment-restart-button"
+ type="button"
i18n-content="flagsRestartButton">RESTART</button>
</div>
</div>
</div>
</div>
+<script src="chrome://flags/flags.js"></script>
+<script src="chrome://flags/strings.js"></script>
+<script src="chrome://resources/js/i18n_template.js"></script>
+<script src="chrome://resources/js/i18n_process.js"></script>
+<script src="chrome://resources/js/jstemplate_compiled.js"></script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698