OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** @typedef {chrome.developerPrivate.ManifestError} */ | 5 /** @typedef {chrome.developerPrivate.ManifestError} */ |
6 var ManifestError; | 6 var ManifestError; |
7 /** @typedef {chrome.developerPrivate.RuntimeError} */ | 7 /** @typedef {chrome.developerPrivate.RuntimeError} */ |
8 var RuntimeError; | 8 var RuntimeError; |
9 | 9 |
10 cr.define('extensions', function() { | 10 cr.define('extensions', function() { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return 'icon-severity-warning'; | 103 return 'icon-severity-warning'; |
104 }, | 104 }, |
105 | 105 |
106 /** | 106 /** |
107 * @param {!Event} event | 107 * @param {!Event} event |
108 * @private | 108 * @private |
109 */ | 109 */ |
110 onDeleteErrorTap_: function(event) { | 110 onDeleteErrorTap_: function(event) { |
111 // TODO(devlin): It would be cleaner if we could cast this to a | 111 // TODO(devlin): It would be cleaner if we could cast this to a |
112 // PolymerDomRepeatEvent-type thing, but that doesn't exist yet. | 112 // PolymerDomRepeatEvent-type thing, but that doesn't exist yet. |
113 var e = /** @type {!{model:Object}} */(event); | 113 var e = /** @type {!{model:Object}} */ (event); |
114 this.delegate.deleteErrors(this.data.id, [e.model.item.id]); | 114 this.delegate.deleteErrors(this.data.id, [e.model.item.id]); |
115 }, | 115 }, |
116 | 116 |
117 /** | 117 /** |
118 * Fetches the source for the selected error and populates the code section. | 118 * Fetches the source for the selected error and populates the code section. |
119 * @private | 119 * @private |
120 */ | 120 */ |
121 onSelectedErrorChanged_: function() { | 121 onSelectedErrorChanged_: function() { |
122 var error = this.selectedError_; | 122 var error = this.selectedError_; |
123 var args = { | 123 var args = { |
124 extensionId: error.extensionId, | 124 extensionId: error.extensionId, |
125 message: error.message, | 125 message: error.message, |
126 }; | 126 }; |
127 switch (error.type) { | 127 switch (error.type) { |
128 case chrome.developerPrivate.ErrorType.MANIFEST: | 128 case chrome.developerPrivate.ErrorType.MANIFEST: |
129 args.pathSuffix = error.source; | 129 args.pathSuffix = error.source; |
130 args.manifestKey = error.manifestKey; | 130 args.manifestKey = error.manifestKey; |
131 args.manifestSpecific = error.manifestSpecific; | 131 args.manifestSpecific = error.manifestSpecific; |
132 break; | 132 break; |
133 case chrome.developerPrivate.ErrorType.RUNTIME: | 133 case chrome.developerPrivate.ErrorType.RUNTIME: |
134 // slice(1) because pathname starts with a /. | 134 // slice(1) because pathname starts with a /. |
135 args.pathSuffix = new URL(error.source).pathname.slice(1); | 135 args.pathSuffix = new URL(error.source).pathname.slice(1); |
136 args.lineNumber = error.stackTrace && error.stackTrace[0] ? | 136 args.lineNumber = error.stackTrace && error.stackTrace[0] ? |
137 error.stackTrace[0].lineNumber : 0; | 137 error.stackTrace[0].lineNumber : |
| 138 0; |
138 break; | 139 break; |
139 } | 140 } |
140 this.delegate.requestFileSource(args).then(function(code) { | 141 this.delegate.requestFileSource(args).then(function(code) { |
141 this.$['code-section'].code = code; | 142 this.$['code-section'].code = code; |
142 }.bind(this)); | 143 }.bind(this)); |
143 }, | 144 }, |
144 | 145 |
145 /** | 146 /** |
146 * Computes the class name for the error item depending on whether its | 147 * Computes the class name for the error item depending on whether its |
147 * the currently selected error. | 148 * the currently selected error. |
148 * @param {!RuntimeError|!ManifestError} selectedError | 149 * @param {!RuntimeError|!ManifestError} selectedError |
149 * @param {!RuntimeError|!ManifestError} error | 150 * @param {!RuntimeError|!ManifestError} error |
150 * @return {string} | 151 * @return {string} |
151 * @private | 152 * @private |
152 */ | 153 */ |
153 computeErrorClass_: function(selectedError, error) { | 154 computeErrorClass_: function(selectedError, error) { |
154 return selectedError == error ? | 155 return selectedError == error ? 'error-item selected' : 'error-item'; |
155 'error-item selected' : 'error-item'; | |
156 }, | 156 }, |
157 | 157 |
158 /** | 158 /** |
159 * Causes the given error to become the currently-selected error. | 159 * Causes the given error to become the currently-selected error. |
160 * @param {!RuntimeError|!ManifestError} error | 160 * @param {!RuntimeError|!ManifestError} error |
161 * @private | 161 * @private |
162 */ | 162 */ |
163 selectError_: function(error) { | 163 selectError_: function(error) { |
164 this.selectedError_ = error; | 164 this.selectedError_ = error; |
165 }, | 165 }, |
(...skipping 14 matching lines...) Expand all Loading... |
180 if (e.key == ' ' || e.key == 'Enter') | 180 if (e.key == ' ' || e.key == 'Enter') |
181 this.selectError_(e.model.item); | 181 this.selectError_(e.model.item); |
182 }, | 182 }, |
183 }); | 183 }); |
184 | 184 |
185 return { | 185 return { |
186 ErrorPage: ErrorPage, | 186 ErrorPage: ErrorPage, |
187 ErrorPageDelegate: ErrorPageDelegate, | 187 ErrorPageDelegate: ErrorPageDelegate, |
188 }; | 188 }; |
189 }); | 189 }); |
OLD | NEW |