Chromium Code Reviews| Index: chrome/browser/resources/extensions/extension_error_overlay.js |
| diff --git a/chrome/browser/resources/extensions/extension_error_overlay.js b/chrome/browser/resources/extensions/extension_error_overlay.js |
| index 24ddff30d64d10d954c8851ea947f5b223ef8af6..d91c9147dfe49e20885da12c33d2edacafe3508f 100644 |
| --- a/chrome/browser/resources/extensions/extension_error_overlay.js |
| +++ b/chrome/browser/resources/extensions/extension_error_overlay.js |
| @@ -91,24 +91,6 @@ cr.define('extensions', function() { |
| return !/^extensions::/.test(url); |
| }; |
| - /** |
| - * Send a call to chrome to open the developer tools for an error. |
| - * This will call either the bound function in ExtensionErrorHandler or the |
| - * API function from developerPrivate, depending on whether this is being |
| - * used in the native chrome:extensions page or the Apps Developer Tool. |
| - * @see chrome/browser/ui/webui/extensions/extension_error_ui_util.h |
| - * @param {OpenDevToolsProperties} args The arguments to pass to openDevTools. |
| - * @private |
| - */ |
| - RuntimeErrorContent.openDevtools_ = function(args) { |
| - if (chrome.send) |
| - chrome.send('extensionErrorOpenDevTools', [args]); |
| - else if (chrome.developerPrivate) |
| - chrome.developerPrivate.openDevTools(args); |
| - else |
| - assertNotReached('Cannot call either openDevTools function.'); |
| - }; |
| - |
| RuntimeErrorContent.prototype = { |
| __proto__: HTMLDivElement.prototype, |
| @@ -236,10 +218,8 @@ cr.define('extensions', function() { |
| frameNode.addEventListener('click', function(frame, frameNode, e) { |
| this.setActiveFrame_(frameNode); |
| - // Request the file source with the section highlighted; this will |
| - // call ExtensionErrorOverlay.requestFileSourceResponse() when |
| - // completed, which in turn calls setCode(). |
| - ExtensionErrorOverlay.requestFileSource( |
| + // Request the file source with the section highlighted. |
| + extensions.ExtensionErrorOverlay.getInstance().requestFileSource( |
| {extensionId: this.error_.extensionId, |
| message: this.error_.message, |
| pathSuffix: getRelativeUrl(frame.url, |
| @@ -268,7 +248,7 @@ cr.define('extensions', function() { |
| var stackFrame = |
| this.error_.stackTrace[this.currentFrameNode_.indexIntoTrace]; |
| - RuntimeErrorContent.openDevtools_( |
| + chrome.developerPrivate.openDevTools( |
| {renderProcessId: this.error_.renderProcessId || -1, |
| renderViewId: this.error_.renderViewId || -1, |
| url: stackFrame.url, |
| @@ -348,27 +328,6 @@ cr.define('extensions', function() { |
| return false; |
| }; |
| - /** |
| - * Send a call to chrome to request the source of a given file. |
| - * This will call either the bound function in ExtensionErrorHandler or the |
| - * API function from developerPrivate, depending on whether this is being |
| - * used in the native chrome:extensions page or the Apps Developer Tool. |
| - * @see chrome/browser/ui/webui/extensions/extension_error_ui_util.h |
| - * @param {RequestFileSourceProperties} args The arguments to pass to |
| - * requestFileSource. |
| - */ |
| - ExtensionErrorOverlay.requestFileSource = function(args) { |
| - if (chrome.send) { |
| - chrome.send('extensionErrorRequestFileSource', [args]); |
| - } else if (chrome.developerPrivate) { |
| - chrome.developerPrivate.requestFileSource(args, function(result) { |
| - extensions.ExtensionErrorOverlay.requestFileSourceResponse(result); |
| - }); |
| - } else { |
| - assertNotReached('Cannot call either requestFileSource function.'); |
| - } |
| - }; |
| - |
| cr.addSingletonGetter(ExtensionErrorOverlay); |
| ExtensionErrorOverlay.prototype = { |
| @@ -500,45 +459,40 @@ cr.define('extensions', function() { |
| error.stackTrace && error.stackTrace[0] ? |
| error.stackTrace[0].lineNumber : 0; |
| } |
| - ExtensionErrorOverlay.requestFileSource(requestFileSourceArgs); |
| + this.requestFileSource(requestFileSourceArgs); |
| } else { |
| - ExtensionErrorOverlay.requestFileSourceResponse(null); |
| + this.onFileSourceResponse_(null); |
|
Dan Beam
2015/03/05 02:05:46
doesn't this throw a null pointer exception, basic
Devlin
2015/03/05 16:56:17
Yes. Fixed.
|
| } |
| }, |
| + /** |
| + * Requests a file's source. |
| + * @param {RequestFileSourceProperties} args The arguments for the call. |
| + */ |
| + requestFileSource: function(args) { |
| + chrome.developerPrivate.requestFileSource( |
| + args, this.onFileSourceResponse_.bind(this)); |
| + }, |
| /** |
| * Set the code to be displayed in the code portion of the overlay. |
| * @see ExtensionErrorOverlay.requestFileSourceResponse(). |
| - * @param {?ExtensionHighlight} code The code to be displayed. If |code| is |
| - * null, then |
| - * a "Could not display code" message will be displayed instead. |
| + * @param {?RequestFileSourceResponse} response The response from the |
| + * request file source call, which will be shown as code. If |response| |
| + * is null, then a "Could not display code" message will be displayed |
| + * instead. |
| */ |
| - setCode: function(code) { |
| + onFileSourceResponse_: function(response) { |
| document.querySelector( |
| '#extension-error-overlay .extension-error-overlay-title'). |
| - textContent = code.title; |
| - |
| + textContent = response.title; |
|
Dan Beam
2015/03/05 02:05:12
if response can be null, shouldn't we handle that
Devlin
2015/03/05 16:56:17
Yes, we definitely should.
|
| this.codeDiv_.populate( |
| - code, |
| + response, |
| loadTimeData.getString('extensionErrorOverlayNoCodeToDisplay')); |
| + this.setVisible(true); |
| }, |
| }; |
| - /** |
| - * Called by the ExtensionErrorHandler responding to the request for a file's |
| - * source. Populate the content area of the overlay and display the overlay. |
| - * @param {?ExtensionHighlight} result The three 'highlight' strings represent |
| - * three portions of the file's content to display - the portion which is |
| - * most relevant and should be emphasized (highlight), and the parts both |
| - * before and after this portion. These may be empty. |
| - */ |
| - ExtensionErrorOverlay.requestFileSourceResponse = function(result) { |
| - var overlay = extensions.ExtensionErrorOverlay.getInstance(); |
| - overlay.setCode(result); |
| - overlay.setVisible(true); |
| - }; |
| - |
| // Export |
| return { |
| ExtensionErrorOverlay: ExtensionErrorOverlay |