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 BackendExtensionDataObject; | |
Dan Beam
2014/08/21 18:27:48
ExtensionData or ExtensionInfo
Vitaly Pavlenko
2014/08/22 01:43:40
Done.
| |
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 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 {BackendExtensionDataObject} extension A dictionary of extension |
131 * metadata. | |
77 * @private | 132 * @private |
78 */ | 133 */ |
79 createNode_: function(extension) { | 134 createNode_: function(extension) { |
80 var template = $('template-collection').querySelector( | 135 var template = $('template-collection').querySelector( |
81 '.extension-list-item-wrapper'); | 136 '.extension-list-item-wrapper'); |
82 var node = template.cloneNode(true); | 137 var node = template.cloneNode(true); |
83 node.id = extension.id; | 138 node.id = extension.id; |
84 | 139 |
85 if (!extension.enabled || extension.terminated) | 140 if (!extension.enabled || extension.terminated) |
86 node.classList.add('inactive-extension'); | 141 node.classList.add('inactive-extension'); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 extension.homepageProvided ? 'extensionSettingsVisitWebsite' : | 269 extension.homepageProvided ? 'extensionSettingsVisitWebsite' : |
215 'extensionSettingsVisitWebStore'); | 270 'extensionSettingsVisitWebStore'); |
216 siteLink.hidden = false; | 271 siteLink.hidden = false; |
217 } | 272 } |
218 | 273 |
219 if (extension.allow_reload) { | 274 if (extension.allow_reload) { |
220 // The 'Reload' link. | 275 // The 'Reload' link. |
221 var reload = node.querySelector('.reload-link'); | 276 var reload = node.querySelector('.reload-link'); |
222 reload.addEventListener('click', function(e) { | 277 reload.addEventListener('click', function(e) { |
223 chrome.send('extensionSettingsReload', [extension.id]); | 278 chrome.send('extensionSettingsReload', [extension.id]); |
224 extensionReloadedTimestamp[extension.id] = Date.now(); | 279 extensionReloadedTimestamp[extension.id] = String(Date.now()); |
Dan Beam
2014/08/21 18:27:47
why do you need this?
Vitaly Pavlenko
2014/08/22 01:43:40
Don't need actually, removed. I also fixed the typ
Dan Beam
2014/08/22 21:57:13
i assume you mean the other way around
| |
225 }); | 280 }); |
226 reload.hidden = false; | 281 reload.hidden = false; |
227 | 282 |
228 if (extension.is_platform_app) { | 283 if (extension.is_platform_app) { |
229 // The 'Launch' link. | 284 // The 'Launch' link. |
230 var launch = node.querySelector('.launch-link'); | 285 var launch = node.querySelector('.launch-link'); |
231 launch.addEventListener('click', function(e) { | 286 launch.addEventListener('click', function(e) { |
232 chrome.send('extensionSettingsLaunch', [extension.id]); | 287 chrome.send('extensionSettingsLaunch', [extension.id]); |
233 }); | 288 }); |
234 launch.hidden = false; | 289 launch.hidden = false; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 li.innerText = warning.message; | 452 li.innerText = warning.message; |
398 list.appendChild(li); | 453 list.appendChild(li); |
399 }); | 454 }); |
400 } | 455 } |
401 | 456 |
402 this.appendChild(node); | 457 this.appendChild(node); |
403 if (location.hash.substr(1) == extension.id) { | 458 if (location.hash.substr(1) == extension.id) { |
404 // Scroll beneath the fixed header so that the extension is not | 459 // Scroll beneath the fixed header so that the extension is not |
405 // obscured. | 460 // obscured. |
406 var topScroll = node.offsetTop - $('page-header').offsetHeight; | 461 var topScroll = node.offsetTop - $('page-header').offsetHeight; |
407 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); | 462 var pad = parseInt(window.getComputedStyle(node, null).marginTop, 10); |
408 if (!isNaN(pad)) | 463 if (!isNaN(pad)) |
409 topScroll -= pad / 2; | 464 topScroll -= pad / 2; |
410 setScrollTopForDocument(document, topScroll); | 465 setScrollTopForDocument(document, topScroll); |
411 } | 466 } |
412 }, | 467 }, |
413 }; | 468 }; |
414 | 469 |
415 return { | 470 return { |
416 ExtensionsList: ExtensionsList | 471 ExtensionsList: ExtensionsList |
417 }; | 472 }; |
418 }); | 473 }); |
OLD | NEW |