Chromium Code Reviews| 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * A lookup helper function to find the first node that has an id (starting | 9 * A lookup helper function to find the first node that has an id (starting |
| 10 * at |node| and going up the parent chain). | 10 * at |node| and going up the parent chain). |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 this.showExtensionNodes_(); | 42 this.showExtensionNodes_(); |
| 43 }, | 43 }, |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Creates all extension items from scratch. | 46 * Creates all extension items from scratch. |
| 47 * @private | 47 * @private |
| 48 */ | 48 */ |
| 49 showExtensionNodes_: function() { | 49 showExtensionNodes_: function() { |
| 50 // Iterate over the extension data and add each item to the list. | 50 // Iterate over the extension data and add each item to the list. |
| 51 var list = this; | 51 this.data_.extensions.forEach(this.createNode_, this); |
| 52 this.data_.extensions.forEach(this.createNode_.bind(this)); | |
| 53 | 52 |
| 54 if (this.data_.extensions.length == 0) | 53 if (this.data_.extensions.length == 0) |
| 55 this.classList.add('empty-extension-list'); | 54 this.classList.add('empty-extension-list'); |
| 56 else | 55 else |
| 57 this.classList.remove('empty-extension-list'); | 56 this.classList.remove('empty-extension-list'); |
| 58 }, | 57 }, |
| 59 | 58 |
| 60 /** | 59 /** |
| 61 * Synthesizes and initializes an HTML element for the extension metadata | 60 * Synthesizes and initializes an HTML element for the extension metadata |
| 62 * given in |extension|. | 61 * given in |extension|. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 91 if (extension.enable_show_button) { | 90 if (extension.enable_show_button) { |
| 92 var showButton = node.querySelector('.show-button'); | 91 var showButton = node.querySelector('.show-button'); |
| 93 showButton.addEventListener('click', function(e) { | 92 showButton.addEventListener('click', function(e) { |
| 94 chrome.send('extensionSettingsShowButton', [extension.id]); | 93 chrome.send('extensionSettingsShowButton', [extension.id]); |
| 95 }); | 94 }); |
| 96 showButton.hidden = false; | 95 showButton.hidden = false; |
| 97 } | 96 } |
| 98 | 97 |
| 99 // The 'allow in incognito' checkbox. | 98 // The 'allow in incognito' checkbox. |
| 100 var incognito = node.querySelector('.incognito-control'); | 99 var incognito = node.querySelector('.incognito-control'); |
| 101 var butterBar = node.querySelector('.butter-bar'); | 100 var butterBar = node.querySelector('.incognito-butter-bar'); |
| 102 incognito.addEventListener('click', function(e) { | 101 incognito.addEventListener('click', function(e) { |
| 103 var checked = e.target.checked; | 102 var checked = e.target.checked; |
| 104 butterBarVisibility[extension.id] = checked; | 103 butterBarVisibility[extension.id] = checked; |
| 105 butterBar.hidden = !checked || extension.is_hosted_app; | 104 butterBar.hidden = !checked || extension.is_hosted_app; |
| 106 chrome.send('extensionSettingsEnableIncognito', | 105 chrome.send('extensionSettingsEnableIncognito', |
| 107 [extension.id, String(checked)]); | 106 [extension.id, String(checked)]); |
| 108 }); | 107 }); |
| 109 incognito.querySelector('input').checked = extension.enabledIncognito; | 108 incognito.querySelector('input').checked = extension.enabledIncognito; |
| 110 butterBar.hidden = !butterBarVisibility[extension.id]; | 109 butterBar.hidden = !butterBarVisibility[extension.id]; |
| 111 | 110 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 | 145 |
| 147 // The 'Reload' checkbox. | 146 // The 'Reload' checkbox. |
| 148 if (extension.allow_reload) { | 147 if (extension.allow_reload) { |
| 149 var reload = node.querySelector('.reload-link'); | 148 var reload = node.querySelector('.reload-link'); |
| 150 reload.addEventListener('click', function(e) { | 149 reload.addEventListener('click', function(e) { |
| 151 chrome.send('extensionSettingsReload', [extension.id]); | 150 chrome.send('extensionSettingsReload', [extension.id]); |
| 152 }); | 151 }); |
| 153 reload.hidden = false; | 152 reload.hidden = false; |
| 154 } | 153 } |
| 155 | 154 |
| 155 // Disable optional controls in managed mode. | |
| 156 if (this.data_.managedMode) { | |
|
Evan Stade
2012/03/13 21:02:07
node.querySelector('.optional-controls').hidden =
| |
| 157 var optional = node.querySelector('.optional-controls'); | |
| 158 optional.hidden = true; | |
| 159 } | |
| 160 | |
| 156 if (!extension.terminated) { | 161 if (!extension.terminated) { |
| 157 // The 'Enabled' checkbox. | 162 // The 'Enabled' checkbox. |
| 158 var enable = node.querySelector('.enable-checkbox'); | 163 var enable = node.querySelector('.enable-checkbox'); |
| 159 enable.hidden = false; | 164 enable.hidden = false; |
| 160 enable.querySelector('input').disabled = !extension.mayDisable; | 165 enable.querySelector('input').disabled = !extension.mayDisable; |
| 161 | 166 |
| 162 if (extension.mayDisable) { | 167 if (extension.mayDisable) { |
| 163 enable.addEventListener('click', function(e) { | 168 enable.addEventListener('click', function(e) { |
| 164 chrome.send('extensionSettingsEnable', | 169 chrome.send('extensionSettingsEnable', |
| 165 [extension.id, e.target.checked ? 'true' : 'false']); | 170 [extension.id, e.target.checked ? 'true' : 'false']); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 } | 238 } |
| 234 | 239 |
| 235 this.appendChild(node); | 240 this.appendChild(node); |
| 236 }, | 241 }, |
| 237 }; | 242 }; |
| 238 | 243 |
| 239 return { | 244 return { |
| 240 ExtensionsList: ExtensionsList | 245 ExtensionsList: ExtensionsList |
| 241 }; | 246 }; |
| 242 }); | 247 }); |
| OLD | NEW |