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