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 * The type of the extension data object. The definition is based on | 8 * The type of the extension data object. The definition is based on |
9 * chrome/browser/ui/webui/extensions/extension_basic_info.cc | 9 * chrome/browser/ui/webui/extensions/extension_basic_info.cc |
10 * and | 10 * and |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 * version: string, | 58 * version: string, |
59 * views: Array<{renderViewId: number, renderProcessId: number, | 59 * views: Array<{renderViewId: number, renderProcessId: number, |
60 * path: string, incognito: boolean, | 60 * path: string, incognito: boolean, |
61 * generatedBackgroundPage: boolean}>, | 61 * generatedBackgroundPage: boolean}>, |
62 * wantsErrorCollection: boolean, | 62 * wantsErrorCollection: boolean, |
63 * wantsFileAccess: boolean, | 63 * wantsFileAccess: boolean, |
64 * warnings: (Array|undefined)}} | 64 * warnings: (Array|undefined)}} |
65 */ | 65 */ |
66 var ExtensionData; | 66 var ExtensionData; |
67 | 67 |
68 cr.define('options', function() { | 68 cr.define('extensions', function() { |
69 'use strict'; | 69 'use strict'; |
70 | 70 |
71 /** | 71 /** |
72 * Creates a new list of extensions. | 72 * Creates a new list of extensions. |
73 * @param {Object=} opt_propertyBag Optional properties. | 73 * @param {Object=} opt_propertyBag Optional properties. |
74 * @constructor | 74 * @constructor |
75 * @extends {HTMLDivElement} | 75 * @extends {HTMLDivElement} |
76 */ | 76 */ |
77 var ExtensionsList = cr.ui.define('div'); | 77 var ExtensionList = cr.ui.define('div'); |
78 | 78 |
79 /** | 79 /** |
80 * @type {Object<string, number>} A map from extension id to last reloaded | 80 * @type {Object<string, number>} A map from extension id to last reloaded |
81 * timestamp. The timestamp is recorded when the user click the 'Reload' | 81 * timestamp. The timestamp is recorded when the user click the 'Reload' |
82 * link. It is used to refresh the icon of an unpacked extension. | 82 * link. It is used to refresh the icon of an unpacked extension. |
83 * This persists between calls to decorate. | 83 * This persists between calls to decorate. |
84 */ | 84 */ |
85 var extensionReloadedTimestamp = {}; | 85 var extensionReloadedTimestamp = {}; |
86 | 86 |
87 ExtensionsList.prototype = { | 87 ExtensionList.prototype = { |
88 __proto__: HTMLDivElement.prototype, | 88 __proto__: HTMLDivElement.prototype, |
89 | 89 |
90 /** | 90 /** |
91 * Indicates whether an embedded options page that was navigated to through | 91 * Indicates whether an embedded options page that was navigated to through |
92 * the '?options=' URL query has been shown to the user. This is necessary | 92 * the '?options=' URL query has been shown to the user. This is necessary |
93 * to prevent showExtensionNodes_ from opening the options more than once. | 93 * to prevent showExtensionNodes_ from opening the options more than once. |
94 * @type {boolean} | 94 * @type {boolean} |
95 * @private | 95 * @private |
96 */ | 96 */ |
97 optionsShown_: false, | 97 optionsShown_: false, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 // disabled, because the user might e.g. get prompted when enabling | 279 // disabled, because the user might e.g. get prompted when enabling |
280 // and choose not to. | 280 // and choose not to. |
281 e.preventDefault(); | 281 e.preventDefault(); |
282 }); | 282 }); |
283 | 283 |
284 // 'Remove' button. | 284 // 'Remove' button. |
285 var trashTemplate = $('template-collection').querySelector('.trash'); | 285 var trashTemplate = $('template-collection').querySelector('.trash'); |
286 var trash = trashTemplate.cloneNode(true); | 286 var trash = trashTemplate.cloneNode(true); |
287 trash.title = loadTimeData.getString('extensionUninstall'); | 287 trash.title = loadTimeData.getString('extensionUninstall'); |
288 trash.addEventListener('click', function(e) { | 288 trash.addEventListener('click', function(e) { |
289 trash.classList.add('open'); | |
290 trash.classList.toggle('mouse-clicked', e.detail > 0); | |
289 chrome.send('extensionSettingsUninstall', [extension.id]); | 291 chrome.send('extensionSettingsUninstall', [extension.id]); |
290 }); | 292 }); |
291 node.querySelector('.enable-controls').appendChild(trash); | 293 node.querySelector('.enable-controls').appendChild(trash); |
292 | 294 |
293 // Developer mode //////////////////////////////////////////////////////// | 295 // Developer mode //////////////////////////////////////////////////////// |
294 | 296 |
295 // The path, if provided by unpacked extension. | 297 // The path, if provided by unpacked extension. |
296 this.addListener_('click', node, '.load-path a:first-of-type', | 298 this.addListener_('click', node, '.load-path a:first-of-type', |
297 function(e) { | 299 function(e) { |
298 chrome.send('extensionSettingsShowPath', [String(extension.id)]); | 300 chrome.send('extensionSettingsShowPath', [String(extension.id)]); |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
694 self.optionsShown_ = false; | 696 self.optionsShown_ = false; |
695 $('overlay').removeEventListener('cancelOverlay', f); | 697 $('overlay').removeEventListener('cancelOverlay', f); |
696 }); | 698 }); |
697 | 699 |
698 // TODO(dbeam): why do we need to focus <extensionoptions> before and | 700 // TODO(dbeam): why do we need to focus <extensionoptions> before and |
699 // after its showing animation? Makes very little sense to me. | 701 // after its showing animation? Makes very little sense to me. |
700 overlay.setInitialFocus(); | 702 overlay.setInitialFocus(); |
701 }, | 703 }, |
702 }; | 704 }; |
703 | 705 |
706 ExtensionList.uninstallCancel = function() { | |
707 var trash = document.querySelector('.trash.open'); | |
708 if (trash.classList.contains('mouse-clicked')) | |
Evan Stade
2015/02/26 02:49:19
seems like this can crash if .trash.open is not fo
Dan Beam
2015/02/26 03:02:42
i think that'd be unexpected and therefore should
| |
709 trash.blur(); | |
710 trash.classList.remove('open'); | |
711 }; | |
712 | |
704 return { | 713 return { |
705 ExtensionsList: ExtensionsList | 714 ExtensionList: ExtensionList |
706 }; | 715 }; |
707 }); | 716 }); |
OLD | NEW |