| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @interface */ | 6 /** @interface */ |
| 7 var ItemDelegate = function() {}; | 7 var ItemDelegate = function() {}; |
| 8 | 8 |
| 9 ItemDelegate.prototype = { | 9 ItemDelegate.prototype = { |
| 10 /** @param {string} id */ | 10 /** @param {string} id */ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 */ | 40 */ |
| 41 setItemCollectsErrors: assertNotReached, | 41 setItemCollectsErrors: assertNotReached, |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * @param {string} id | 44 * @param {string} id |
| 45 * @param {chrome.developerPrivate.ExtensionView} view | 45 * @param {chrome.developerPrivate.ExtensionView} view |
| 46 */ | 46 */ |
| 47 inspectItemView: assertNotReached, | 47 inspectItemView: assertNotReached, |
| 48 | 48 |
| 49 /** @param {string} id */ | 49 /** @param {string} id */ |
| 50 reloadItem: assertNotReached, |
| 51 |
| 52 /** @param {string} id */ |
| 50 repairItem: assertNotReached, | 53 repairItem: assertNotReached, |
| 51 | 54 |
| 52 /** @param {string} id */ | 55 /** @param {string} id */ |
| 53 showItemOptionsPage: assertNotReached, | 56 showItemOptionsPage: assertNotReached, |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 var Item = Polymer({ | 59 var Item = Polymer({ |
| 57 is: 'extensions-item', | 60 is: 'extensions-item', |
| 58 | 61 |
| 59 behaviors: [I18nBehavior], | 62 behaviors: [I18nBehavior], |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 /** @private */ | 131 /** @private */ |
| 129 onDetailsTap_: function() { | 132 onDetailsTap_: function() { |
| 130 this.fire('extension-item-show-details', {data: this.data}); | 133 this.fire('extension-item-show-details', {data: this.data}); |
| 131 }, | 134 }, |
| 132 | 135 |
| 133 /** | 136 /** |
| 134 * @param {!{model: !{item: !chrome.developerPrivate.ExtensionView}}} e | 137 * @param {!{model: !{item: !chrome.developerPrivate.ExtensionView}}} e |
| 135 * @private | 138 * @private |
| 136 */ | 139 */ |
| 137 onInspectTap_: function(e) { | 140 onInspectTap_: function(e) { |
| 138 this.delegate.inspectItemView(this.data.id, e.model.item); | 141 this.delegate.inspectItemView(this.data.id, this.data.views[0]); |
| 139 }, | 142 }, |
| 140 | 143 |
| 141 /** @private */ | 144 /** @private */ |
| 145 onExtraInspectTap_: function() { |
| 146 this.fire('extension-item-show-details', {data: this.data}); |
| 147 }, |
| 148 |
| 149 /** @private */ |
| 150 onReloadTap_: function() { |
| 151 this.delegate.reloadItem(this.data.id); |
| 152 }, |
| 153 |
| 154 /** @private */ |
| 142 onRepairTap_: function() { | 155 onRepairTap_: function() { |
| 143 this.delegate.repairItem(this.data.id); | 156 this.delegate.repairItem(this.data.id); |
| 144 }, | 157 }, |
| 145 | 158 |
| 146 /** | 159 /** |
| 147 * Returns true if the extension is enabled, including terminated | 160 * Returns true if the extension is enabled, including terminated |
| 148 * extensions. | 161 * extensions. |
| 149 * @return {boolean} | 162 * @return {boolean} |
| 150 * @private | 163 * @private |
| 151 */ | 164 */ |
| 152 isEnabled_: function() { | 165 isEnabled_: function() { |
| 153 switch (this.data.state) { | 166 switch (this.data.state) { |
| 154 case chrome.developerPrivate.ExtensionState.ENABLED: | 167 case chrome.developerPrivate.ExtensionState.ENABLED: |
| 155 case chrome.developerPrivate.ExtensionState.TERMINATED: | 168 case chrome.developerPrivate.ExtensionState.TERMINATED: |
| 156 return true; | 169 return true; |
| 157 case chrome.developerPrivate.ExtensionState.DISABLED: | 170 case chrome.developerPrivate.ExtensionState.DISABLED: |
| 158 return false; | 171 return false; |
| 159 } | 172 } |
| 160 assertNotReached(); // FileNotFound. | 173 assertNotReached(); // FileNotFound. |
| 161 }, | 174 }, |
| 162 | 175 |
| 163 /** @private */ | 176 /** |
| 164 computeClasses_: function() { | 177 * Returns true if the enable toggle should be shown. |
| 165 return this.isEnabled_() ? 'enabled' : 'disabled'; | 178 * @return {boolean} |
| 179 * @private |
| 180 */ |
| 181 showEnableToggle_: function() { |
| 182 return !this.isTerminated_() && !this.data.disableReasons.corruptInstall; |
| 166 }, | 183 }, |
| 167 | 184 |
| 168 /** | 185 /** |
| 186 * Returns true if the extension is in the terminated state. |
| 187 * @return {boolean} |
| 188 * @private |
| 189 */ |
| 190 isTerminated_: function() { |
| 191 return this.data.state == |
| 192 chrome.developerPrivate.ExtensionState.TERMINATED; |
| 193 }, |
| 194 |
| 195 /** |
| 196 * return {string} |
| 197 * @private |
| 198 */ |
| 199 computeClasses_: function() { |
| 200 var classes = this.isEnabled_() ? 'enabled' : 'disabled'; |
| 201 if (this.inDevMode) |
| 202 classes += ' dev-mode'; |
| 203 return classes; |
| 204 }, |
| 205 |
| 206 /** |
| 169 * @return {string} | 207 * @return {string} |
| 170 * @private | 208 * @private |
| 171 */ | 209 */ |
| 172 computeSourceIndicatorIcon_: function() { | 210 computeSourceIndicatorIcon_: function() { |
| 173 switch (extensions.getItemSource(this.data)) { | 211 switch (extensions.getItemSource(this.data)) { |
| 174 case SourceType.POLICY: | 212 case SourceType.POLICY: |
| 175 return 'communication:business'; | 213 return 'communication:business'; |
| 176 case SourceType.SIDELOADED: | 214 case SourceType.SIDELOADED: |
| 177 return 'input'; | 215 return 'input'; |
| 178 case SourceType.UNPACKED: | 216 case SourceType.UNPACKED: |
| 179 return 'extensions-icons:unpacked'; | 217 return 'extensions-icons:unpacked'; |
| 180 case SourceType.WEBSTORE: | 218 case SourceType.WEBSTORE: |
| 181 return ''; | 219 return ''; |
| 182 } | 220 } |
| 183 assertNotReached(); | 221 assertNotReached(); |
| 184 }, | 222 }, |
| 185 | 223 |
| 186 /** | 224 /** |
| 187 * @return {string} | 225 * @return {string} |
| 188 * @private | 226 * @private |
| 189 */ | 227 */ |
| 190 computeSourceIndicatorText_: function() { | 228 computeSourceIndicatorText_: function() { |
| 191 var sourceType = extensions.getItemSource(this.data); | 229 var sourceType = extensions.getItemSource(this.data); |
| 192 return sourceType == SourceType.WEBSTORE ? '' : | 230 return sourceType == SourceType.WEBSTORE ? '' : |
| 193 extensions.getItemSourceString(sourceType); | 231 extensions.getItemSourceString(sourceType); |
| 194 }, | 232 }, |
| 195 | 233 |
| 196 /** | 234 /** |
| 197 * @param {chrome.developerPrivate.ExtensionView} view | 235 * @return {boolean} |
| 198 * @private | 236 * @private |
| 199 */ | 237 */ |
| 200 computeInspectLabel_: function(view) { | 238 computeInspectViewsHidden_: function() { |
| 239 return !this.data.views || this.data.views.length == 0; |
| 240 }, |
| 241 |
| 242 /** |
| 243 * @return {string} |
| 244 * @private |
| 245 */ |
| 246 computeFirstInspectLabel_: function() { |
| 247 var view = this.data.views[0]; |
| 201 // Trim the "chrome-extension://<id>/". | 248 // Trim the "chrome-extension://<id>/". |
| 202 var url = new URL(view.url); | 249 var url = new URL(view.url); |
| 203 var label = view.url; | 250 var label = view.url; |
| 204 if (url.protocol == 'chrome-extension:') | 251 if (url.protocol == 'chrome-extension:') |
| 205 label = url.pathname.substring(1); | 252 label = url.pathname.substring(1); |
| 206 if (label == '_generated_background_page.html') | 253 if (label == '_generated_background_page.html') |
| 207 label = this.i18n('viewBackgroundPage'); | 254 label = this.i18n('viewBackgroundPage'); |
| 208 // Add any qualifiers. | 255 // Add any qualifiers. |
| 209 label += (view.incognito ? ' ' + this.i18n('viewIncognito') : '') + | 256 label += (view.incognito ? ' ' + this.i18n('viewIncognito') : '') + |
| 210 (view.renderProcessId == -1 ? | 257 (view.renderProcessId == -1 ? |
| 211 ' ' + this.i18n('viewInactive') : '') + | 258 ' ' + this.i18n('viewInactive') : '') + |
| 212 (view.isIframe ? ' ' + this.i18n('viewIframe') : ''); | 259 (view.isIframe ? ' ' + this.i18n('viewIframe') : ''); |
| 260 var index = this.data.views.indexOf(view); |
| 261 assert(index >= 0); |
| 262 if (index < this.data.views.length - 1) |
| 263 label += ','; |
| 213 return label; | 264 return label; |
| 214 }, | 265 }, |
| 215 | 266 |
| 216 /** | 267 /** |
| 217 * @return {boolean} | 268 * @return {boolean} |
| 218 * @private | 269 * @private |
| 219 */ | 270 */ |
| 271 computeExtraViewsHidden_: function() { |
| 272 return this.data.views.length <= 1; |
| 273 }, |
| 274 |
| 275 /** |
| 276 * @return {string} |
| 277 * @private |
| 278 */ |
| 279 computeExtraInspectLabel_: function() { |
| 280 return loadTimeData.getStringF('itemInspectViewsExtra', |
| 281 this.data.views.length - 1); |
| 282 }, |
| 283 |
| 284 /** |
| 285 * @return {boolean} |
| 286 * @private |
| 287 */ |
| 220 hasWarnings_: function() { | 288 hasWarnings_: function() { |
| 221 return this.data.disableReasons.corruptInstall || | 289 return this.data.disableReasons.corruptInstall || |
| 222 this.data.disableReasons.suspiciousInstall || | 290 this.data.disableReasons.suspiciousInstall || |
| 223 !!this.data.blacklistText; | 291 !!this.data.blacklistText; |
| 224 }, | 292 }, |
| 225 | 293 |
| 226 /** | 294 /** |
| 227 * @return {string} | 295 * @return {string} |
| 228 * @private | 296 * @private |
| 229 */ | 297 */ |
| 230 computeWarningsClasses_: function() { | 298 computeWarningsClasses_: function() { |
| 231 return this.data.blacklistText ? 'severe' : 'mild'; | 299 return this.data.blacklistText ? 'severe' : 'mild'; |
| 232 }, | 300 }, |
| 233 }); | 301 }); |
| 234 | 302 |
| 235 return { | 303 return { |
| 236 Item: Item, | 304 Item: Item, |
| 237 ItemDelegate: ItemDelegate, | 305 ItemDelegate: ItemDelegate, |
| 238 }; | 306 }; |
| 239 }); | 307 }); |
| 240 | 308 |
| OLD | NEW |