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 10083028: [WebUI] Remove needless large object literal. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove flags.js literal as well Created 8 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/resources/plugins.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * This variable structure is here to document the structure that the template 6 * This variable structure is here to document the structure that the template
7 * expects to correctly populate the page. 7 * expects to correctly populate the page.
8 */ 8 */
9 var flagsExperimentsDataFormat = {
10 flagsExperiments: [
11 {
12 internal_name: 'Experiment ID string',
13 name: 'Experiment Name',
14 description: 'description',
15 // enabled is only set if the experiment is single valued.
16 enabled: true,
17 // choices is only set if the experiment has multiple values.
18 choices: [
19 {
20 internal_name: 'Experiment ID string',
21 description: 'description',
22 selected: true
23 }
24 ],
25 supported: true,
26 supported_platforms: [
27 'Mac',
28 'Linux'
29 ],
30 }
31 ],
32 needsRestart: false
33 };
34 9
35 /** 10 /**
36 * Takes the |flagsExperimentsData| input argument which represents data about 11 * Takes the |flagsExperimentsData| input argument which represents data about
37 * the currently available experiments and populates the html jstemplate 12 * the currently available experiments and populates the html jstemplate
38 * with that data. It expects an object structure like the above. 13 * with that data. It expects an object structure like the above.
39 * @param {Object} flagsExperimentsData Information about available experiments 14 * @param {Object} flagsExperimentsData Information about available experiments.
40 * in the format of the flagsExperimentsDataFormat object above. 15 * See returnFlagsExperiments() for the structure of this object.
41 */ 16 */
42 function renderTemplate(flagsExperimentsData) { 17 function renderTemplate(flagsExperimentsData) {
43 // This is the javascript code that processes the template: 18 // This is the javascript code that processes the template:
44 var input = new JsEvalContext(flagsExperimentsData); 19 var input = new JsEvalContext(flagsExperimentsData);
45 var output = $('flagsExperimentTemplate'); 20 var output = $('flagsExperimentTemplate');
46 jstProcess(input, output); 21 jstProcess(input, output);
47 22
48 // Add handlers to dynamically created HTML elements. 23 // Add handlers to dynamically created HTML elements.
49 var elements = document.getElementsByClassName('experiment-select'); 24 var elements = document.getElementsByClassName('experiment-select');
50 for (var i = 0; i < elements.length; ++i) { 25 for (var i = 0; i < elements.length; ++i) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 * Asks the C++ FlagsDOMHandler to restart the browser (restoring tabs). 64 * Asks the C++ FlagsDOMHandler to restart the browser (restoring tabs).
90 */ 65 */
91 function restartBrowser() { 66 function restartBrowser() {
92 chrome.send('restartBrowser'); 67 chrome.send('restartBrowser');
93 } 68 }
94 69
95 /** 70 /**
96 * Called by the WebUI to re-populate the page with data representing the 71 * Called by the WebUI to re-populate the page with data representing the
97 * current state of installed experiments. 72 * current state of installed experiments.
98 * @param {Object} flagsExperimentsData Information about available experiments 73 * @param {Object} flagsExperimentsData Information about available experiments
99 * in the format of the flagsExperimentsDataFormat object above. 74 * in the following format:
75 * {
76 * flagsExperiments: [
77 * {
78 * internal_name: 'Experiment ID string',
79 * name: 'Experiment Name',
80 * description: 'description',
81 * // enabled is only set if the experiment is single valued.
82 * enabled: true,
83 * // choices is only set if the experiment has multiple values.
84 * choices: [
85 * {
86 * internal_name: 'Experiment ID string',
87 * description: 'description',
88 * selected: true
89 * }
90 * ],
91 * supported: true,
92 * supported_platforms: [
93 * 'Mac',
94 * 'Linux'
95 * ],
96 * }
97 * ],
98 * needsRestart: false
99 * }
100 */ 100 */
101 function returnFlagsExperiments(flagsExperimentsData) { 101 function returnFlagsExperiments(flagsExperimentsData) {
102 var bodyContainer = $('body-container'); 102 var bodyContainer = $('body-container');
103 renderTemplate(flagsExperimentsData); 103 renderTemplate(flagsExperimentsData);
104 bodyContainer.style.visibility = 'visible'; 104 bodyContainer.style.visibility = 'visible';
105 } 105 }
106 106
107 /** 107 /**
108 * Handles a 'enable' or 'disable' button getting clicked. 108 * Handles a 'enable' or 'disable' button getting clicked.
109 * @param {HTMLElement} node The node for the experiment being changed. 109 * @param {HTMLElement} node The node for the experiment being changed.
(...skipping 15 matching lines...) Expand all
125 function handleSelectChoiceExperiment(node, index) { 125 function handleSelectChoiceExperiment(node, index) {
126 // Tell the C++ FlagsDOMHandler to enable the selected choice. 126 // Tell the C++ FlagsDOMHandler to enable the selected choice.
127 chrome.send('enableFlagsExperiment', 127 chrome.send('enableFlagsExperiment',
128 [String(node.internal_name) + '@' + index, 'true']); 128 [String(node.internal_name) + '@' + index, 'true']);
129 requestFlagsExperimentsData(); 129 requestFlagsExperimentsData();
130 } 130 }
131 131
132 // Get data and have it displayed upon loading. 132 // Get data and have it displayed upon loading.
133 document.addEventListener('DOMContentLoaded', requestFlagsExperimentsData); 133 document.addEventListener('DOMContentLoaded', requestFlagsExperimentsData);
134 134
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/plugins.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698