Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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('extensions', function() { | 5 cr.define('extensions', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 var DetailView = Polymer({ | 8 var DetailView = Polymer({ |
| 9 is: 'extensions-detail-view', | 9 is: 'extensions-detail-view', |
| 10 | 10 |
| 11 behaviors: [Polymer.NeonAnimatableBehavior], | 11 behaviors: [I18nBehavior, Polymer.NeonAnimatableBehavior], |
| 12 | 12 |
| 13 properties: { | 13 properties: { |
| 14 /** | 14 /** |
| 15 * The underlying ExtensionInfo for the details being displayed. | 15 * The underlying ExtensionInfo for the details being displayed. |
| 16 * @type {chrome.developerPrivate.ExtensionInfo} | 16 * @type {chrome.developerPrivate.ExtensionInfo} |
| 17 */ | 17 */ |
| 18 data: Object, | 18 data: Object, |
| 19 | 19 |
| 20 /** @type {!extensions.ItemDelegate} */ | 20 /** @type {!extensions.ItemDelegate} */ |
| 21 delegate: Object, | 21 delegate: Object, |
| 22 | |
| 23 /** Whether the user has the UI's developer mode. */ | |
|
michaelpg
2017/03/06 22:19:57
I probably meant:
"Whether the user has toggled
Devlin
2017/03/07 01:18:56
Heh, whoops. Didn't mean to copy-paste the gramma
| |
| 24 inDevMode: Boolean, | |
| 22 }, | 25 }, |
| 23 | 26 |
| 24 ready: function() { | 27 ready: function() { |
| 25 this.sharedElements = {hero: this.$.main}; | 28 this.sharedElements = {hero: this.$.main}; |
| 26 /** @type {!extensions.AnimationHelper} */ | 29 /** @type {!extensions.AnimationHelper} */ |
| 27 this.animationHelper = new extensions.AnimationHelper(this, this.$.main); | 30 this.animationHelper = new extensions.AnimationHelper(this, this.$.main); |
| 28 }, | 31 }, |
| 29 | 32 |
| 30 /** @private */ | 33 /** @private */ |
| 31 onCloseButtonTap_: function() { | 34 onCloseButtonTap_: function() { |
| 32 this.fire('close'); | 35 this.fire('close'); |
| 33 }, | 36 }, |
| 34 | 37 |
| 35 /** | 38 /** |
| 36 * @return {boolean} | 39 * @return {boolean} |
| 37 * @private | 40 * @private |
| 38 */ | 41 */ |
| 42 isEnabled_: function() { return extensions.isEnabled(this.data.state); }, | |
| 43 | |
| 44 /** | |
| 45 * @return {boolean} | |
| 46 * @private | |
| 47 */ | |
| 48 isEnableToggleEnabled_: function() { | |
| 49 return extensions.userCanChangeEnablement(this.data); | |
| 50 }, | |
| 51 | |
| 52 /** | |
| 53 * @return {boolean} | |
| 54 * @private | |
| 55 */ | |
| 39 hasDependentExtensions_: function() { | 56 hasDependentExtensions_: function() { |
| 40 return this.data.dependentExtensions.length > 0; | 57 return this.data.dependentExtensions.length > 0; |
| 41 }, | 58 }, |
| 42 | 59 |
| 43 /** | 60 /** |
| 44 * @return {boolean} | 61 * @return {boolean} |
| 45 * @private | 62 * @private |
| 46 */ | 63 */ |
| 47 hasPermissions_: function() { | 64 hasPermissions_: function() { |
| 48 return this.data.permissions.length > 0; | 65 return this.data.permissions.length > 0; |
| 49 }, | 66 }, |
| 50 | 67 |
| 51 /** | 68 /** |
| 69 * @return {string} | |
| 70 * @private | |
| 71 */ | |
| 72 computeEnabledText_: function() { | |
| 73 // TODO(devlin): Get the full spectrum of these strings from bettes. | |
| 74 return this.isEnabled_() ? this.i18n('itemOn') : this.i18n('itemOff'); | |
| 75 }, | |
| 76 | |
| 77 /** | |
| 78 * @param {!chrome.developerPrivate.ExtensionView} view | |
| 79 * @return {string} | |
| 80 * @private | |
| 81 */ | |
| 82 computeInspectLabel_: function(view) { | |
| 83 return extensions.computeInspectableViewLabel(view); | |
| 84 }, | |
| 85 | |
| 86 /** | |
| 52 * @return {boolean} | 87 * @return {boolean} |
| 53 * @private | 88 * @private |
| 54 */ | 89 */ |
| 55 shouldShowHomepageButton_: function() { | 90 shouldShowHomepageButton_: function() { |
| 56 // Note: we ignore |data.homePage.specified| - we use an extension's | 91 // Note: we ignore |data.homePage.specified| - we use an extension's |
| 57 // webstore entry as a homepage if the extension didn't explicitly specify | 92 // webstore entry as a homepage if the extension didn't explicitly specify |
| 58 // a homepage. (|url| can still be unset in the case of unpacked | 93 // a homepage. (|url| can still be unset in the case of unpacked |
| 59 // extensions.) | 94 // extensions.) |
| 60 return this.data.homePage.url.length > 0; | 95 return this.data.homePage.url.length > 0; |
| 61 }, | 96 }, |
| 62 | 97 |
| 63 /** | 98 /** |
| 64 * @return {boolean} | 99 * @return {boolean} |
| 65 * @private | 100 * @private |
| 66 */ | 101 */ |
| 67 shouldShowOptionsButton_: function() { | 102 shouldShowOptionsLink_: function() { |
| 68 return !!this.data.optionsPage; | 103 return !!this.data.optionsPage; |
| 69 }, | 104 }, |
| 70 | 105 |
| 71 /** | 106 /** |
| 72 * @return {boolean} | 107 * @return {boolean} |
| 73 * @private | 108 * @private |
| 74 */ | 109 */ |
| 75 shouldShowOptionsSection_: function() { | 110 shouldShowOptionsSection_: function() { |
| 76 return this.data.incognitoAccess.isEnabled || | 111 return this.data.incognitoAccess.isEnabled || |
| 77 this.data.fileAccess.isEnabled || | 112 this.data.fileAccess.isEnabled || |
| 78 this.data.runOnAllUrls.isEnabled || | 113 this.data.runOnAllUrls.isEnabled || |
| 79 this.data.errorCollection.isEnabled; | 114 this.data.errorCollection.isEnabled; |
| 80 }, | 115 }, |
| 81 | 116 |
| 82 /** @private */ | 117 /** @private */ |
| 83 onOptionsButtonTap_: function() { | 118 onEnableChange_: function() { |
| 119 this.delegate.setItemEnabled(this.data.id, | |
| 120 this.$['enable-toggle'].checked); | |
| 121 }, | |
| 122 | |
| 123 /** | |
| 124 * @param {!{model: !{item: !chrome.developerPrivate.ExtensionView}}} e | |
| 125 * @private | |
| 126 */ | |
| 127 onInspectTap_: function(e) { | |
| 128 this.delegate.inspectItemView(this.data.id, e.model.item); | |
| 129 }, | |
| 130 | |
| 131 /** @private */ | |
| 132 onOptionsTap_: function() { | |
| 84 this.delegate.showItemOptionsPage(this.data.id); | 133 this.delegate.showItemOptionsPage(this.data.id); |
| 85 }, | 134 }, |
| 86 | 135 |
| 87 /** @private */ | 136 /** @private */ |
| 137 onRemoveTap_: function() { | |
| 138 this.delegate.deleteItem(this.data.id); | |
| 139 }, | |
| 140 | |
| 141 /** @private */ | |
| 88 onAllowIncognitoChange_: function() { | 142 onAllowIncognitoChange_: function() { |
| 89 this.delegate.setItemAllowedIncognito( | 143 this.delegate.setItemAllowedIncognito( |
| 90 this.data.id, this.$$('#allow-incognito').checked); | 144 this.data.id, this.$$('#allow-incognito').checked); |
| 91 }, | 145 }, |
| 92 | 146 |
| 93 /** @private */ | 147 /** @private */ |
| 94 onAllowOnFileUrlsChange_: function() { | 148 onAllowOnFileUrlsChange_: function() { |
| 95 this.delegate.setItemAllowedOnFileUrls( | 149 this.delegate.setItemAllowedOnFileUrls( |
| 96 this.data.id, this.$$('#allow-on-file-urls').checked); | 150 this.data.id, this.$$('#allow-on-file-urls').checked); |
| 97 }, | 151 }, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 118 | 172 |
| 119 /** @private */ | 173 /** @private */ |
| 120 computeSourceString_: function() { | 174 computeSourceString_: function() { |
| 121 return extensions.getItemSourceString( | 175 return extensions.getItemSourceString( |
| 122 extensions.getItemSource(this.data)); | 176 extensions.getItemSource(this.data)); |
| 123 } | 177 } |
| 124 }); | 178 }); |
| 125 | 179 |
| 126 return {DetailView: DetailView}; | 180 return {DetailView: DetailView}; |
| 127 }); | 181 }); |
| OLD | NEW |