Chromium Code Reviews| Index: chrome/browser/resources/extensions/extension_list.js |
| diff --git a/chrome/browser/resources/extensions/extension_list.js b/chrome/browser/resources/extensions/extension_list.js |
| index 15832f38b4e0277a4b4cb6a14875f192bf169eaf..5ae210bee041adea4cf482325cdd0b6c817410a1 100644 |
| --- a/chrome/browser/resources/extensions/extension_list.js |
| +++ b/chrome/browser/resources/extensions/extension_list.js |
| @@ -148,6 +148,8 @@ cr.define('extensions', function() { |
| div.__proto__ = ExtensionList.prototype; |
| /** @private {!Array<ExtensionInfo>} */ |
| div.extensions_ = []; |
| + chrome.developerPrivate.onItemStateChanged.addListener( |
| + div.onItemStateChanged_.bind(div)); |
| return div; |
| } |
| @@ -448,6 +450,17 @@ cr.define('extensions', function() { |
| chrome.send('extensionSettingsLaunch', [extension.id]); |
| }); |
| + row.setupColumn('.errors-link', 'errors', 'click', function(e) { |
| + var extensionId = extension.id; |
| + var newEx = this.extensions_.filter(function(e) { |
|
Dan Beam
2015/04/22 21:02:38
what if this.extensions_ is empty?
Devlin
2015/04/22 23:17:32
I don't think it can be - there'd be no node to cr
|
| + return e.state == chrome.developerPrivate.ExtensionState.ENABLED && |
| + e.id == extensionId; |
| + })[0]; |
| + var errors = newEx.manifestErrors.concat(newEx.runtimeErrors); |
| + extensions.ExtensionErrorOverlay.getInstance().setErrorsAndShowOverlay( |
| + errors, extensionId, newEx.name); |
| + }.bind(this)); |
| + |
| // The 'Reload' terminated link. |
| row.setupColumn('.terminated-reload-link', 'terminatedReload', 'click', |
| function(e) { |
| @@ -648,6 +661,31 @@ cr.define('extensions', function() { |
| isUnpacked && extension.type == |
| chrome.developerPrivate.ExtensionType.PLATFORM_APP); |
|
Dan Beam
2015/04/22 21:02:38
var errors = extension.runtimeErrors.length || ext
Devlin
2015/04/22 23:17:32
Done.
|
| + // The 'Errors' link. |
| + this.updateVisibility_( |
| + row, '.errors-link', |
| + extension.runtimeErrors.length > 0 || |
| + extension.manifestErrors.length > 0, |
| + function(item) { |
| + var Level = chrome.developerPrivate.ErrorLevel; |
|
Dan Beam
2015/04/28 03:47:03
\n
Devlin
2015/04/29 16:08:37
Done.
|
| + var map = {}; |
| + map[Level.LOG] = {weight: 0, name: 'extension-error-info-icon'}; |
| + map[Level.WARN] = {weight: 1, name: 'extension-error-warning-icon'}; |
| + map[Level.ERROR] = {weight: 2, name: 'extension-error-fatal-icon'}; |
|
Dan Beam
2015/04/28 03:47:03
\n
Devlin
2015/04/29 16:08:37
Done.
|
| + // Find the highest severity of all the errors; manifest errors all have |
| + // a 'warning' level severity. |
| + var highSeverity = extension.runtimeErrors.reduce( |
|
Dan Beam
2015/04/28 03:47:03
nit: highestSeverity or mostSevere
Devlin
2015/04/29 16:08:37
Done.
|
| + function(prev, error) { |
| + return map[error.severity].weight > map[prev].weight ? |
| + error.severity : prev; |
| + }, extension.manifestErrors.length ? Level.WARN : Level.LOG); |
|
Dan Beam
2015/04/22 21:02:38
i have no idea what this does
Devlin
2015/04/22 23:17:32
Comment on line 675. :)
It goes through and looks
|
| + |
| + // Adjust the class on the icon. |
| + var icon = item.querySelector('.extension-error-icon'); |
| + icon.className = 'extension-error-icon'; |
|
Dan Beam
2015/04/22 21:02:38
and the point of this is... to remove other classe
Devlin
2015/04/22 23:17:32
Exactly. We could also remove all the possibles,
Dan Beam
2015/04/28 03:47:03
leave as is, maybe add " // Remove other classes.
Devlin
2015/04/29 16:08:37
Done.
|
| + icon.classList.add(map[highSeverity].name); |
| + }); |
| + |
| // The 'Reload' terminated link. |
| var isTerminated = |
| extension.state == chrome.developerPrivate.ExtensionState.TERMINATED; |
| @@ -833,15 +871,6 @@ cr.define('extensions', function() { |
| }); |
| }); |
| - // If the ErrorConsole is enabled, we should have manifest and/or runtime |
| - // errors. Otherwise, we may have install warnings. We should not have |
| - // both ErrorConsole errors and install warnings. |
| - // Errors. |
| - this.updateErrors_(row.querySelector('.manifest-errors'), |
| - 'dev-manifestErrors', extension.manifestErrors); |
| - this.updateErrors_(row.querySelector('.runtime-errors'), |
| - 'dev-runtimeErrors', extension.runtimeErrors); |
| - |
| // Install warnings. |
| this.updateVisibility_(row, '.install-warnings', |
| extension.installWarnings.length > 0, |
| @@ -901,38 +930,6 @@ cr.define('extensions', function() { |
| }, |
| /** |
| - * Updates an element to show a list of errors. |
| - * @param {Element} panel An element to hold the errors. |
| - * @param {string} columnType A tag used to identify the column when |
| - * changing focus. |
| - * @param {Array<RuntimeError|ManifestError>|undefined} errors The errors |
| - * to be displayed. |
| - * @private |
| - */ |
| - updateErrors_: function(panel, columnType, errors) { |
| - // TODO(hcarmona): Look into updating the ExtensionErrorList rather than |
| - // rebuilding it every time. |
| - panel.hidden = !errors || errors.length == 0; |
| - panel.textContent = ''; |
| - |
| - if (panel.hidden) |
| - return; |
| - |
| - var errorList = |
| - new extensions.ExtensionErrorList(assertInstanceof(errors, Array)); |
| - |
| - panel.appendChild(errorList); |
| - |
| - var list = errorList.getErrorListElement(); |
| - if (list) |
| - list.setAttribute('column-type', columnType + 'list'); |
| - |
| - var button = errorList.getToggleElement(); |
| - if (button) |
| - button.setAttribute('column-type', columnType + 'button'); |
| - }, |
| - |
| - /** |
| * Opens the extension options overlay for the extension with the given id. |
| * @param {string} extensionId The id of extension whose options page should |
| * be displayed. |
| @@ -982,6 +979,24 @@ cr.define('extensions', function() { |
| // after its showing animation? Makes very little sense to me. |
| overlay.setInitialFocus(); |
| }, |
| + |
| + /** |
| + * Handle an extension changing. Currently this only checks when errors are |
| + * deleted. |
| + * @param {EventData} e The event data for the extension change. |
| + * @private |
| + */ |
| + onItemStateChanged_: function(e) { |
| + // TODO(devlin): We should be doing this for far more than just |
| + // ERRORS_REMOVED, instead of re-generating all extension data whenever |
| + // anything happens. |
| + if (e.event_type == chrome.developerPrivate.EventType.ERRORS_REMOVED && |
| + e.info) { |
| + var node = /** @type {ExtensionFocusRow} */($(e.info.id)); |
| + if (node) |
| + this.updateNode_(e.info, node); |
| + } |
| + }, |
| }; |
| return { |