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 assert(this.data.views.length > 0); |
248 // Trim the "chrome-extension://<id>/". | 245 var label = extensions.computeInspectableViewLabel(this.data.views[0]); |
249 var url = new URL(view.url); | 246 if (this.data.views.length > 1) |
250 var label = view.url; | |
251 if (url.protocol == 'chrome-extension:') | |
252 label = url.pathname.substring(1); | |
253 if (label == '_generated_background_page.html') | |
254 label = this.i18n('viewBackgroundPage'); | |
255 // Add any qualifiers. | |
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 += ','; | 247 label += ','; |
264 return label; | 248 return label; |
265 }, | 249 }, |
266 | 250 |
267 /** | 251 /** |
268 * @return {boolean} | 252 * @return {boolean} |
269 * @private | 253 * @private |
270 */ | 254 */ |
271 computeExtraViewsHidden_: function() { | 255 computeExtraViewsHidden_: function() { |
272 return this.data.views.length <= 1; | 256 return this.data.views.length <= 1; |
(...skipping 26 matching lines...) Expand all Loading... |
299 return this.data.blacklistText ? 'severe' : 'mild'; | 283 return this.data.blacklistText ? 'severe' : 'mild'; |
300 }, | 284 }, |
301 }); | 285 }); |
302 | 286 |
303 return { | 287 return { |
304 Item: Item, | 288 Item: Item, |
305 ItemDelegate: ItemDelegate, | 289 ItemDelegate: ItemDelegate, |
306 }; | 290 }; |
307 }); | 291 }); |
308 | 292 |
OLD | NEW |