OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 /** @interface */ | 8 /** @interface */ |
9 function LoadErrorDelegate() {} | 9 function LoadErrorDelegate() {} |
10 | 10 |
11 LoadErrorDelegate.prototype = { | 11 LoadErrorDelegate.prototype = { |
12 /** Attempts to load the previously-attempted unpacked extension. */ | 12 /** Attempts to load the previously-attempted unpacked extension. */ |
13 retryLoadUnpacked: assertNotReached, | 13 retryLoadUnpacked: assertNotReached, |
14 }; | 14 }; |
15 | 15 |
16 var LoadError = Polymer({ | 16 var LoadError = Polymer({ |
17 is: 'extensions-load-error', | 17 is: 'extensions-load-error', |
18 properties: { | 18 properties: { |
19 /** @type {extensions.LoadErrorDelegate} */ | 19 /** @type {extensions.LoadErrorDelegate} */ |
20 delegate: Object, | 20 delegate: Object, |
21 | 21 |
22 error: String, | 22 /** @type {chrome.developerPrivate.LoadError} */ |
23 loadError: Object, | |
24 }, | |
23 | 25 |
24 filePath: String, | 26 observers: [ |
25 }, | 27 'observeLoadErrorChanges_(loadError)', |
28 ], | |
26 | 29 |
27 show: function() { | 30 show: function() { |
28 this.$$('dialog').showModal(); | 31 this.$$('dialog').showModal(); |
29 }, | 32 }, |
30 | 33 |
31 close: function() { | 34 close: function() { |
32 this.$$('dialog').close(); | 35 this.$$('dialog').close(); |
33 }, | 36 }, |
34 | 37 |
35 /** @private */ | 38 /** @private */ |
36 onRetryTap_: function() { | 39 onRetryTap_: function() { |
37 this.delegate.retryLoadUnpacked(); | 40 this.delegate.retryLoadUnpacked(); |
38 this.close(); | 41 this.close(); |
39 }, | 42 }, |
43 | |
44 /** @private */ | |
45 observeLoadErrorChanges_: function() { | |
46 assert(this.loadError); | |
47 var source = this.loadError.source; | |
48 // CodeSection expects a RequestFileSourceResponse, rather than an | |
49 // ErrorFileSource. Massage into place. | |
50 // TODO(devlin): Make RequestFileSourceResponse use ErrorFileSource. | |
51 var codeSectionProperties = { | |
michaelpg
2017/03/24 02:59:01
does closure let you "cast" this to @type !Request
Devlin
2017/03/24 16:03:08
Yep, done.
| |
52 beforeHighlight: source ? source.beforeHighlight : '', | |
53 highlight: source ? source.highlight : '', | |
54 afterHighlight: source ? source.afterHighlight : '', | |
55 title: '', | |
56 message: this.loadError.error, | |
57 }; | |
58 | |
59 this.$.code.set('code', codeSectionProperties); | |
60 }, | |
40 }); | 61 }); |
41 | 62 |
42 return {LoadError: LoadError, | 63 return {LoadError: LoadError, |
43 LoadErrorDelegate: LoadErrorDelegate}; | 64 LoadErrorDelegate: LoadErrorDelegate}; |
44 }); | 65 }); |
OLD | NEW |