Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: chrome/browser/resources/extensions/extension_loader.js

Issue 422533002: Fix Regression in Unpacked Extension Load Error UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 cr.define('extensions', function() { 5 cr.define('extensions', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Construct an ExtensionLoadError around the given |div|. 9 * Construct an ExtensionLoadError around the given |div|.
10 * @param {HTMLDivElement} div The HTML div for the extension load error. 10 * @param {HTMLDivElement} div The HTML div for the extension load error.
11 * @constructor 11 * @constructor
12 */ 12 */
13 function ExtensionLoadError(div) { 13 function ExtensionLoadError(div) {
14 div.__proto__ = ExtensionLoadError.prototype; 14 div.__proto__ = ExtensionLoadError.prototype;
15 div.init(); 15 div.init();
16 return div; 16 return div;
17 } 17 }
18 18
19 /**
20 * Construct a Failure.
not at google - send to devlin 2014/07/25 16:03:10 what was wrong with a Failure type?
Devlin 2014/07/25 16:15:41 Well, depends on your semantics ;) Since JS is "t
not at google - send to devlin 2014/07/25 16:19:09 if we never constructed a Failure that is a proble
Devlin 2014/07/25 16:22:44 Well, the failure object is primarily constructed
not at google - send to devlin 2014/07/25 16:44:13 Yes I think that would be better. why is it wastef
Devlin 2014/07/25 17:17:25 Because of all the extra work we do to copy those
21 * @param {string} filePath The path to the unpacked extension.
22 * @param {string} reason The reason the extension failed to load.
23 * @param {Object} manifest An object with three strings: beforeHighlight,
24 * afterHighlight, and highlight. These represent three portions of the
25 * file's content to display - the portion which is most relevant and
26 * should be emphasized (highlight), and the parts both before and after
27 * this portion. These may be empty.
28 * @param {HTMLLIElement} listElement The HTML element used for displaying the
29 * failure path for the additional failures UI.
30 * @constructor
31 */
32 function Failure(filePath, reason, manifest, listElement) {
33 this.path = filePath;
34 this.reason = reason;
35 this.manifest = manifest;
36 this.listElement = listElement;
37 }
38
39 ExtensionLoadError.prototype = { 19 ExtensionLoadError.prototype = {
40 __proto__: HTMLDivElement.prototype, 20 __proto__: HTMLDivElement.prototype,
41 21
42 /** 22 /**
43 * Initialize the ExtensionLoadError div. 23 * Initialize the ExtensionLoadError div.
44 */ 24 */
45 init: function() { 25 init: function() {
46 /** 26 /**
47 * The element which displays the path of the extension. 27 * The element which displays the path of the extension.
48 * @type {HTMLSpanElement} 28 * @type {HTMLSpanElement}
(...skipping 19 matching lines...) Expand all
68 /** 48 /**
69 * The element which displays information about additional errors. 49 * The element which displays information about additional errors.
70 * @type {HTMLULElement} 50 * @type {HTMLULElement}
71 * @private 51 * @private
72 */ 52 */
73 this.additional_ = this.querySelector('#extension-load-error-additional'); 53 this.additional_ = this.querySelector('#extension-load-error-additional');
74 this.additional_.list = this.additional_.getElementsByTagName('ul')[0]; 54 this.additional_.list = this.additional_.getElementsByTagName('ul')[0];
75 55
76 /** 56 /**
77 * An array of Failures for keeping track of multiple active failures. 57 * An array of Failures for keeping track of multiple active failures.
78 * @type {Array.<Failure>} 58 * Each failure object contains the following:
59 * filePath (string) The path to the unpacked extension.
60 * error (string) The reason the extension failed to load.
61 * manifest (object) An object with three strings: beforeHighlight,
62 * afterHighlight, and highlight. These represent three portions of
63 * the file's content to display - the portion which is most relevant
64 * and should be emphasized (highlight), and the parts both before and
65 * after this portion. These may be empty.
66 * listElement (HTMLLIElement) The HTML element used for displaying the
67 * @type {Array.<Object>}
79 * @private 68 * @private
80 */ 69 */
81 this.failures_ = []; 70 this.failures_ = [];
82 71
83 this.querySelector('#extension-load-error-retry-button').addEventListener( 72 this.querySelector('#extension-load-error-retry-button').addEventListener(
84 'click', function(e) { 73 'click', function(e) {
85 chrome.send('extensionLoaderRetry'); 74 chrome.send('extensionLoaderRetry');
86 this.remove_(); 75 this.remove_();
87 }.bind(this)); 76 }.bind(this));
88 77
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 /** 128 /**
140 * Display the load error to the user. The last failure gets its manifest 129 * Display the load error to the user. The last failure gets its manifest
141 * and error displayed, while additional failures have their path names 130 * and error displayed, while additional failures have their path names
142 * displayed in the additional failures element. 131 * displayed in the additional failures element.
143 * @private 132 * @private
144 */ 133 */
145 show_: function() { 134 show_: function() {
146 assert(this.failures_.length >= 1); 135 assert(this.failures_.length >= 1);
147 var failure = this.failures_[this.failures_.length - 1]; 136 var failure = this.failures_[this.failures_.length - 1];
148 this.path_.textContent = failure.path; 137 this.path_.textContent = failure.path;
149 this.reason_.textContent = failure.reason; 138 this.reason_.textContent = failure.error;
150 139
151 failure.manifest.message = failure.reason; 140 failure.manifest.message = failure.error;
152 this.manifest_.populate( 141 this.manifest_.populate(
153 failure.manifest, 142 failure.manifest,
154 loadTimeData.getString('extensionLoadCouldNotLoadManifest')); 143 loadTimeData.getString('extensionLoadCouldNotLoadManifest'));
155 this.hidden = false; 144 this.hidden = false;
156 this.manifest_.scrollToError(); 145 this.manifest_.scrollToError();
157 146
158 this.additional_.hidden = this.failures_.length == 1; 147 this.additional_.hidden = this.failures_.length == 1;
159 } 148 }
160 }; 149 };
161 150
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 * @see ExtensionLoader.notifyFailed 191 * @see ExtensionLoader.notifyFailed
203 */ 192 */
204 ExtensionLoader.notifyLoadFailed = function(failures) { 193 ExtensionLoader.notifyLoadFailed = function(failures) {
205 ExtensionLoader.getInstance().notifyFailed(failures); 194 ExtensionLoader.getInstance().notifyFailed(failures);
206 }; 195 };
207 196
208 return { 197 return {
209 ExtensionLoader: ExtensionLoader 198 ExtensionLoader: ExtensionLoader
210 }; 199 };
211 }); 200 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698