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