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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4ae3b25f689977e985ec0c3d6e73fc262a76c7d0 |
| --- /dev/null |
| +++ b/chrome/browser/resources/extensions/extension_error_overlay.js |
| @@ -0,0 +1,83 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +cr.define('extensions', function() { |
| + 'use strict'; |
| + |
|
Dan Beam
2013/08/20 21:39:26
/** @constructor */
Devlin
2013/08/20 23:06:51
Done.
|
| + function ExtensionErrorOverlay() { |
| + } |
| + |
| + cr.addSingletonGetter(ExtensionErrorOverlay); |
| + |
| + ExtensionErrorOverlay.prototype = { |
| + /** |
| + * Initialize the page. |
| + */ |
| + initializePage: function() { |
|
Dan Beam
2013/08/20 21:39:26
does this override anything?
Devlin
2013/08/20 23:06:51
I don't *believe* so. There's an identically-named
|
| + var overlay = $('overlay'); |
| + cr.ui.overlay.setupOverlay(overlay); |
| + cr.ui.overlay.globalInitialization(); |
| + overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); |
| + |
| + $('extensionErrorOverlayDismiss').addEventListener( |
| + 'click', this.handleDismiss_.bind(this)); |
| + }, |
| + |
| + /** |
| + * Handles a click on the dismiss button. |
| + * @param {Event} e The click event. |
|
Dan Beam
2013/08/20 21:39:26
@private
Devlin
2013/08/20 23:06:51
Done.
|
| + */ |
| + handleDismiss_: function(e) { |
| + $('extensionErrorOverlayContent').innerHTML = ''; |
| + ExtensionSettings.showOverlay(null); |
| + }, |
| + }; |
| + |
| + /** |
| + * Called by the dom_ui_ to re-populate the page with data representing |
| + * the current state of extension commands. |
| + */ |
| + ExtensionErrorOverlay.returnExtensionsData = function(extensionsData) { |
| + }; |
|
Dan Beam
2013/08/20 21:39:26
^ er, what's the point of this?
Devlin
2013/08/20 23:06:51
To teach me that, no matter how much I look at a C
|
| + |
| + /** |
| + * 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 {Object} result An object with four strings - the title, |
| + * beforeHighlight, afterHighlight, and highlight. 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 content = $('extensionErrorOverlayContent'); |
| + $('extensionErrorOverlay').querySelector( |
| + '.extension-error-overlay-title').innerText = result.title; |
| + |
| + var createSpan = function(source, isHighlighted) { |
| + var span = document.createElement('span'); |
| + span.className = isHighlighted ? 'highlighted-source' : 'normal-source'; |
| + source = source.replace(/ /g, ' ').replace(/\n/g, '<br/>'); |
| + span.innerHTML = source; |
| + return span; |
| + }; |
| + |
| + if (result.beforeHighlight) |
| + content.appendChild(createSpan(result.beforeHighlight, false)); |
| + if (result.highlight) { |
| + var highlightSpan = createSpan(result.highlight, true); |
| + highlightSpan.title = result.errorMessage; |
| + content.appendChild(highlightSpan); |
| + } |
| + if (result.afterHighlight) |
| + content.appendChild(createSpan(result.afterHighlight, false)); |
| + |
| + ExtensionSettings.showOverlay($('extensionErrorOverlay')); |
| + }; |
| + |
| + // Export |
| + return { |
| + ExtensionErrorOverlay: ExtensionErrorOverlay |
| + }; |
| +}); |