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 /** @type {!chrome.developerPrivate.RequestFileSourceResponse} */ |
| 52 var codeSectionProperties = { |
| 53 beforeHighlight: source ? source.beforeHighlight : '', |
| 54 highlight: source ? source.highlight : '', |
| 55 afterHighlight: source ? source.afterHighlight : '', |
| 56 title: '', |
| 57 message: this.loadError.error, |
| 58 }; |
| 59 |
| 60 this.$.code.code = codeSectionProperties; |
| 61 }, |
40 }); | 62 }); |
41 | 63 |
42 return {LoadError: LoadError, | 64 return {LoadError: LoadError, |
43 LoadErrorDelegate: LoadErrorDelegate}; | 65 LoadErrorDelegate: LoadErrorDelegate}; |
44 }); | 66 }); |
OLD | NEW |