| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 onReloadTap_: function() { | 150 onReloadTap_: function() { |
| 151 this.delegate.reloadItem(this.data.id); | 151 this.delegate.reloadItem(this.data.id); |
| 152 }, | 152 }, |
| 153 | 153 |
| 154 /** @private */ | 154 /** @private */ |
| 155 onRepairTap_: function() { | 155 onRepairTap_: function() { |
| 156 this.delegate.repairItem(this.data.id); | 156 this.delegate.repairItem(this.data.id); |
| 157 }, | 157 }, |
| 158 | 158 |
| 159 /** | 159 /** |
| 160 * Returns true if the extension is enabled, including terminated | |
| 161 * extensions. | |
| 162 * @return {boolean} | 160 * @return {boolean} |
| 163 * @private | 161 * @private |
| 164 */ | 162 */ |
| 165 isEnabled_: function() { | 163 isEnabled_: function() { return extensions.isEnabled(this.data.state); }, |
| 166 switch (this.data.state) { | 164 |
| 167 case chrome.developerPrivate.ExtensionState.ENABLED: | 165 /** |
| 168 case chrome.developerPrivate.ExtensionState.TERMINATED: | 166 * @return {boolean} |
| 169 return true; | 167 * @private |
| 170 case chrome.developerPrivate.ExtensionState.DISABLED: | 168 */ |
| 171 return false; | 169 isEnableToggleEnabled_: function() { |
| 172 } | 170 return extensions.userCanChangeEnablement(this.data); |
| 173 assertNotReached(); // FileNotFound. | |
| 174 }, | 171 }, |
| 175 | 172 |
| 176 /** | 173 /** |
| 177 * Returns true if the enable toggle should be shown. | 174 * Returns true if the enable toggle should be shown. |
| 178 * @return {boolean} | 175 * @return {boolean} |
| 179 * @private | 176 * @private |
| 180 */ | 177 */ |
| 181 showEnableToggle_: function() { | 178 showEnableToggle_: function() { |
| 182 return !this.isTerminated_() && !this.data.disableReasons.corruptInstall; | 179 return !this.isTerminated_() && !this.data.disableReasons.corruptInstall; |
| 183 }, | 180 }, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 */ | 234 */ |
| 238 computeInspectViewsHidden_: function() { | 235 computeInspectViewsHidden_: function() { |
| 239 return !this.data.views || this.data.views.length == 0; | 236 return !this.data.views || this.data.views.length == 0; |
| 240 }, | 237 }, |
| 241 | 238 |
| 242 /** | 239 /** |
| 243 * @return {string} | 240 * @return {string} |
| 244 * @private | 241 * @private |
| 245 */ | 242 */ |
| 246 computeFirstInspectLabel_: function() { | 243 computeFirstInspectLabel_: function() { |
| 247 var view = this.data.views[0]; | 244 // Note: theoretically, this wouldn't be called without any inspectable |
| 248 // Trim the "chrome-extension://<id>/". | 245 // views (because it's in a dom-if="!computeInspectViewsHidden_()"). |
| 249 var url = new URL(view.url); | 246 // However, due to the recycling behavior of iron list, it seems that |
| 250 var label = view.url; | 247 // sometimes it can. Even when it is, the UI behaves properly, but we |
| 251 if (url.protocol == 'chrome-extension:') | 248 // need to handle the case gracefully. |
| 252 label = url.pathname.substring(1); | 249 if (this.data.views.length == 0) |
| 253 if (label == '_generated_background_page.html') | 250 return ''; |
| 254 label = this.i18n('viewBackgroundPage'); | 251 var label = extensions.computeInspectableViewLabel(this.data.views[0]); |
| 255 // Add any qualifiers. | 252 if (this.data.views.length > 1) |
| 256 label += (view.incognito ? ' ' + this.i18n('viewIncognito') : '') + | |
| 257 (view.renderProcessId == -1 ? | |
| 258 ' ' + this.i18n('viewInactive') : '') + | |
| 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 += ','; | 253 label += ','; |
| 264 return label; | 254 return label; |
| 265 }, | 255 }, |
| 266 | 256 |
| 267 /** | 257 /** |
| 268 * @return {boolean} | 258 * @return {boolean} |
| 269 * @private | 259 * @private |
| 270 */ | 260 */ |
| 271 computeExtraViewsHidden_: function() { | 261 computeExtraViewsHidden_: function() { |
| 272 return this.data.views.length <= 1; | 262 return this.data.views.length <= 1; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 299 return this.data.blacklistText ? 'severe' : 'mild'; | 289 return this.data.blacklistText ? 'severe' : 'mild'; |
| 300 }, | 290 }, |
| 301 }); | 291 }); |
| 302 | 292 |
| 303 return { | 293 return { |
| 304 Item: Item, | 294 Item: Item, |
| 305 ItemDelegate: ItemDelegate, | 295 ItemDelegate: ItemDelegate, |
| 306 }; | 296 }; |
| 307 }); | 297 }); |
| 308 | 298 |
| OLD | NEW |