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

Side by Side Diff: chrome/browser/resources/flags.js

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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /**
Evan Stade 2011/06/18 00:37:25 license header
2 * This variable structure is here to document the structure that the template
3 * expects to correctly populate the page.
4 */
5 var flagsExperimentsDataFormat = {
6 'flagsExperiments': [
7 {
8 'internal_name': 'Experiment ID string',
9 'name': 'Experiment Name',
10 'description': 'description',
11 /* enabled is only set if the experiment is single valued */
Evan Stade 2011/06/18 00:37:25 C++ style comments (//), final punctuation
12 'enabled': true,
13 /* choices is only set if the experiment has multiple values */
14 'choices': [
15 {
16 'internal_name': 'Experiment ID string',
17 'description': 'description',
18 'selected': true
19 }
20 ]
21 }
22 ],
23 'needsRestart': false
24 };
25
26 /**
27 * Takes the |flagsExperimentsData| input argument which represents data about
28 * the currently available experiments and populates the html jstemplate
29 * with that data. It expects an object structure like the above.
30 * @param {Object} flagsExperimentsData Information about available experiments
31 */
32 function renderTemplate(flagsExperimentsData) {
33 // This is the javascript code that processes the template:
34 var input = new JsEvalContext(flagsExperimentsData);
35 var output = document.getElementById('flagsExperimentTemplate');
36 jstProcess(input, output);
37
38 // Add handlers to dynamically created HTML elements.
39 var elements = document.getElementsByClassName('experiment-select');
40 for (var i = 0; i < elements.length; ++i) {
41 elements[i].onclick = function () {
42 handleSelectChoiceExperiment(this, this.selectedIndex);
43 return false;
44 };
45 }
46
47 elements = document.getElementsByClassName('experiment-disable-link');
48 for (var i = 0; i < elements.length; ++i) {
49 elements[i].onclick = function () {
50 handleEnableExperiment(this, false);
51 return false;
52 };
53 }
54
55 elements = document.getElementsByClassName('experiment-enable-link');
56 for (var i = 0; i < elements.length; ++i) {
57 elements[i].onclick = function () {
58 handleEnableExperiment(this, true);
59 return false;
60 };
61 }
62
63 elements = document.getElementsByClassName('experiment-restart-button');
64 for (var i = 0; i < elements.length; ++i) {
65 elements[i].onclick = restartBrowser;
66 }
67 }
68
69 /**
70 * Asks the C++ FlagsDOMHandler to get details about the available experiments
71 * and return detailed data about the configuration. The FlagsDOMHandler
72 * should reply to returnFlagsExperiments() (below).
73 */
74 function requestFlagsExperimentsData() {
75 chrome.send('requestFlagsExperiments', []);
76 }
77
78 /**
79 * Asks the C++ FlagsDOMHandler to restart the browser (restoring tabs).
80 */
81 function restartBrowser() {
82 chrome.send('restartBrowser', []);
83 }
84
85 /**
86 * Called by the WebUI to re-populate the page with data representing the
87 * current state of installed experiments.
88 */
89 function returnFlagsExperiments(flagsExperimentsData){
90 var bodyContainer = document.getElementById('body-container');
91 renderTemplate(flagsExperimentsData);
92 bodyContainer.style.visibility = 'visible';
93 }
94
95 /**
96 * Handles a 'enable' or 'disable' button getting clicked.
97 */
98 function handleEnableExperiment(node, enable) {
99 // Tell the C++ FlagsDOMHandler to enable/disable the experiment.
100 chrome.send('enableFlagsExperiment', [String(node.internal_name),
101 String(enable)]);
102 requestFlagsExperimentsData();
103 }
104
105 /**
106 * Invoked when the selection of a multi-value choice is changed to the
107 * specified index.
108 */
109 function handleSelectChoiceExperiment(node, index) {
110 // Tell the C++ FlagsDOMHandler to enable the selected choice.
111 chrome.send('enableFlagsExperiment',
112 [String(node.internal_name) + "@" + index, "true"]);
113 requestFlagsExperimentsData();
114 }
115
116 // Get data and have it displayed upon loading.
117 document.addEventListener('DOMContentLoaded', requestFlagsExperimentsData);
118
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698