OLD | NEW |
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 | 9 |
10 /** | 10 /** |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 elements[i].onclick = function() { | 42 elements[i].onclick = function() { |
43 handleEnableExperiment(this, true); | 43 handleEnableExperiment(this, true); |
44 return false; | 44 return false; |
45 }; | 45 }; |
46 } | 46 } |
47 | 47 |
48 elements = document.getElementsByClassName('experiment-restart-button'); | 48 elements = document.getElementsByClassName('experiment-restart-button'); |
49 for (var i = 0; i < elements.length; ++i) { | 49 for (var i = 0; i < elements.length; ++i) { |
50 elements[i].onclick = restartBrowser; | 50 elements[i].onclick = restartBrowser; |
51 } | 51 } |
| 52 |
| 53 $('experiment-reset-all').onclick = resetAllFlags; |
52 } | 54 } |
53 | 55 |
54 /** | 56 /** |
55 * Asks the C++ FlagsDOMHandler to get details about the available experiments | 57 * Asks the C++ FlagsDOMHandler to get details about the available experiments |
56 * and return detailed data about the configuration. The FlagsDOMHandler | 58 * and return detailed data about the configuration. The FlagsDOMHandler |
57 * should reply to returnFlagsExperiments() (below). | 59 * should reply to returnFlagsExperiments() (below). |
58 */ | 60 */ |
59 function requestFlagsExperimentsData() { | 61 function requestFlagsExperimentsData() { |
60 chrome.send('requestFlagsExperiments'); | 62 chrome.send('requestFlagsExperiments'); |
61 } | 63 } |
62 | 64 |
63 /** | 65 /** |
64 * Asks the C++ FlagsDOMHandler to restart the browser (restoring tabs). | 66 * Asks the C++ FlagsDOMHandler to restart the browser (restoring tabs). |
65 */ | 67 */ |
66 function restartBrowser() { | 68 function restartBrowser() { |
67 chrome.send('restartBrowser'); | 69 chrome.send('restartBrowser'); |
68 } | 70 } |
69 | 71 |
70 /** | 72 /** |
| 73 * Reset all flags to their default values and refresh the UI. |
| 74 */ |
| 75 function resetAllFlags() { |
| 76 // Asks the C++ FlagsDOMHandler to reset all flags to default values. |
| 77 chrome.send('resetAllFlags'); |
| 78 requestFlagsExperimentsData(); |
| 79 } |
| 80 |
| 81 /** |
71 * Called by the WebUI to re-populate the page with data representing the | 82 * Called by the WebUI to re-populate the page with data representing the |
72 * current state of installed experiments. | 83 * current state of installed experiments. |
73 * @param {Object} flagsExperimentsData Information about available experiments | 84 * @param {Object} flagsExperimentsData Information about available experiments |
74 * in the following format: | 85 * in the following format: |
75 * { | 86 * { |
76 * flagsExperiments: [ | 87 * flagsExperiments: [ |
77 * { | 88 * { |
78 * internal_name: 'Experiment ID string', | 89 * internal_name: 'Experiment ID string', |
79 * name: 'Experiment Name', | 90 * name: 'Experiment Name', |
80 * description: 'description', | 91 * description: 'description', |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 function handleSelectChoiceExperiment(node, index) { | 136 function handleSelectChoiceExperiment(node, index) { |
126 // Tell the C++ FlagsDOMHandler to enable the selected choice. | 137 // Tell the C++ FlagsDOMHandler to enable the selected choice. |
127 chrome.send('enableFlagsExperiment', | 138 chrome.send('enableFlagsExperiment', |
128 [String(node.internal_name) + '@' + index, 'true']); | 139 [String(node.internal_name) + '@' + index, 'true']); |
129 requestFlagsExperimentsData(); | 140 requestFlagsExperimentsData(); |
130 } | 141 } |
131 | 142 |
132 // Get data and have it displayed upon loading. | 143 // Get data and have it displayed upon loading. |
133 document.addEventListener('DOMContentLoaded', requestFlagsExperimentsData); | 144 document.addEventListener('DOMContentLoaded', requestFlagsExperimentsData); |
134 | 145 |
OLD | NEW |