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 <include src="extension_error.js"></include> | 5 <include src="extension_error.js"></include> |
6 | 6 |
7 cr.define('options', function() { | 7 cr.define('options', function() { |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 /** | 10 /** |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 */ | 78 */ |
79 createNode_: function(extension) { | 79 createNode_: function(extension) { |
80 var template = $('template-collection').querySelector( | 80 var template = $('template-collection').querySelector( |
81 '.extension-list-item-wrapper'); | 81 '.extension-list-item-wrapper'); |
82 var node = template.cloneNode(true); | 82 var node = template.cloneNode(true); |
83 node.id = extension.id; | 83 node.id = extension.id; |
84 | 84 |
85 if (!extension.enabled || extension.terminated) | 85 if (!extension.enabled || extension.terminated) |
86 node.classList.add('inactive-extension'); | 86 node.classList.add('inactive-extension'); |
87 | 87 |
88 if (extension.managedInstall) { | 88 if (extension.managedInstall || |
| 89 extension.dependentExtensions.length > 0) { |
89 node.classList.add('may-not-modify'); | 90 node.classList.add('may-not-modify'); |
90 node.classList.add('may-not-remove'); | 91 node.classList.add('may-not-remove'); |
91 } else if (extension.suspiciousInstall || extension.corruptInstall) { | 92 } else if (extension.suspiciousInstall || extension.corruptInstall) { |
92 node.classList.add('may-not-modify'); | 93 node.classList.add('may-not-modify'); |
93 } | 94 } |
94 | 95 |
95 var idToHighlight = this.getIdQueryParam_(); | 96 var idToHighlight = this.getIdQueryParam_(); |
96 if (node.id == idToHighlight) | 97 if (node.id == idToHighlight) |
97 node.classList.add('extension-highlight'); | 98 node.classList.add('extension-highlight'); |
98 | 99 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 chrome.send('extensionSettingsLaunch', [extension.id]); | 230 chrome.send('extensionSettingsLaunch', [extension.id]); |
230 }); | 231 }); |
231 launch.hidden = false; | 232 launch.hidden = false; |
232 } | 233 } |
233 } | 234 } |
234 | 235 |
235 if (!extension.terminated) { | 236 if (!extension.terminated) { |
236 // The 'Enabled' checkbox. | 237 // The 'Enabled' checkbox. |
237 var enable = node.querySelector('.enable-checkbox'); | 238 var enable = node.querySelector('.enable-checkbox'); |
238 enable.hidden = false; | 239 enable.hidden = false; |
239 var managedOrHosedExtension = extension.managedInstall || | 240 var enableCheckboxDisabled = extension.managedInstall || |
240 extension.suspiciousInstall || | 241 extension.suspiciousInstall || |
241 extension.corruptInstall; | 242 extension.corruptInstall || |
242 enable.querySelector('input').disabled = managedOrHosedExtension; | 243 extension.dependentExtensions.length > 0; |
| 244 enable.querySelector('input').disabled = enableCheckboxDisabled; |
243 | 245 |
244 if (!managedOrHosedExtension) { | 246 if (!enableCheckboxDisabled) { |
245 enable.addEventListener('click', function(e) { | 247 enable.addEventListener('click', function(e) { |
246 // When e.target is the label instead of the checkbox, it doesn't | 248 // When e.target is the label instead of the checkbox, it doesn't |
247 // have the checked property and the state of the checkbox is | 249 // have the checked property and the state of the checkbox is |
248 // left unchanged. | 250 // left unchanged. |
249 var checked = e.target.checked; | 251 var checked = e.target.checked; |
250 if (checked == undefined) | 252 if (checked == undefined) |
251 checked = !e.currentTarget.querySelector('input').checked; | 253 checked = !e.currentTarget.querySelector('input').checked; |
252 chrome.send('extensionSettingsEnable', | 254 chrome.send('extensionSettingsEnable', |
253 [extension.id, checked ? 'true' : 'false']); | 255 [extension.id, checked ? 'true' : 'false']); |
254 | 256 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 if (extension.suspiciousInstall) { | 307 if (extension.suspiciousInstall) { |
306 // Then the 'This isn't from the webstore, looks suspicious' message. | 308 // Then the 'This isn't from the webstore, looks suspicious' message. |
307 node.querySelector('.suspicious-install-message').hidden = false; | 309 node.querySelector('.suspicious-install-message').hidden = false; |
308 } | 310 } |
309 if (extension.corruptInstall) { | 311 if (extension.corruptInstall) { |
310 // Then the 'This is a corrupt extension' message. | 312 // Then the 'This is a corrupt extension' message. |
311 node.querySelector('.corrupt-install-message').hidden = false; | 313 node.querySelector('.corrupt-install-message').hidden = false; |
312 } | 314 } |
313 } | 315 } |
314 | 316 |
| 317 if (extension.dependentExtensions.length > 0) { |
| 318 var dependentMessage = |
| 319 node.querySelector('.dependent-extensions-message'); |
| 320 dependentMessage.hidden = false; |
| 321 var dependentList = dependentMessage.querySelector('ul'); |
| 322 extension.dependentExtensions.forEach(function(id) { |
| 323 var li = document.createElement('li'); |
| 324 li.innerText = id; |
| 325 dependentList.appendChild(li); |
| 326 }); |
| 327 } |
| 328 |
315 // Then active views. | 329 // Then active views. |
316 if (extension.views.length > 0) { | 330 if (extension.views.length > 0) { |
317 var activeViews = node.querySelector('.active-views'); | 331 var activeViews = node.querySelector('.active-views'); |
318 activeViews.hidden = false; | 332 activeViews.hidden = false; |
319 var link = activeViews.querySelector('a'); | 333 var link = activeViews.querySelector('a'); |
320 | 334 |
321 extension.views.forEach(function(view, i) { | 335 extension.views.forEach(function(view, i) { |
322 var displayName = view.generatedBackgroundPage ? | 336 var displayName = view.generatedBackgroundPage ? |
323 loadTimeData.getString('backgroundPage') : view.path; | 337 loadTimeData.getString('backgroundPage') : view.path; |
324 var label = displayName + | 338 var label = displayName + |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 topScroll -= pad / 2; | 404 topScroll -= pad / 2; |
391 setScrollTopForDocument(document, topScroll); | 405 setScrollTopForDocument(document, topScroll); |
392 } | 406 } |
393 }, | 407 }, |
394 }; | 408 }; |
395 | 409 |
396 return { | 410 return { |
397 ExtensionsList: ExtensionsList | 411 ExtensionsList: ExtensionsList |
398 }; | 412 }; |
399 }); | 413 }); |
OLD | NEW |