Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('extensions', function() { | |
| 6 'use strict'; | |
| 7 | |
| 8 function ExtensionErrorOverlay() { | |
| 9 } | |
| 10 | |
| 11 cr.addSingletonGetter(ExtensionErrorOverlay); | |
| 12 | |
| 13 ExtensionErrorOverlay.prototype = { | |
| 14 /** | |
| 15 * Initialize the page. | |
| 16 */ | |
| 17 initializePage: function() { | |
| 18 var overlay = $('overlay'); | |
| 19 cr.ui.overlay.setupOverlay(overlay); | |
| 20 cr.ui.overlay.globalInitialization(); | |
| 21 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); | |
| 22 | |
| 23 $('extensionErrorOverlayDismiss').addEventListener( | |
| 24 'click', this.handleDismiss_.bind(this)); | |
| 25 }, | |
| 26 | |
| 27 /** | |
| 28 * Handles a click on the dismiss button. | |
| 29 * @param {Event} e The click event. | |
| 30 */ | |
| 31 handleDismiss_: function(e) { | |
| 32 $('extensionErrorOverlayContent').innerHTML = ''; | |
| 33 ExtensionSettings.showOverlay(null); | |
| 34 }, | |
| 35 }; | |
| 36 | |
| 37 /** | |
| 38 * Called by the dom_ui_ to re-populate the page with data representing | |
| 39 * the current state of extension commands. | |
| 40 */ | |
| 41 ExtensionErrorOverlay.returnExtensionsData = function(extensionsData) { | |
| 42 }; | |
| 43 | |
| 44 /** | |
| 45 * Called by the ExtensionErrorHandler responding to the request for a file's | |
| 46 * source. Populate the content area of the overlay and display the overlay. | |
| 47 * @param {Object} result An object with four strings - the title, | |
| 48 * beforeHighlight, afterHighlight, and highlight. The three 'highlight' | |
| 49 * strings represent three portions of the file's content to display - the | |
| 50 * portion which is most relevant and should be emphasized (highlight), | |
| 51 * and the parts both before and after this portion. These may be empty. | |
| 52 */ | |
| 53 ExtensionErrorOverlay.requestFileSourceResponse = function(result) { | |
| 54 var content = $('extensionErrorOverlayContent'); | |
| 55 $('extensionErrorOverlay').querySelector( | |
| 56 '.extension-error-overlay-title').innerText = result.title; | |
| 57 | |
| 58 var createSpan = function(source, isHighlighted) { | |
| 59 var span = document.createElement('span'); | |
| 60 span.className = isHighlighted ? 'highlighted-source' : 'normal-source'; | |
| 61 source = source.replace(/ /g, ' ').replace(/\n/g, '<br/>'); | |
|
Yoyo Zhou
2013/08/16 00:17:26
?
Devlin
2013/08/16 18:07:49
Huh. I wonder why that worked... oh well. Fixed.
| |
| 62 span.innerHTML = source; | |
| 63 return span; | |
| 64 }; | |
| 65 | |
| 66 if (result.beforeHighlight) | |
| 67 content.appendChild(createSpan(result.beforeHighlight, false)); | |
| 68 if (result.highlight) { | |
| 69 var highlightSpan = createSpan(result.highlight, true); | |
| 70 highlightSpan.title = result.errorMessage; | |
| 71 content.appendChild(highlightSpan); | |
| 72 } | |
| 73 if (result.afterHighlight) | |
| 74 content.appendChild(createSpan(result.afterHighlight, false)); | |
| 75 | |
| 76 ExtensionSettings.showOverlay($('extensionErrorOverlay')); | |
| 77 }; | |
| 78 | |
| 79 // Export | |
| 80 return { | |
| 81 ExtensionErrorOverlay: ExtensionErrorOverlay | |
| 82 }; | |
| 83 }); | |
| 84 | |
| 85 // Update the C++ call so this isn't necessary. | |
|
Yoyo Zhou
2013/08/16 00:17:26
Is this a TODO?
Devlin
2013/08/16 18:07:49
I was following the pattern of PackExtension/Comma
| |
| 86 var ExtensionErrorOverlay = extensions.ExtensionErrorOverlay; | |
| OLD | NEW |