Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: chrome/browser/resources/extensions/extension_list.js

Issue 512003002: Revert of Revert "Typecheck JS files for chrome://extensions" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.<RuntimeError>|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.<RuntimeError>|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 /** 90 /**
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // above the element being scrolled to. 145 // above the element being scrolled to.
92 var scrollFudge = 1.2; 146 var scrollFudge = 1.2;
93 var scrollTop = $(extensionId).offsetTop - scrollFudge * 147 var scrollTop = $(extensionId).offsetTop - scrollFudge *
94 $(extensionId).clientHeight; 148 $(extensionId).clientHeight;
95 setScrollTopForDocument(document, scrollTop); 149 setScrollTopForDocument(document, scrollTop);
96 }, 150 },
97 151
98 /** 152 /**
99 * Synthesizes and initializes an HTML element for the extension metadata 153 * Synthesizes and initializes an HTML element for the extension metadata
100 * given in |extension|. 154 * given in |extension|.
101 * @param {Object} extension A dictionary of extension metadata. 155 * @param {ExtensionData} extension A dictionary of extension metadata.
102 * @private 156 * @private
103 */ 157 */
104 createNode_: function(extension) { 158 createNode_: function(extension) {
105 var template = $('template-collection').querySelector( 159 var template = $('template-collection').querySelector(
106 '.extension-list-item-wrapper'); 160 '.extension-list-item-wrapper');
107 var node = template.cloneNode(true); 161 var node = template.cloneNode(true);
108 node.id = extension.id; 162 node.id = extension.id;
109 163
110 if (!extension.enabled || extension.terminated) 164 if (!extension.enabled || extension.terminated)
111 node.classList.add('inactive-extension'); 165 node.classList.add('inactive-extension');
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 li.innerText = warning.message; 480 li.innerText = warning.message;
427 list.appendChild(li); 481 list.appendChild(li);
428 }); 482 });
429 } 483 }
430 484
431 this.appendChild(node); 485 this.appendChild(node);
432 if (location.hash.substr(1) == extension.id) { 486 if (location.hash.substr(1) == extension.id) {
433 // Scroll beneath the fixed header so that the extension is not 487 // Scroll beneath the fixed header so that the extension is not
434 // obscured. 488 // obscured.
435 var topScroll = node.offsetTop - $('page-header').offsetHeight; 489 var topScroll = node.offsetTop - $('page-header').offsetHeight;
436 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); 490 var pad = parseInt(window.getComputedStyle(node, null).marginTop, 10);
437 if (!isNaN(pad)) 491 if (!isNaN(pad))
438 topScroll -= pad / 2; 492 topScroll -= pad / 2;
439 setScrollTopForDocument(document, topScroll); 493 setScrollTopForDocument(document, topScroll);
440 } 494 }
441 }, 495 },
442 496
443 /** 497 /**
444 * Opens the extension options overlay for the extension with the given id. 498 * Opens the extension options overlay for the extension with the given id.
445 * @param {string} extensionId The id of extension whose options page should 499 * @param {string} extensionId The id of extension whose options page should
446 * be displayed. 500 * be displayed.
(...skipping 28 matching lines...) Expand all
475 $('overlay').addEventListener('cancelOverlay', function() { 529 $('overlay').addEventListener('cancelOverlay', function() {
476 this.optionsShown_ = false; 530 this.optionsShown_ = false;
477 }.bind(this)); 531 }.bind(this));
478 }, 532 },
479 }; 533 };
480 534
481 return { 535 return {
482 ExtensionsList: ExtensionsList 536 ExtensionsList: ExtensionsList
483 }; 537 };
484 }); 538 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698