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

Unified Diff: chrome/browser/resources/extensions/extension_loader.js

Issue 342003005: Show alert failure for reloading unpacked extensions with bad manifest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed be_noisy, support interaction with multiple failures Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/extensions/extension_loader.js
diff --git a/chrome/browser/resources/extensions/extension_loader.js b/chrome/browser/resources/extensions/extension_loader.js
index fb57c18b139075cba35b00c733df28187052c4c9..7e24a536f43f0203fcd8f41cbcbb18f38ef880b1 100644
--- a/chrome/browser/resources/extensions/extension_loader.js
+++ b/chrome/browser/resources/extensions/extension_loader.js
@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+window.addEventListener('beforeunload', function() {
+ chrome.send('extensionLoaderSetDisplayLoading');
+});
+
cr.define('extensions', function() {
'use strict';
@@ -45,42 +49,96 @@ cr.define('extensions', function() {
this.manifest_ = new extensions.ExtensionCode(
this.querySelector('#extension-load-error-manifest'));
+ /**
+ * The element which displays information about additional errors.
+ * @type {HTMLPreElement}
+ * @private
+ */
+ this.additional_ = this.querySelector('#extension-load-error-additional');
+
+ /**
+ * An array of failures for keeping track of multiple active failures.
+ * @type {Array}
Devlin 2014/07/01 22:14:17 Array of whats? (document)
gpdavis 2014/07/01 23:48:09 An array of failures! Just kidding. Added in a F
+ * @private
+ */
+ this.failures_ = [];
+
this.querySelector('#extension-load-error-retry-button').addEventListener(
'click', function(e) {
- chrome.send('extensionLoaderRetry');
- this.hide_();
+ chrome.send('extensionLoaderRetry',
+ [this.failures_[this.failures_.length - 1].path_]);
Devlin 2014/07/01 22:14:17 We can't do this. We deliberately do not allow We
gpdavis 2014/07/01 23:48:10 Rats. I suppose I'll add a vector of file paths a
+ this.remove_();
}.bind(this));
this.querySelector('#extension-load-error-give-up-button').
addEventListener('click', function(e) {
- this.hide_();
+ this.remove_();
}.bind(this));
+
+ chrome.send('extensionLoaderDisplayFailures');
},
/**
- * Display the load error to the user.
+ * Add a failure to failures_ array. If there is already a displayed
Devlin 2014/07/01 22:14:17 nit: one space after a period (Clint will never fo
gpdavis 2014/07/01 23:48:10 He most certainly has not ;) Done.
+ * failure, display the additional failures element.
* @param {string} path The path from which the extension was loaded.
* @param {string} reason The reason the extension failed to load.
* @param {string} manifest The manifest object, with highlighted regions.
*/
- show: function(path, reason, manifest) {
- this.path_.textContent = path;
- this.reason_.textContent = reason;
+ add: function(path, reason, manifest) {
+ if (this.failures_.length == 1) {
Devlin 2014/07/01 22:14:17 nit: no brackets around single-line if
gpdavis 2014/07/01 23:48:10 Done.
+ this.additional_.hidden = false;
+ }
+
+ this.failures_.push({
+ path_: path,
+ reason_: reason,
+ manifest_: manifest
+ });
+
+ this.show_();
+ },
- manifest.message = reason;
- this.manifest_.populate(
- manifest,
- loadTimeData.getString('extensionLoadCouldNotLoadManifest'));
- this.hidden = false;
- this.manifest_.scrollToError();
+ /**
+ * Remove a failure from failures_ array. If this was the last failure,
+ * hide the error UI. If this was the last additional failure, hide
+ * the additional failures UI.
+ * @private
+ */
+ remove_: function() {
+ this.failures_.pop();
+ if (this.failures_.length == 0) {
+ this.hidden = true;
+ } else {
+ if (this.failures_.length == 1) {
Devlin 2014/07/01 22:14:17 nit: brackets.
gpdavis 2014/07/01 23:48:10 Done.
+ this.additional_.hidden = true;
+ }
+ this.show_();
+ }
},
/**
- * Hide the extension load error.
+ * Display the load error to the user. The last failure gets its manifest
+ * and error displayed, while additional failures have their path names
Devlin 2014/07/01 22:14:17 I don't think we wrap like this for these comments
gpdavis 2014/07/01 23:48:10 See line 176. Should I do it a different way?
Devlin 2014/07/02 17:46:49 I think that we only line-wrap for param declarati
+ * displayed in the additional failures element.
* @private
*/
- hide_: function() {
- this.hidden = true;
+ show_: function() {
+ var failure = this.failures_[this.failures_.length - 1];
+ this.path_.textContent = failure.path_;
+ this.reason_.textContent = failure.reason_;
+
+ failure.manifest_.message = failure.reason_;
+ this.manifest_.populate(
+ failure.manifest_,
+ loadTimeData.getString('extensionLoadCouldNotLoadManifest'));
+ this.hidden = false;
+ this.manifest_.scrollToError();
+
+ this.additional_.textContent = 'Additional failures:';
Devlin 2014/07/01 22:14:17 this will still have to be i18n'd. ;)
gpdavis 2014/07/01 23:48:10 How do in JS?
gpdavis 2014/07/02 00:49:36 This was a premature request for help. Got it fig
+ for (var i = 0; i < this.failures_.length - 1; ++i) {
+ this.additional_.textContent += '\n' + this.failures_[i].path_;
Devlin 2014/07/01 22:14:17 nit: no brackets around 1-line for loops
gpdavis 2014/07/01 23:48:09 Done.
+ }
}
};
@@ -111,7 +169,7 @@ cr.define('extensions', function() {
/**
* Notify the ExtensionLoader that loading an unpacked extension failed.
- * Show the ExtensionLoadError.
+ * Add the failure to failures_ and show the ExtensionLoadError.
* @param {string} filePath The path to the unpacked extension.
* @param {string} reason The reason the extension failed to load.
* @param {Object} manifest An object with three strings: beforeHighlight,
@@ -121,8 +179,8 @@ cr.define('extensions', function() {
* this portion. These may be empty.
*/
notifyFailed: function(filePath, reason, manifest) {
- this.loadError_.show(filePath, reason, manifest);
- }
+ this.loadError_.add(filePath, reason, manifest);
+ },
};
/*

Powered by Google App Engine
This is Rietveld 408576698