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 f6967bd6297656b638d75cb63c44064ba79773fc..69985d53c275881febbb4428940bac808c4eeb45 100644 |
| --- a/chrome/browser/resources/extensions/extension_list.js |
| +++ b/chrome/browser/resources/extensions/extension_list.js |
| @@ -235,6 +235,17 @@ cr.define('extensions', function() { |
| /** @private {!Array<ExtensionInfo>} */ |
| this.extensions_ = []; |
| + var self = this; |
| + /** |
| + * |loadFinished| should be used for testing purposes and will be |
| + * fulfilled when this list has finished loading the first time. |
| + * @type {Promise} |
| + * */ |
| + this.loadFinished = new Promise(function(resolve, reject) { |
| + /** @private {function(?)} */ |
| + self.onLoadFinish_ = resolve; |
| + }); |
|
not at google - send to devlin
2015/04/17 19:40:59
.bind(this) instead of self?
hcarmona
2015/04/17 20:57:37
Done.
|
| + |
| chrome.developerPrivate.onItemStateChanged.addListener( |
| function(eventData) { |
| var EventType = chrome.developerPrivate.EventType; |
| @@ -285,11 +296,39 @@ cr.define('extensions', function() { |
| this.extensions_ = extensions; |
| this.showExtensionNodes_(); |
| resolve(); |
| + |
| + this.extensionsUpdated_.then(function() { |
| + // |onUpdateFinished_| should be called after the list becomes |
| + // visible in extensions.js. |resolve| is async, so |
| + // |onUpdateFinished_| shouldn't be called directly. |
|
not at google - send to devlin
2015/04/17 19:40:59
I don't understand the second half of this comment
hcarmona
2015/04/17 20:57:37
Updated comment.
|
| + if (extensions.length > 0) |
| + this.onUpdateFinished_(); |
| + |
| + // |onLoadFinish_| will resolve the |loadFinished| promise for |
| + // testing purposes. |
| + this.onLoadFinish_(); |
| + }.bind(this)); |
| }.bind(this)); |
| }.bind(this)); |
| return this.extensionsUpdated_; |
| }, |
| + /** Updates elements that need to be visible in order to update properly. */ |
| + onUpdateFinished_: function() { |
| + assert(!this.hidden); |
| + assert(!this.parentElement.hidden); |
| + |
| + this.updateFocusableElements(); |
| + |
| + var idToHighlight = this.getIdQueryParam_(); |
| + if (idToHighlight && $(idToHighlight)) |
| + this.scrollToNode_(idToHighlight); |
| + |
| + var idToOpenOptions = this.getOptionsQueryParam_(); |
| + if (idToOpenOptions && $(idToOpenOptions)) |
| + this.showEmbeddedExtensionOptions_(idToOpenOptions, true); |
| + }, |
| + |
| /** @return {number} The number of extensions being displayed. */ |
| getNumExtensions: function() { |
| return this.extensions_.length; |
| @@ -339,14 +378,6 @@ cr.define('extensions', function() { |
| assertInstanceof(node, ExtensionFocusRow).destroy(); |
| } |
| } |
| - |
| - var idToHighlight = this.getIdQueryParam_(); |
| - if (idToHighlight && $(idToHighlight)) |
| - this.scrollToNode_(idToHighlight); |
| - |
| - var idToOpenOptions = this.getOptionsQueryParam_(); |
| - if (idToOpenOptions && $(idToOpenOptions)) |
| - this.showEmbeddedExtensionOptions_(idToOpenOptions, true); |
| }, |
| /** Updates each row's focusable elements without rebuilding the grid. */ |