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

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

Issue 1090763003: Fix scroll regression when specifying an extension id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply Feedback Created 5 years, 8 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_list.js
diff --git a/chrome/browser/resources/extensions/extension_list.js b/chrome/browser/resources/extensions/extension_list.js
index f6967bd6297656b638d75cb63c44064ba79773fc..041ae9914944c3deded36c2aad1d3f01bd21baa8 100644
--- a/chrome/browser/resources/extensions/extension_list.js
+++ b/chrome/browser/resources/extensions/extension_list.js
@@ -235,6 +235,16 @@ cr.define('extensions', function() {
/** @private {!Array<ExtensionInfo>} */
this.extensions_ = [];
+ /**
+ * |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(?)} */
+ this.onLoadFinish_ = resolve;
+ }.bind(this));
+
chrome.developerPrivate.onItemStateChanged.addListener(
function(eventData) {
var EventType = chrome.developerPrivate.EventType;
@@ -285,11 +295,43 @@ cr.define('extensions', function() {
this.extensions_ = extensions;
this.showExtensionNodes_();
resolve();
+
+ // |resolve| is async so it's necessary to use |then| here in order to
+ // do work after other |then|s have finished.
+ this.extensionsUpdated_.then(function() {
Dan Beam 2015/04/18 01:28:40 why not: this.loadFinished_ = this.extensionUpd
hcarmona 2015/04/20 17:51:08 |updateExtensionsData| is called async, so the tes
Dan Beam 2015/04/20 17:56:00 ok, makes sense. thanks for explanation.
+ // |onUpdateFinished_| should be called after the list becomes
+ // visible in extensions.js.
+ 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. */
Dan Beam 2015/04/18 01:28:41 /** * Updates ... * @private */
hcarmona 2015/04/20 17:51:08 Done.
+ onUpdateFinished_: function() {
+ // Cannot focus or highlight a extension if there are none.
+ if (this.extensions_.length == 0)
+ return;
+
+ 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 +381,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. */

Powered by Google App Engine
This is Rietveld 408576698