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 cr.define('extensions', function() { | 5 cr.define('extensions', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Construct an ExtensionLoadError around the given |div|. | 9 * Construct an ExtensionLoadError around the given |div|. |
10 * @param {HTMLDivElement} div The HTML div for the extension load error. | 10 * @param {HTMLDivElement} div The HTML div for the extension load error. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 * @private | 179 * @private |
180 */ | 180 */ |
181 this.loadError_ = new ExtensionLoadError( | 181 this.loadError_ = new ExtensionLoadError( |
182 /** @type {HTMLDivElement} */($('extension-load-error'))); | 182 /** @type {HTMLDivElement} */($('extension-load-error'))); |
183 } | 183 } |
184 | 184 |
185 cr.addSingletonGetter(ExtensionLoader); | 185 cr.addSingletonGetter(ExtensionLoader); |
186 | 186 |
187 ExtensionLoader.prototype = { | 187 ExtensionLoader.prototype = { |
188 /** | 188 /** |
| 189 * Whether or not we are currently loading an unpacked extension. |
| 190 * @private {boolean} |
| 191 */ |
| 192 isLoading_: false, |
| 193 |
| 194 /** |
189 * Begin the sequence of loading an unpacked extension. If an error is | 195 * Begin the sequence of loading an unpacked extension. If an error is |
190 * encountered, this object will get notified via notifyFailed(). | 196 * encountered, this object will get notified via notifyFailed(). |
191 */ | 197 */ |
192 loadUnpacked: function() { | 198 loadUnpacked: function() { |
193 chrome.send('extensionLoaderLoadUnpacked'); | 199 if (this.isLoading_) // Only one running load at a time. |
| 200 return; |
| 201 this.isLoading_ = true; |
| 202 chrome.developerPrivate.loadUnpacked({failQuietly: true}, function() { |
| 203 // Check lastError to avoid the log, but don't do anything with it - |
| 204 // error-handling is done on the C++ side. |
| 205 var lastError = chrome.runtime.lastError; |
| 206 this.isLoading_ = false; |
| 207 }.bind(this)); |
194 }, | 208 }, |
195 | 209 |
196 /** | 210 /** |
197 * Notify the ExtensionLoader that loading an unpacked extension failed. | 211 * Notify the ExtensionLoader that loading an unpacked extension failed. |
198 * Add the failure to failures_ and show the ExtensionLoadError. | 212 * Add the failure to failures_ and show the ExtensionLoadError. |
199 * @param {Array<Object>} failures Array of failures containing paths, | 213 * @param {Array<Object>} failures Array of failures containing paths, |
200 * errors, and manifests. | 214 * errors, and manifests. |
201 */ | 215 */ |
202 notifyFailed: function(failures) { | 216 notifyFailed: function(failures) { |
203 this.loadError_.add_(failures); | 217 this.loadError_.add_(failures); |
204 }, | 218 }, |
205 }; | 219 }; |
206 | 220 |
207 /** | 221 /** |
208 * A static forwarding function for ExtensionLoader.notifyFailed. | 222 * A static forwarding function for ExtensionLoader.notifyFailed. |
209 * @param {Array<Object>} failures Array of failures containing paths, | 223 * @param {Array<Object>} failures Array of failures containing paths, |
210 * errors, and manifests. | 224 * errors, and manifests. |
211 * @see ExtensionLoader.notifyFailed | 225 * @see ExtensionLoader.notifyFailed |
212 */ | 226 */ |
213 ExtensionLoader.notifyLoadFailed = function(failures) { | 227 ExtensionLoader.notifyLoadFailed = function(failures) { |
214 ExtensionLoader.getInstance().notifyFailed(failures); | 228 ExtensionLoader.getInstance().notifyFailed(failures); |
215 }; | 229 }; |
216 | 230 |
217 return { | 231 return { |
218 ExtensionLoader: ExtensionLoader | 232 ExtensionLoader: ExtensionLoader |
219 }; | 233 }; |
220 }); | 234 }); |
OLD | NEW |