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

Side by Side Diff: chrome/browser/resources/extensions/extension_error.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_overlay.js">
6
7 cr.define('extensions', function() { 5 cr.define('extensions', function() {
8 'use strict'; 6 'use strict';
9 7
10 /** 8 /**
11 * Clone a template within the extension error template collection. 9 * Clone a template within the extension error template collection.
12 * @param {string} templateName The class name of the template to clone. 10 * @param {string} templateName The class name of the template to clone.
13 * @return {HTMLElement} The clone of the template. 11 * @return {HTMLElement} The clone of the template.
14 */ 12 */
15 function cloneTemplate(templateName) { 13 function cloneTemplate(templateName) {
16 return $('template-collection-extension-error'). 14 return /** @type {HTMLElement} */($('template-collection-extension-error').
17 querySelector('.' + templateName).cloneNode(true); 15 querySelector('.' + templateName).cloneNode(true));
18 } 16 }
19 17
20 /** 18 /**
21 * Checks that an Extension ID follows the proper format (i.e., is 32 19 * Checks that an Extension ID follows the proper format (i.e., is 32
22 * characters long, is lowercase, and contains letters in the range [a, p]). 20 * characters long, is lowercase, and contains letters in the range [a, p]).
23 * @param {string} id The Extension ID to test. 21 * @param {string} id The Extension ID to test.
24 * @return {boolean} Whether or not the ID is valid. 22 * @return {boolean} Whether or not the ID is valid.
25 */ 23 */
26 function idIsValid(id) { 24 function idIsValid(id) {
27 return /^[a-p]{32}$/.test(id); 25 return /^[a-p]{32}$/.test(id);
28 } 26 }
29 27
30 /** 28 /**
31 * Creates a new ExtensionError HTMLElement; this is used to show a 29 * Creates a new ExtensionError HTMLElement; this is used to show a
32 * notification to the user when an error is caused by an extension. 30 * notification to the user when an error is caused by an extension.
33 * @param {Object} error The error the element should represent. 31 * @param {Object} error The error the element should represent.
34 * @constructor 32 * @constructor
35 * @extends {HTMLDivElement} 33 * @extends {HTMLDivElement}
36 */ 34 */
37 function ExtensionError(error) { 35 function ExtensionError(error) {
38 var div = cloneTemplate('extension-error-metadata'); 36 var div = cloneTemplate('extension-error-metadata');
39 div.__proto__ = ExtensionError.prototype; 37 div.__proto__ = ExtensionError.prototype;
40 div.decorate(error); 38 div.decorate(error);
41 return div; 39 return div;
42 } 40 }
43 41
44 ExtensionError.prototype = { 42 ExtensionError.prototype = {
45 __proto__: HTMLDivElement.prototype, 43 __proto__: HTMLDivElement.prototype,
46 44
47 /** @override */ 45 /**
46 * @param {RuntimeError} error
47 * @override
48 */
48 decorate: function(error) { 49 decorate: function(error) {
49 // Add an additional class for the severity level. 50 // Add an additional class for the severity level.
50 if (error.level == 0) 51 if (error.level == 0)
51 this.classList.add('extension-error-severity-info'); 52 this.classList.add('extension-error-severity-info');
52 else if (error.level == 1) 53 else if (error.level == 1)
53 this.classList.add('extension-error-severity-warning'); 54 this.classList.add('extension-error-severity-warning');
54 else 55 else
55 this.classList.add('extension-error-severity-fatal'); 56 this.classList.add('extension-error-severity-fatal');
56 57
57 var iconNode = document.createElement('img'); 58 var iconNode = document.createElement('img');
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 button.textContent = loadTimeData.getString(message); 147 button.textContent = loadTimeData.getString(message);
147 button.isShowingAll = !button.isShowingAll; 148 button.isShowingAll = !button.isShowingAll;
148 }.bind(this)); 149 }.bind(this));
149 } 150 }
150 }; 151 };
151 152
152 return { 153 return {
153 ExtensionErrorList: ExtensionErrorList 154 ExtensionErrorList: ExtensionErrorList
154 }; 155 };
155 }); 156 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698