| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 5 |
| 6 /** @typedef {chrome.developerPrivate.RuntimeError} */ | 6 /** @typedef {chrome.developerPrivate.RuntimeError} */ |
| 7 var RuntimeError; | 7 var RuntimeError; |
| 8 /** @typedef {chrome.developerPrivate.ManifestError} */ | 8 /** @typedef {chrome.developerPrivate.ManifestError} */ |
| 9 var ManifestError; | 9 var ManifestError; |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 /** | 23 /** |
| 24 * Get the url relative to the main extension url. If the url is | 24 * Get the url relative to the main extension url. If the url is |
| 25 * unassociated with the extension, this will be the full url. | 25 * unassociated with the extension, this will be the full url. |
| 26 * @param {string} url The url to make relative. | 26 * @param {string} url The url to make relative. |
| 27 * @param {string} extensionUrl The url for the extension resources, in the | 27 * @param {string} extensionUrl The url for the extension resources, in the |
| 28 * form "chrome-etxension://<extension_id>/". | 28 * form "chrome-etxension://<extension_id>/". |
| 29 * @return {string} The url relative to the host. | 29 * @return {string} The url relative to the host. |
| 30 */ | 30 */ |
| 31 function getRelativeUrl(url, extensionUrl) { | 31 function getRelativeUrl(url, extensionUrl) { |
| 32 return url.substring(0, extensionUrl.length) == extensionUrl ? | 32 return url.substring(0, extensionUrl.length) == extensionUrl ? |
| 33 url.substring(extensionUrl.length) : url; | 33 url.substring(extensionUrl.length) : |
| 34 url; |
| 34 } | 35 } |
| 35 | 36 |
| 36 /** | 37 /** |
| 37 * The RuntimeErrorContent manages all content specifically associated with | 38 * The RuntimeErrorContent manages all content specifically associated with |
| 38 * runtime errors; this includes stack frames and the context url. | 39 * runtime errors; this includes stack frames and the context url. |
| 39 * @constructor | 40 * @constructor |
| 40 * @extends {HTMLDivElement} | 41 * @extends {HTMLDivElement} |
| 41 */ | 42 */ |
| 42 function RuntimeErrorContent() { | 43 function RuntimeErrorContent() { |
| 43 var contentArea = $('template-collection-extension-error-overlay'). | 44 var contentArea = |
| 44 querySelector('.extension-error-overlay-runtime-content'). | 45 $('template-collection-extension-error-overlay') |
| 45 cloneNode(true); | 46 .querySelector('.extension-error-overlay-runtime-content') |
| 47 .cloneNode(true); |
| 46 contentArea.__proto__ = RuntimeErrorContent.prototype; | 48 contentArea.__proto__ = RuntimeErrorContent.prototype; |
| 47 contentArea.init(); | 49 contentArea.init(); |
| 48 return contentArea; | 50 return contentArea; |
| 49 } | 51 } |
| 50 | 52 |
| 51 /** | 53 /** |
| 52 * The name of the "active" class specific to extension errors (so as to | 54 * The name of the "active" class specific to extension errors (so as to |
| 53 * not conflict with other rules). | 55 * not conflict with other rules). |
| 54 * @type {string} | 56 * @type {string} |
| 55 * @const | 57 * @const |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 96 |
| 95 /** | 97 /** |
| 96 * Initialize the RuntimeErrorContent for the first time. | 98 * Initialize the RuntimeErrorContent for the first time. |
| 97 */ | 99 */ |
| 98 init: function() { | 100 init: function() { |
| 99 /** | 101 /** |
| 100 * The stack trace element in the overlay. | 102 * The stack trace element in the overlay. |
| 101 * @type {HTMLElement} | 103 * @type {HTMLElement} |
| 102 * @private | 104 * @private |
| 103 */ | 105 */ |
| 104 this.stackTrace_ = /** @type {HTMLElement} */( | 106 this.stackTrace_ = /** @type {HTMLElement} */ ( |
| 105 this.querySelector('.extension-error-overlay-stack-trace-list')); | 107 this.querySelector('.extension-error-overlay-stack-trace-list')); |
| 106 assert(this.stackTrace_); | 108 assert(this.stackTrace_); |
| 107 | 109 |
| 108 /** | 110 /** |
| 109 * The context URL element in the overlay. | 111 * The context URL element in the overlay. |
| 110 * @type {HTMLElement} | 112 * @type {HTMLElement} |
| 111 * @private | 113 * @private |
| 112 */ | 114 */ |
| 113 this.contextUrl_ = /** @type {HTMLElement} */( | 115 this.contextUrl_ = /** @type {HTMLElement} */ ( |
| 114 this.querySelector('.extension-error-overlay-context-url')); | 116 this.querySelector('.extension-error-overlay-context-url')); |
| 115 assert(this.contextUrl_); | 117 assert(this.contextUrl_); |
| 116 }, | 118 }, |
| 117 | 119 |
| 118 /** | 120 /** |
| 119 * Sets the error for the content. | 121 * Sets the error for the content. |
| 120 * @param {(RuntimeError|ManifestError)} error The error whose content | 122 * @param {(RuntimeError|ManifestError)} error The error whose content |
| 121 * should be displayed. | 123 * should be displayed. |
| 122 * @param {string} extensionUrl The URL associated with this extension. | 124 * @param {string} extensionUrl The URL associated with this extension. |
| 123 */ | 125 */ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 continue; | 175 continue; |
| 174 | 176 |
| 175 var frameNode = document.createElement('li'); | 177 var frameNode = document.createElement('li'); |
| 176 // Attach the index of the frame to which this node refers (since we | 178 // Attach the index of the frame to which this node refers (since we |
| 177 // may skip some, this isn't a 1-to-1 match). | 179 // may skip some, this isn't a 1-to-1 match). |
| 178 frameNode.indexIntoTrace = i; | 180 frameNode.indexIntoTrace = i; |
| 179 | 181 |
| 180 // The description is a human-readable summation of the frame, in the | 182 // The description is a human-readable summation of the frame, in the |
| 181 // form "<relative_url>:<line_number> (function)", e.g. | 183 // form "<relative_url>:<line_number> (function)", e.g. |
| 182 // "myfile.js:25 (myFunction)". | 184 // "myfile.js:25 (myFunction)". |
| 183 var description = getRelativeUrl(frame.url, | 185 var description = |
| 184 assert(this.extensionUrl_)) + ':' + frame.lineNumber; | 186 getRelativeUrl(frame.url, assert(this.extensionUrl_)) + ':' + |
| 187 frame.lineNumber; |
| 185 if (frame.functionName) { | 188 if (frame.functionName) { |
| 186 var functionName = frame.functionName == '(anonymous function)' ? | 189 var functionName = frame.functionName == '(anonymous function)' ? |
| 187 loadTimeData.getString('extensionErrorOverlayAnonymousFunction') : | 190 loadTimeData.getString('extensionErrorOverlayAnonymousFunction') : |
| 188 frame.functionName; | 191 frame.functionName; |
| 189 description += ' (' + functionName + ')'; | 192 description += ' (' + functionName + ')'; |
| 190 } | 193 } |
| 191 frameNode.textContent = description; | 194 frameNode.textContent = description; |
| 192 | 195 |
| 193 // When the user clicks on a frame in the stack trace, we should | 196 // When the user clicks on a frame in the stack trace, we should |
| 194 // highlight that overlay in the list, display the appropriate source | 197 // highlight that overlay in the list, display the appropriate source |
| 195 // code with the line highlighted, and link the "Open DevTools" button | 198 // code with the line highlighted, and link the "Open DevTools" button |
| 196 // with that frame. | 199 // with that frame. |
| 197 frameNode.addEventListener('click', function(frame, frameNode, e) { | 200 frameNode.addEventListener('click', function(frame, frameNode, e) { |
| 198 this.setActiveFrame_(frameNode); | 201 this.setActiveFrame_(frameNode); |
| 199 | 202 |
| 200 // Request the file source with the section highlighted. | 203 // Request the file source with the section highlighted. |
| 201 extensions.ExtensionErrorOverlay.getInstance().requestFileSource( | 204 extensions.ExtensionErrorOverlay.getInstance().requestFileSource({ |
| 202 {extensionId: this.error_.extensionId, | 205 extensionId: this.error_.extensionId, |
| 203 message: this.error_.message, | 206 message: this.error_.message, |
| 204 pathSuffix: getRelativeUrl(frame.url, | 207 pathSuffix: getRelativeUrl(frame.url, assert(this.extensionUrl_)), |
| 205 assert(this.extensionUrl_)), | 208 lineNumber: frame.lineNumber |
| 206 lineNumber: frame.lineNumber}); | 209 }); |
| 207 }.bind(this, frame, frameNode)); | 210 }.bind(this, frame, frameNode)); |
| 208 | 211 |
| 209 this.stackTrace_.appendChild(frameNode); | 212 this.stackTrace_.appendChild(frameNode); |
| 210 } | 213 } |
| 211 | 214 |
| 212 // Set the current stack frame to the first stack frame and show the | 215 // Set the current stack frame to the first stack frame and show the |
| 213 // trace, if one exists. (We can't just check error.stackTrace, because | 216 // trace, if one exists. (We can't just check error.stackTrace, because |
| 214 // it's possible the trace was purely internal, and we don't show | 217 // it's possible the trace was purely internal, and we don't show |
| 215 // internal frames.) | 218 // internal frames.) |
| 216 if (this.stackTrace_.children.length > 0) { | 219 if (this.stackTrace_.children.length > 0) { |
| 217 this.stackTrace_.hidden = false; | 220 this.stackTrace_.hidden = false; |
| 218 this.setActiveFrame_(assertInstanceof(this.stackTrace_.firstChild, | 221 this.setActiveFrame_( |
| 219 HTMLElement)); | 222 assertInstanceof(this.stackTrace_.firstChild, HTMLElement)); |
| 220 } | 223 } |
| 221 }, | 224 }, |
| 222 | 225 |
| 223 /** | 226 /** |
| 224 * Open the developer tools for the active stack frame. | 227 * Open the developer tools for the active stack frame. |
| 225 */ | 228 */ |
| 226 openDevtools: function() { | 229 openDevtools: function() { |
| 227 var stackFrame = | 230 var stackFrame = |
| 228 this.error_.stackTrace[this.currentFrameNode_.indexIntoTrace]; | 231 this.error_.stackTrace[this.currentFrameNode_.indexIntoTrace]; |
| 229 | 232 |
| 230 chrome.developerPrivate.openDevTools( | 233 chrome.developerPrivate.openDevTools({ |
| 231 {renderProcessId: this.error_.renderProcessId || -1, | 234 renderProcessId: this.error_.renderProcessId || -1, |
| 232 renderViewId: this.error_.renderViewId || -1, | 235 renderViewId: this.error_.renderViewId || -1, |
| 233 url: stackFrame.url, | 236 url: stackFrame.url, |
| 234 lineNumber: stackFrame.lineNumber || 0, | 237 lineNumber: stackFrame.lineNumber || 0, |
| 235 columnNumber: stackFrame.columnNumber || 0}); | 238 columnNumber: stackFrame.columnNumber || 0 |
| 239 }); |
| 236 } | 240 } |
| 237 }; | 241 }; |
| 238 | 242 |
| 239 /** | 243 /** |
| 240 * The ExtensionErrorOverlay will show the contents of a file which pertains | 244 * The ExtensionErrorOverlay will show the contents of a file which pertains |
| 241 * to the ExtensionError; this is either the manifest file (for manifest | 245 * to the ExtensionError; this is either the manifest file (for manifest |
| 242 * errors) or a source file (for runtime errors). If possible, the portion | 246 * errors) or a source file (for runtime errors). If possible, the portion |
| 243 * of the file which caused the error will be highlighted. | 247 * of the file which caused the error will be highlighted. |
| 244 * @constructor | 248 * @constructor |
| 245 */ | 249 */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 265 * Determine whether or not chrome can load the source for a given file; this | 269 * Determine whether or not chrome can load the source for a given file; this |
| 266 * can only be done if the file belongs to the extension. | 270 * can only be done if the file belongs to the extension. |
| 267 * @param {string} file The file to load. | 271 * @param {string} file The file to load. |
| 268 * @param {string} extensionUrl The url for the extension, in the form | 272 * @param {string} extensionUrl The url for the extension, in the form |
| 269 * chrome-extension://<extension-id>/. | 273 * chrome-extension://<extension-id>/. |
| 270 * @return {boolean} True if the file can be loaded, false otherwise. | 274 * @return {boolean} True if the file can be loaded, false otherwise. |
| 271 * @private | 275 * @private |
| 272 */ | 276 */ |
| 273 ExtensionErrorOverlay.canLoadFileSource = function(file, extensionUrl) { | 277 ExtensionErrorOverlay.canLoadFileSource = function(file, extensionUrl) { |
| 274 return file.substr(0, extensionUrl.length) == extensionUrl || | 278 return file.substr(0, extensionUrl.length) == extensionUrl || |
| 275 file.toLowerCase() == ExtensionErrorOverlay.MANIFEST_FILENAME_; | 279 file.toLowerCase() == ExtensionErrorOverlay.MANIFEST_FILENAME_; |
| 276 }; | 280 }; |
| 277 | 281 |
| 278 cr.addSingletonGetter(ExtensionErrorOverlay); | 282 cr.addSingletonGetter(ExtensionErrorOverlay); |
| 279 | 283 |
| 280 ExtensionErrorOverlay.prototype = { | 284 ExtensionErrorOverlay.prototype = { |
| 281 /** | 285 /** |
| 282 * The underlying error whose details are being displayed. | 286 * The underlying error whose details are being displayed. |
| 283 * @type {?(RuntimeError|ManifestError)} | 287 * @type {?(RuntimeError|ManifestError)} |
| 284 * @private | 288 * @private |
| 285 */ | 289 */ |
| 286 selectedError_: null, | 290 selectedError_: null, |
| 287 | 291 |
| 288 /** | 292 /** |
| 289 * Initialize the page. | 293 * Initialize the page. |
| 290 * @param {function(HTMLDivElement)} showOverlay The function to show or | 294 * @param {function(HTMLDivElement)} showOverlay The function to show or |
| 291 * hide the ExtensionErrorOverlay; this should take a single parameter | 295 * hide the ExtensionErrorOverlay; this should take a single parameter |
| 292 * which is either the overlay Div if the overlay should be displayed, | 296 * which is either the overlay Div if the overlay should be displayed, |
| 293 * or null if the overlay should be hidden. | 297 * or null if the overlay should be hidden. |
| 294 */ | 298 */ |
| 295 initializePage: function(showOverlay) { | 299 initializePage: function(showOverlay) { |
| 296 var overlay = $('overlay'); | 300 var overlay = $('overlay'); |
| 297 cr.ui.overlay.setupOverlay(overlay); | 301 cr.ui.overlay.setupOverlay(overlay); |
| 298 cr.ui.overlay.globalInitialization(); | 302 cr.ui.overlay.globalInitialization(); |
| 299 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); | 303 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); |
| 300 | 304 |
| 301 $('extension-error-overlay-dismiss').addEventListener('click', | 305 $('extension-error-overlay-dismiss') |
| 302 function() { | 306 .addEventListener('click', function() { |
| 303 cr.dispatchSimpleEvent(overlay, 'cancelOverlay'); | 307 cr.dispatchSimpleEvent(overlay, 'cancelOverlay'); |
| 304 }); | 308 }); |
| 305 | 309 |
| 306 /** | 310 /** |
| 307 * The element of the full overlay. | 311 * The element of the full overlay. |
| 308 * @type {HTMLDivElement} | 312 * @type {HTMLDivElement} |
| 309 * @private | 313 * @private |
| 310 */ | 314 */ |
| 311 this.overlayDiv_ = /** @type {HTMLDivElement} */( | 315 this.overlayDiv_ = |
| 312 $('extension-error-overlay')); | 316 /** @type {HTMLDivElement} */ ($('extension-error-overlay')); |
| 313 | 317 |
| 314 /** | 318 /** |
| 315 * The portion of the overlay which shows the code relating to the error | 319 * The portion of the overlay which shows the code relating to the error |
| 316 * and the corresponding line numbers. | 320 * and the corresponding line numbers. |
| 317 * @type {extensions.ExtensionCode} | 321 * @type {extensions.ExtensionCode} |
| 318 * @private | 322 * @private |
| 319 */ | 323 */ |
| 320 this.codeDiv_ = | 324 this.codeDiv_ = |
| 321 new extensions.ExtensionCode($('extension-error-overlay-code')); | 325 new extensions.ExtensionCode($('extension-error-overlay-code')); |
| 322 | 326 |
| 323 /** | 327 /** |
| 324 * The function to show or hide the ExtensionErrorOverlay. | 328 * The function to show or hide the ExtensionErrorOverlay. |
| 325 * @param {boolean} isVisible Whether the overlay should be visible. | 329 * @param {boolean} isVisible Whether the overlay should be visible. |
| 326 */ | 330 */ |
| 327 this.setVisible = function(isVisible) { | 331 this.setVisible = function(isVisible) { |
| 328 showOverlay(isVisible ? this.overlayDiv_ : null); | 332 showOverlay(isVisible ? this.overlayDiv_ : null); |
| 329 if (isVisible) | 333 if (isVisible) |
| 330 this.codeDiv_.scrollToError(); | 334 this.codeDiv_.scrollToError(); |
| 331 }; | 335 }; |
| 332 | 336 |
| 333 /** | 337 /** |
| 334 * The button to open the developer tools (only available for runtime | 338 * The button to open the developer tools (only available for runtime |
| 335 * errors). | 339 * errors). |
| 336 * @type {HTMLButtonElement} | 340 * @type {HTMLButtonElement} |
| 337 * @private | 341 * @private |
| 338 */ | 342 */ |
| 339 this.openDevtoolsButton_ = /** @type {HTMLButtonElement} */( | 343 this.openDevtoolsButton_ = /** @type {HTMLButtonElement} */ ( |
| 340 $('extension-error-overlay-devtools-button')); | 344 $('extension-error-overlay-devtools-button')); |
| 341 this.openDevtoolsButton_.addEventListener('click', function() { | 345 this.openDevtoolsButton_.addEventListener('click', function() { |
| 342 this.runtimeErrorContent_.openDevtools(); | 346 this.runtimeErrorContent_.openDevtools(); |
| 343 }.bind(this)); | 347 }.bind(this)); |
| 344 }, | 348 }, |
| 345 | 349 |
| 346 /** | 350 /** |
| 347 * Handles a click on the dismiss ("OK" or close) buttons. | 351 * Handles a click on the dismiss ("OK" or close) buttons. |
| 348 * @param {Event} e The click event. | 352 * @param {Event} e The click event. |
| 349 * @private | 353 * @private |
| 350 */ | 354 */ |
| 351 handleDismiss_: function(e) { | 355 handleDismiss_: function(e) { |
| 352 this.setVisible(false); | 356 this.setVisible(false); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 this.codeDiv_.populate( | 398 this.codeDiv_.populate( |
| 395 null, loadTimeData.getString('extensionErrorNoErrorsCodeMessage')); | 399 null, loadTimeData.getString('extensionErrorNoErrorsCodeMessage')); |
| 396 this.clearRuntimeContent_(); | 400 this.clearRuntimeContent_(); |
| 397 return; | 401 return; |
| 398 } | 402 } |
| 399 | 403 |
| 400 var extensionUrl = 'chrome-extension://' + error.extensionId + '/'; | 404 var extensionUrl = 'chrome-extension://' + error.extensionId + '/'; |
| 401 // Set or hide runtime content. | 405 // Set or hide runtime content. |
| 402 if (error.type == chrome.developerPrivate.ErrorType.RUNTIME) { | 406 if (error.type == chrome.developerPrivate.ErrorType.RUNTIME) { |
| 403 this.runtimeErrorContent_.setError(error, extensionUrl); | 407 this.runtimeErrorContent_.setError(error, extensionUrl); |
| 404 this.overlayDiv_.querySelector('.content-area').insertBefore( | 408 this.overlayDiv_.querySelector('.content-area') |
| 405 this.runtimeErrorContent_, | 409 .insertBefore(this.runtimeErrorContent_, this.codeDiv_.nextSibling); |
| 406 this.codeDiv_.nextSibling); | |
| 407 this.openDevtoolsButton_.hidden = false; | 410 this.openDevtoolsButton_.hidden = false; |
| 408 this.openDevtoolsButton_.disabled = !error.canInspect; | 411 this.openDevtoolsButton_.disabled = !error.canInspect; |
| 409 } else { | 412 } else { |
| 410 this.clearRuntimeContent_(); | 413 this.clearRuntimeContent_(); |
| 411 } | 414 } |
| 412 | 415 |
| 413 // Read the file source to populate the code section, or set it to null if | 416 // Read the file source to populate the code section, or set it to null if |
| 414 // the file is unreadable. | 417 // the file is unreadable. |
| 415 if (ExtensionErrorOverlay.canLoadFileSource(error.source, extensionUrl)) { | 418 if (ExtensionErrorOverlay.canLoadFileSource(error.source, extensionUrl)) { |
| 416 // Use pathname instead of relativeUrl. | 419 // Use pathname instead of relativeUrl. |
| 417 var requestFileSourceArgs = {extensionId: error.extensionId, | 420 var requestFileSourceArgs = { |
| 418 message: error.message}; | 421 extensionId: error.extensionId, |
| 422 message: error.message |
| 423 }; |
| 419 switch (error.type) { | 424 switch (error.type) { |
| 420 case chrome.developerPrivate.ErrorType.MANIFEST: | 425 case chrome.developerPrivate.ErrorType.MANIFEST: |
| 421 requestFileSourceArgs.pathSuffix = error.source; | 426 requestFileSourceArgs.pathSuffix = error.source; |
| 422 requestFileSourceArgs.manifestKey = error.manifestKey; | 427 requestFileSourceArgs.manifestKey = error.manifestKey; |
| 423 requestFileSourceArgs.manifestSpecific = error.manifestSpecific; | 428 requestFileSourceArgs.manifestSpecific = error.manifestSpecific; |
| 424 break; | 429 break; |
| 425 case chrome.developerPrivate.ErrorType.RUNTIME: | 430 case chrome.developerPrivate.ErrorType.RUNTIME: |
| 426 // slice(1) because pathname starts with a /. | 431 // slice(1) because pathname starts with a /. |
| 427 var pathname = new URL(error.source).pathname.slice(1); | 432 var pathname = new URL(error.source).pathname.slice(1); |
| 428 requestFileSourceArgs.pathSuffix = pathname; | 433 requestFileSourceArgs.pathSuffix = pathname; |
| 429 requestFileSourceArgs.lineNumber = | 434 requestFileSourceArgs.lineNumber = |
| 430 error.stackTrace && error.stackTrace[0] ? | 435 error.stackTrace && error.stackTrace[0] ? |
| 431 error.stackTrace[0].lineNumber : 0; | 436 error.stackTrace[0].lineNumber : |
| 437 0; |
| 432 break; | 438 break; |
| 433 default: | 439 default: |
| 434 assertNotReached(); | 440 assertNotReached(); |
| 435 } | 441 } |
| 436 this.requestFileSource(requestFileSourceArgs); | 442 this.requestFileSource(requestFileSourceArgs); |
| 437 } else { | 443 } else { |
| 438 this.onFileSourceResponse_(null); | 444 this.onFileSourceResponse_(null); |
| 439 } | 445 } |
| 440 }, | 446 }, |
| 441 | 447 |
| 442 /** | 448 /** |
| 443 * Associate an error with the overlay. This will set the error for the | 449 * Associate an error with the overlay. This will set the error for the |
| 444 * overlay, and, if possible, will populate the code section of the overlay | 450 * overlay, and, if possible, will populate the code section of the overlay |
| 445 * with the relevant file, load the stack trace, and generate links for | 451 * with the relevant file, load the stack trace, and generate links for |
| 446 * opening devtools (the latter two only happen for runtime errors). | 452 * opening devtools (the latter two only happen for runtime errors). |
| 447 * @param {Array<(RuntimeError|ManifestError)>} errors The error to show in | 453 * @param {Array<(RuntimeError|ManifestError)>} errors The error to show in |
| 448 * the overlay. | 454 * the overlay. |
| 449 * @param {string} extensionId The id of the extension. | 455 * @param {string} extensionId The id of the extension. |
| 450 * @param {string} extensionName The name of the extension. | 456 * @param {string} extensionName The name of the extension. |
| 451 */ | 457 */ |
| 452 setErrorsAndShowOverlay: function(errors, extensionId, extensionName) { | 458 setErrorsAndShowOverlay: function(errors, extensionId, extensionName) { |
| 453 document.querySelector( | 459 document |
| 454 '#extension-error-overlay .extension-error-overlay-title'). | 460 .querySelector( |
| 455 textContent = extensionName; | 461 '#extension-error-overlay .extension-error-overlay-title') |
| 462 .textContent = extensionName; |
| 456 var errorsDiv = this.overlayDiv_.querySelector('.extension-error-list'); | 463 var errorsDiv = this.overlayDiv_.querySelector('.extension-error-list'); |
| 457 var extensionErrors = | 464 var extensionErrors = |
| 458 new extensions.ExtensionErrorList(errors, extensionId); | 465 new extensions.ExtensionErrorList(errors, extensionId); |
| 459 errorsDiv.parentNode.replaceChild(extensionErrors, errorsDiv); | 466 errorsDiv.parentNode.replaceChild(extensionErrors, errorsDiv); |
| 460 extensionErrors.addEventListener('activeExtensionErrorChanged', | 467 extensionErrors.addEventListener( |
| 461 function(e) { | 468 'activeExtensionErrorChanged', function(e) { |
| 462 this.setActiveError_(e.detail); | 469 this.setActiveError_(e.detail); |
| 463 }.bind(this)); | 470 }.bind(this)); |
| 464 | 471 |
| 465 if (errors.length > 0) | 472 if (errors.length > 0) |
| 466 this.setActiveError_(errors[0]); | 473 this.setActiveError_(errors[0]); |
| 467 this.setVisible(true); | 474 this.setVisible(true); |
| 468 }, | 475 }, |
| 469 | 476 |
| 470 /** | 477 /** |
| 471 * Requests a file's source. | 478 * Requests a file's source. |
| 472 * @param {chrome.developerPrivate.RequestFileSourceProperties} args The | 479 * @param {chrome.developerPrivate.RequestFileSourceProperties} args The |
| 473 * arguments for the call. | 480 * arguments for the call. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 487 */ | 494 */ |
| 488 onFileSourceResponse_: function(response) { | 495 onFileSourceResponse_: function(response) { |
| 489 this.codeDiv_.populate( | 496 this.codeDiv_.populate( |
| 490 response, // ExtensionCode can handle a null response. | 497 response, // ExtensionCode can handle a null response. |
| 491 loadTimeData.getString('extensionErrorOverlayNoCodeToDisplay')); | 498 loadTimeData.getString('extensionErrorOverlayNoCodeToDisplay')); |
| 492 this.setVisible(true); | 499 this.setVisible(true); |
| 493 }, | 500 }, |
| 494 }; | 501 }; |
| 495 | 502 |
| 496 // Export | 503 // Export |
| 497 return { | 504 return {ExtensionErrorOverlay: ExtensionErrorOverlay}; |
| 498 ExtensionErrorOverlay: ExtensionErrorOverlay | |
| 499 }; | |
| 500 }); | 505 }); |
| OLD | NEW |