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 | |
Dan Beam
2013/08/20 21:39:26
/** @constructor */
Devlin
2013/08/20 23:06:51
Done.
| |
8 function ExtensionErrorOverlay() { | |
9 } | |
10 | |
11 cr.addSingletonGetter(ExtensionErrorOverlay); | |
12 | |
13 ExtensionErrorOverlay.prototype = { | |
14 /** | |
15 * Initialize the page. | |
16 */ | |
17 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
| |
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. | |
Dan Beam
2013/08/20 21:39:26
@private
Devlin
2013/08/20 23:06:51
Done.
| |
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 }; | |
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
| |
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/>'); | |
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 }); | |
OLD | NEW |