| 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"> | 5 <include src="extension_error.js"> |
| 6 | 6 |
| 7 /////////////////////////////////////////////////////////////////////////////// | 7 /////////////////////////////////////////////////////////////////////////////// |
| 8 // ExtensionFocusRow: | 8 // ExtensionFocusRow: |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 // becomes enabled/disabled. It also might not become enabled or | 632 // becomes enabled/disabled. It also might not become enabled or |
| 633 // disabled, because the user might e.g. get prompted when enabling | 633 // disabled, because the user might e.g. get prompted when enabling |
| 634 // and choose not to. | 634 // and choose not to. |
| 635 e.preventDefault(); | 635 e.preventDefault(); |
| 636 }); | 636 }); |
| 637 | 637 |
| 638 // 'Remove' button. | 638 // 'Remove' button. |
| 639 var trashTemplate = $('template-collection').querySelector('.trash'); | 639 var trashTemplate = $('template-collection').querySelector('.trash'); |
| 640 var trash = trashTemplate.cloneNode(true); | 640 var trash = trashTemplate.cloneNode(true); |
| 641 trash.title = loadTimeData.getString('extensionUninstall'); | 641 trash.title = loadTimeData.getString('extensionUninstall'); |
| 642 trash.hidden = !extension.userMayModify; | |
| 643 trash.setAttribute('column-type', 'trash'); | 642 trash.setAttribute('column-type', 'trash'); |
| 644 trash.addEventListener('click', function(e) { | 643 trash.addEventListener('click', function(e) { |
| 645 trash.classList.add('open'); | 644 trash.classList.add('open'); |
| 646 trash.classList.toggle('mouse-clicked', e.detail > 0); | 645 trash.classList.toggle('mouse-clicked', e.detail > 0); |
| 647 if (this.uninstallIsShowing_) | 646 if (this.uninstallIsShowing_) |
| 648 return; | 647 return; |
| 649 this.uninstallIsShowing_ = true; | 648 this.uninstallIsShowing_ = true; |
| 650 chrome.management.uninstall(extension.id, | 649 chrome.management.uninstall(extension.id, |
| 651 {showConfirmDialog: true}, | 650 {showConfirmDialog: true}, |
| 652 function() { | 651 function() { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 * @private | 694 * @private |
| 696 */ | 695 */ |
| 697 updateNode_: function(extension, row) { | 696 updateNode_: function(extension, row) { |
| 698 var isActive = | 697 var isActive = |
| 699 extension.state == chrome.developerPrivate.ExtensionState.ENABLED; | 698 extension.state == chrome.developerPrivate.ExtensionState.ENABLED; |
| 700 row.classList.toggle('inactive-extension', !isActive); | 699 row.classList.toggle('inactive-extension', !isActive); |
| 701 | 700 |
| 702 // Hack to keep the closure compiler happy about |remove|. | 701 // Hack to keep the closure compiler happy about |remove|. |
| 703 // TODO(hcarmona): Remove this hack when the closure compiler is updated. | 702 // TODO(hcarmona): Remove this hack when the closure compiler is updated. |
| 704 var node = /** @type {Element} */ (row); | 703 var node = /** @type {Element} */ (row); |
| 705 node.classList.remove('policy-controlled', 'may-not-modify', | 704 node.classList.remove('controlled', 'may-not-remove'); |
| 706 'may-not-remove'); | |
| 707 var classes = []; | 705 var classes = []; |
| 708 if (!extension.userMayModify) { | 706 if (extension.controlledInfo) { |
| 709 classes.push('policy-controlled', 'may-not-modify'); | 707 classes.push('controlled'); |
| 710 } else if (extension.dependentExtensions.length > 0) { | 708 } else if (!extension.userMayModify || |
| 711 classes.push('may-not-remove', 'may-not-modify'); | 709 extension.mustRemainInstalled || |
| 712 } else if (extension.mustRemainInstalled) { | 710 extension.dependentExtensions.length > 0) { |
| 713 classes.push('may-not-remove'); | 711 classes.push('may-not-remove'); |
| 714 } else if (extension.disableReasons.suspiciousInstall || | |
| 715 extension.disableReasons.corruptInstall || | |
| 716 extension.disableReasons.updateRequired) { | |
| 717 classes.push('may-not-modify'); | |
| 718 } | 712 } |
| 719 row.classList.add.apply(row.classList, classes); | 713 row.classList.add.apply(row.classList, classes); |
| 720 | 714 |
| 721 var item = row.querySelector('.extension-list-item'); | 715 var item = row.querySelector('.extension-list-item'); |
| 722 item.style.backgroundImage = 'url(' + extension.iconUrl + ')'; | 716 item.style.backgroundImage = 'url(' + extension.iconUrl + ')'; |
| 723 | 717 |
| 724 this.setText_(row, '.extension-title', extension.name); | 718 this.setText_(row, '.extension-title', extension.name); |
| 725 this.setText_(row, '.extension-version', extension.version); | 719 this.setText_(row, '.extension-version', extension.version); |
| 726 this.setText_(row, '.location-text', extension.locationText || ''); | 720 this.setText_(row, '.location-text', extension.locationText || ''); |
| 727 this.setText_(row, '.blacklist-text', extension.blacklistText || ''); | 721 this.setText_(row, '.blacklist-text', extension.blacklistText || ''); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 this.updateVisibility_(row, '.corrupted-repair-button', canRepair); | 837 this.updateVisibility_(row, '.corrupted-repair-button', canRepair); |
| 844 | 838 |
| 845 // The 'Enabled' checkbox. | 839 // The 'Enabled' checkbox. |
| 846 var isOK = !isTerminated && !canRepair; | 840 var isOK = !isTerminated && !canRepair; |
| 847 this.updateVisibility_(row, '.enable-checkbox', isOK, function(item) { | 841 this.updateVisibility_(row, '.enable-checkbox', isOK, function(item) { |
| 848 var enableCheckboxDisabled = | 842 var enableCheckboxDisabled = |
| 849 !extension.userMayModify || | 843 !extension.userMayModify || |
| 850 extension.disableReasons.suspiciousInstall || | 844 extension.disableReasons.suspiciousInstall || |
| 851 extension.disableReasons.corruptInstall || | 845 extension.disableReasons.corruptInstall || |
| 852 extension.disableReasons.updateRequired || | 846 extension.disableReasons.updateRequired || |
| 853 extension.installedByCustodian || | |
| 854 extension.dependentExtensions.length > 0; | 847 extension.dependentExtensions.length > 0; |
| 855 item.querySelector('input').disabled = enableCheckboxDisabled; | 848 item.querySelector('input').disabled = enableCheckboxDisabled; |
| 856 item.querySelector('input').checked = isActive; | 849 item.querySelector('input').checked = isActive; |
| 857 }); | 850 }); |
| 858 | 851 |
| 859 // Button for extensions controlled by policy. | 852 // Indicator for extensions controlled by policy. |
| 860 var controlNode = row.querySelector('.enable-controls'); | 853 var controlNode = row.querySelector('.enable-controls'); |
| 861 var indicator = | 854 var indicator = |
| 862 controlNode.querySelector('.controlled-extension-indicator'); | 855 controlNode.querySelector('.controlled-extension-indicator'); |
| 863 var needsIndicator = isOK && | 856 var needsIndicator = isOK && extension.controlledInfo; |
| 864 !extension.userMayModify && | |
| 865 extension.policyText; | |
| 866 // TODO(treib): If userMayModify is false, but policyText is empty, that | |
| 867 // indicates this extension is controlled by something else than | |
| 868 // enterprise policy (such as the profile being supervised). For now, just | |
| 869 // don't show the indicator in this case. We should really handle this | |
| 870 // better though (ie use a different text and icon). | |
| 871 | 857 |
| 872 if (needsIndicator && !indicator) { | 858 if (needsIndicator && !indicator) { |
| 873 indicator = new cr.ui.ControlledIndicator(); | 859 indicator = new cr.ui.ControlledIndicator(); |
| 874 indicator.classList.add('controlled-extension-indicator'); | 860 indicator.classList.add('controlled-extension-indicator'); |
| 875 indicator.setAttribute('controlled-by', 'policy'); | 861 var ControllerType = chrome.developerPrivate.ControllerType; |
| 876 var textPolicy = extension.policyText || ''; | 862 var controlledByStr = ''; |
| 877 indicator.setAttribute('textpolicy', textPolicy); | 863 switch (extension.controlledInfo.type) { |
| 878 indicator.image.setAttribute('aria-label', textPolicy); | 864 case ControllerType.POLICY: |
| 865 controlledByStr = 'policy'; |
| 866 break; |
| 867 case ControllerType.CHILD_CUSTODIAN: |
| 868 controlledByStr = 'child-custodian'; |
| 869 break; |
| 870 case ControllerType.SUPERVISED_USER_CUSTODIAN: |
| 871 controlledByStr = 'supervised-user-custodian'; |
| 872 break; |
| 873 } |
| 874 indicator.setAttribute('controlled-by', controlledByStr); |
| 875 var text = extension.controlledInfo.text; |
| 876 indicator.setAttribute('text' + controlledByStr, text); |
| 877 indicator.image.setAttribute('aria-label', text); |
| 879 controlNode.appendChild(indicator); | 878 controlNode.appendChild(indicator); |
| 880 indicator.querySelector('div').setAttribute('column-type', | 879 indicator.querySelector('div').setAttribute('column-type', |
| 881 'enterprise'); | 880 'enterprise'); |
| 882 } else if (!needsIndicator && indicator) { | 881 } else if (!needsIndicator && indicator) { |
| 883 controlNode.removeChild(indicator); | 882 controlNode.removeChild(indicator); |
| 884 } | 883 } |
| 885 | 884 |
| 886 // Developer mode //////////////////////////////////////////////////////// | 885 // Developer mode //////////////////////////////////////////////////////// |
| 887 | 886 |
| 888 // First we have the id. | 887 // First we have the id. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 this.createNode_(extension, nextExt ? $(nextExt.id) : null); | 1169 this.createNode_(extension, nextExt ? $(nextExt.id) : null); |
| 1171 } | 1170 } |
| 1172 } | 1171 } |
| 1173 }; | 1172 }; |
| 1174 | 1173 |
| 1175 return { | 1174 return { |
| 1176 ExtensionList: ExtensionList, | 1175 ExtensionList: ExtensionList, |
| 1177 ExtensionListDelegate: ExtensionListDelegate | 1176 ExtensionListDelegate: ExtensionListDelegate |
| 1178 }; | 1177 }; |
| 1179 }); | 1178 }); |
| OLD | NEW |