OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 document.addEventListener('DOMContentLoaded', function() { | |
6 chrome.send('extensionLoaderDisplayFailures'); | |
7 }); | |
8 | |
9 window.addEventListener('beforeunload', function() { | |
Devlin
2014/06/30 21:06:42
Actually, I'm wondering if this wouldn't be better
gpdavis
2014/06/30 21:41:19
Will the ExtensionLoader be constructed after the
Devlin
2014/06/30 22:32:36
Well, since extensions are loaded on page load, we
gpdavis
2014/06/30 23:35:11
Wait, are you talking about the Extension Loader H
Devlin
2014/07/01 17:02:55
I was talking about the ExtensionLoader JS class.
gpdavis
2014/07/01 20:58:55
I replaced the DOMContentLoaded listener with a me
Devlin
2014/07/01 22:14:17
Can we not just unset it when the page is reloadin
gpdavis
2014/07/01 23:50:59
Well, that is the goal. I figured adding a listen
Devlin
2014/07/02 17:46:49
Can we not just listen for the same signal that Ex
| |
10 chrome.send('extensionLoaderSetDisplayLoading'); | |
11 }); | |
12 | |
5 cr.define('extensions', function() { | 13 cr.define('extensions', function() { |
6 'use strict'; | 14 'use strict'; |
7 | 15 |
8 /** | 16 /** |
9 * Construct an ExtensionLoadError around the given |div|. | 17 * Construct an ExtensionLoadError around the given |div|. |
10 * @param {HTMLDivElement} div The HTML div for the extension load error. | 18 * @param {HTMLDivElement} div The HTML div for the extension load error. |
11 * @constructor | 19 * @constructor |
12 */ | 20 */ |
13 function ExtensionLoadError(div) { | 21 function ExtensionLoadError(div) { |
14 div.__proto__ = ExtensionLoadError.prototype; | 22 div.__proto__ = ExtensionLoadError.prototype; |
(...skipping 16 matching lines...) Expand all Loading... | |
31 this.path_ = this.querySelector('#extension-load-error-path'); | 39 this.path_ = this.querySelector('#extension-load-error-path'); |
32 | 40 |
33 /** | 41 /** |
34 * The element which displays the reason the extension failed to load. | 42 * The element which displays the reason the extension failed to load. |
35 * @type {HTMLSpanElement} | 43 * @type {HTMLSpanElement} |
36 * @private | 44 * @private |
37 */ | 45 */ |
38 this.reason_ = this.querySelector('#extension-load-error-reason'); | 46 this.reason_ = this.querySelector('#extension-load-error-reason'); |
39 | 47 |
40 /** | 48 /** |
49 * The element which displays information about additional load failures. | |
50 * @type {HTMLPreElement} | |
51 * @private | |
52 */ | |
53 this.additional_ = | |
54 this.querySelector('#extension-load-error-additional'); | |
55 | |
56 /** | |
41 * The element which displays the manifest code. | 57 * The element which displays the manifest code. |
42 * @type {ExtensionCode} | 58 * @type {ExtensionCode} |
43 * @private | 59 * @private |
44 */ | 60 */ |
45 this.manifest_ = new extensions.ExtensionCode( | 61 this.manifest_ = new extensions.ExtensionCode( |
46 this.querySelector('#extension-load-error-manifest')); | 62 this.querySelector('#extension-load-error-manifest')); |
47 | 63 |
48 this.querySelector('#extension-load-error-retry-button').addEventListener( | 64 this.querySelector('#extension-load-error-retry-button').addEventListener( |
49 'click', function(e) { | 65 'click', function(e) { |
50 chrome.send('extensionLoaderRetry'); | 66 chrome.send('extensionLoaderRetry'); |
(...skipping 18 matching lines...) Expand all Loading... | |
69 | 85 |
70 manifest.message = reason; | 86 manifest.message = reason; |
71 this.manifest_.populate( | 87 this.manifest_.populate( |
72 manifest, | 88 manifest, |
73 loadTimeData.getString('extensionLoadCouldNotLoadManifest')); | 89 loadTimeData.getString('extensionLoadCouldNotLoadManifest')); |
74 this.hidden = false; | 90 this.hidden = false; |
75 this.manifest_.scrollToError(); | 91 this.manifest_.scrollToError(); |
76 }, | 92 }, |
77 | 93 |
78 /** | 94 /** |
95 * Display additional load failures to the user. | |
Devlin
2014/06/30 21:06:41
We should be able to clean this up when we move al
| |
96 * @param {string} failures The error message listing paths of additional | |
97 * extensions that failed to load. | |
98 */ | |
99 showAdditional: function(failures) { | |
100 this.additional_.textContent = failures; | |
101 }, | |
102 | |
103 /** | |
79 * Hide the extension load error. | 104 * Hide the extension load error. |
80 * @private | 105 * @private |
81 */ | 106 */ |
82 hide_: function() { | 107 hide_: function() { |
83 this.hidden = true; | 108 this.hidden = true; |
84 } | 109 } |
85 }; | 110 }; |
86 | 111 |
87 /** | 112 /** |
88 * The ExtensionLoader is the class in charge of loading unpacked extensions. | 113 * The ExtensionLoader is the class in charge of loading unpacked extensions. |
(...skipping 26 matching lines...) Expand all Loading... | |
115 * @param {string} filePath The path to the unpacked extension. | 140 * @param {string} filePath The path to the unpacked extension. |
116 * @param {string} reason The reason the extension failed to load. | 141 * @param {string} reason The reason the extension failed to load. |
117 * @param {Object} manifest An object with three strings: beforeHighlight, | 142 * @param {Object} manifest An object with three strings: beforeHighlight, |
118 * afterHighlight, and highlight. These represent three portions of the | 143 * afterHighlight, and highlight. These represent three portions of the |
119 * file's content to display - the portion which is most relevant and | 144 * file's content to display - the portion which is most relevant and |
120 * should be emphasized (highlight), and the parts both before and after | 145 * should be emphasized (highlight), and the parts both before and after |
121 * this portion. These may be empty. | 146 * this portion. These may be empty. |
122 */ | 147 */ |
123 notifyFailed: function(filePath, reason, manifest) { | 148 notifyFailed: function(filePath, reason, manifest) { |
124 this.loadError_.show(filePath, reason, manifest); | 149 this.loadError_.show(filePath, reason, manifest); |
150 }, | |
151 | |
152 /** | |
153 * Notify the ExtensionLoader of additional failures. | |
154 * @param {string} filePath The path to the unpacked extension. | |
155 * @param {string} failures The error message listing paths of additional | |
156 * extensions that failed to load. | |
157 */ | |
158 notifyAdditionalFailures: function(failures) { | |
159 this.loadError_.showAdditional(failures); | |
125 } | 160 } |
126 }; | 161 }; |
127 | 162 |
128 /* | 163 /* |
129 * A static forwarding function for ExtensionLoader.notifyFailed. | 164 * A static forwarding function for ExtensionLoader.notifyFailed. |
130 * @param {string} filePath The path to the unpacked extension. | 165 * @param {string} filePath The path to the unpacked extension. |
131 * @param {string} reason The reason the extension failed to load. | 166 * @param {string} reason The reason the extension failed to load. |
132 * @param {Object} manifest The manifest of the failed extension. | 167 * @param {Object} manifest The manifest of the failed extension. |
133 * @see ExtensionLoader.notifyFailed | 168 * @see ExtensionLoader.notifyFailed |
134 */ | 169 */ |
135 ExtensionLoader.notifyLoadFailed = function(filePath, reason, manifest) { | 170 ExtensionLoader.notifyLoadFailed = function(filePath, reason, manifest) { |
136 ExtensionLoader.getInstance().notifyFailed(filePath, reason, manifest); | 171 ExtensionLoader.getInstance().notifyFailed(filePath, reason, manifest); |
137 }; | 172 }; |
138 | 173 |
174 /* | |
175 * A static forwarding function for ExtensionLoader.notifyFailed. | |
176 * @param {string} failures The error message listing paths of additional | |
177 * extensions that failed to load. | |
178 * @see ExtensionLoader.notifyAdditionalFailures | |
179 */ | |
180 ExtensionLoader.notifyAdditional = function(failures) { | |
181 ExtensionLoader.getInstance().notifyAdditionalFailures(failures); | |
182 }; | |
183 | |
139 return { | 184 return { |
140 ExtensionLoader: ExtensionLoader | 185 ExtensionLoader: ExtensionLoader |
141 }; | 186 }; |
142 }); | 187 }); |
OLD | NEW |