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 /** |
| 8 * The type of the extension data object. The definition is based on |
| 9 * chrome/browser/ui/webui/extensions/extension_basic_info.cc |
| 10 * and |
| 11 * chrome/browser/ui/webui/extensions/extension_settings_handler.cc |
| 12 * ExtensionSettingsHandler::CreateExtensionDetailValue() |
| 13 * @typedef {{allow_reload: boolean, |
| 14 * allowAllUrls: boolean, |
| 15 * allowFileAccess: boolean, |
| 16 * blacklistText: string, |
| 17 * corruptInstall: boolean, |
| 18 * dependentExtensions: Array, |
| 19 * description: string, |
| 20 * detailsUrl: string, |
| 21 * enable_show_button: boolean, |
| 22 * enabled: boolean, |
| 23 * enabledIncognito: boolean, |
| 24 * errorCollectionEnabled: (boolean|undefined), |
| 25 * hasPopupAction: boolean, |
| 26 * homepageProvided: boolean, |
| 27 * homepageUrl: string, |
| 28 * icon: string, |
| 29 * id: string, |
| 30 * incognitoCanBeEnabled: boolean, |
| 31 * installWarnings: (Array|undefined), |
| 32 * is_hosted_app: boolean, |
| 33 * is_platform_app: boolean, |
| 34 * isUnpacked: boolean, |
| 35 * kioskEnabled: boolean, |
| 36 * kioskOnly: boolean, |
| 37 * locationText: string, |
| 38 * managedInstall: boolean, |
| 39 * manifestErrors: (Array.<BackendExtensionErrorObject>|undefined), |
| 40 * name: string, |
| 41 * offlineEnabled: boolean, |
| 42 * optionsUrl: string, |
| 43 * order: number, |
| 44 * packagedApp: boolean, |
| 45 * path: (string|undefined), |
| 46 * prettifiedPath: (string|undefined), |
| 47 * runtimeErrors: (Array.<BackendExtensionErrorObject>|undefined), |
| 48 * suspiciousInstall: boolean, |
| 49 * terminated: boolean, |
| 50 * version: string, |
| 51 * views: Array.<{renderViewId: number, renderProcessId: number, |
| 52 * path: string, incognito: boolean, |
| 53 * generatedBackgroundPage: boolean}>, |
| 54 * wantsAllUrls: boolean, |
| 55 * wantsErrorCollection: boolean, |
| 56 * wantsFileAccess: boolean, |
| 57 * warnings: (Array|undefined)}} |
| 58 */ |
| 59 var ExtensionData; |
| 60 |
7 cr.define('options', function() { | 61 cr.define('options', function() { |
8 'use strict'; | 62 'use strict'; |
9 | 63 |
10 /** | 64 /** |
11 * Creates a new list of extensions. | 65 * Creates a new list of extensions. |
12 * @param {Object=} opt_propertyBag Optional properties. | 66 * @param {Object=} opt_propertyBag Optional properties. |
13 * @constructor | 67 * @constructor |
14 * @extends {cr.ui.div} | 68 * @extends {HTMLDivElement} |
15 */ | 69 */ |
16 var ExtensionsList = cr.ui.define('div'); | 70 var ExtensionsList = cr.ui.define('div'); |
17 | 71 |
18 /** | 72 /** |
19 * @type {Object.<string, boolean>} A map from extension id to a boolean | 73 * @type {Object.<string, boolean>} A map from extension id to a boolean |
20 * indicating whether the incognito warning is showing. This persists | 74 * indicating whether the incognito warning is showing. This persists |
21 * between calls to decorate. | 75 * between calls to decorate. |
22 */ | 76 */ |
23 var butterBarVisibility = {}; | 77 var butterBarVisibility = {}; |
24 | 78 |
25 /** | 79 /** |
26 * @type {Object.<string, string>} A map from extension id to last reloaded | 80 * @type {Object.<string, number>} A map from extension id to last reloaded |
27 * timestamp. The timestamp is recorded when the user click the 'Reload' | 81 * timestamp. The timestamp is recorded when the user click the 'Reload' |
28 * 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. |
29 * This persists between calls to decorate. | 83 * This persists between calls to decorate. |
30 */ | 84 */ |
31 var extensionReloadedTimestamp = {}; | 85 var extensionReloadedTimestamp = {}; |
32 | 86 |
33 ExtensionsList.prototype = { | 87 ExtensionsList.prototype = { |
34 __proto__: HTMLDivElement.prototype, | 88 __proto__: HTMLDivElement.prototype, |
35 | 89 |
36 /** @override */ | 90 /** @override */ |
(...skipping 29 matching lines...) Expand all Loading... |
66 | 120 |
67 if (this.data_.extensions.length == 0) | 121 if (this.data_.extensions.length == 0) |
68 this.classList.add('empty-extension-list'); | 122 this.classList.add('empty-extension-list'); |
69 else | 123 else |
70 this.classList.remove('empty-extension-list'); | 124 this.classList.remove('empty-extension-list'); |
71 }, | 125 }, |
72 | 126 |
73 /** | 127 /** |
74 * Synthesizes and initializes an HTML element for the extension metadata | 128 * Synthesizes and initializes an HTML element for the extension metadata |
75 * given in |extension|. | 129 * given in |extension|. |
76 * @param {Object} extension A dictionary of extension metadata. | 130 * @param {ExtensionData} extension A dictionary of extension metadata. |
77 * @private | 131 * @private |
78 */ | 132 */ |
79 createNode_: function(extension) { | 133 createNode_: function(extension) { |
80 var template = $('template-collection').querySelector( | 134 var template = $('template-collection').querySelector( |
81 '.extension-list-item-wrapper'); | 135 '.extension-list-item-wrapper'); |
82 var node = template.cloneNode(true); | 136 var node = template.cloneNode(true); |
83 node.id = extension.id; | 137 node.id = extension.id; |
84 | 138 |
85 if (!extension.enabled || extension.terminated) | 139 if (!extension.enabled || extension.terminated) |
86 node.classList.add('inactive-extension'); | 140 node.classList.add('inactive-extension'); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 li.innerText = warning.message; | 456 li.innerText = warning.message; |
403 list.appendChild(li); | 457 list.appendChild(li); |
404 }); | 458 }); |
405 } | 459 } |
406 | 460 |
407 this.appendChild(node); | 461 this.appendChild(node); |
408 if (location.hash.substr(1) == extension.id) { | 462 if (location.hash.substr(1) == extension.id) { |
409 // Scroll beneath the fixed header so that the extension is not | 463 // Scroll beneath the fixed header so that the extension is not |
410 // obscured. | 464 // obscured. |
411 var topScroll = node.offsetTop - $('page-header').offsetHeight; | 465 var topScroll = node.offsetTop - $('page-header').offsetHeight; |
412 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); | 466 var pad = parseInt(window.getComputedStyle(node, null).marginTop, 10); |
413 if (!isNaN(pad)) | 467 if (!isNaN(pad)) |
414 topScroll -= pad / 2; | 468 topScroll -= pad / 2; |
415 setScrollTopForDocument(document, topScroll); | 469 setScrollTopForDocument(document, topScroll); |
416 } | 470 } |
417 }, | 471 }, |
418 }; | 472 }; |
419 | 473 |
420 return { | 474 return { |
421 ExtensionsList: ExtensionsList | 475 ExtensionsList: ExtensionsList |
422 }; | 476 }; |
423 }); | 477 }); |
OLD | NEW |