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

Side by Side 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: Add tests 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/extensions/extensions.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <include src="extension_error.js"> 5 <include src="extension_error.js">
6 6
7 /////////////////////////////////////////////////////////////////////////////// 7 ///////////////////////////////////////////////////////////////////////////////
8 // ExtensionFocusRow: 8 // ExtensionFocusRow:
9 9
10 /** 10 /**
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 */ 228 */
229 enableAppInfoDialog_: false, 229 enableAppInfoDialog_: false,
230 230
231 /** 231 /**
232 * Initializes the list. 232 * Initializes the list.
233 */ 233 */
234 initialize: function() { 234 initialize: function() {
235 /** @private {!Array<ExtensionInfo>} */ 235 /** @private {!Array<ExtensionInfo>} */
236 this.extensions_ = []; 236 this.extensions_ = [];
237 237
238 var self = this;
239 /**
240 * |loadFinished| should be used for testing purposes and will be
241 * fulfilled when this list has finished loading the first time.
242 * @type {Promise}
243 * */
244 this.loadFinished = new Promise(function(resolve, reject) {
245 /** @private {function(?)} */
246 self.onLoadFinish_ = resolve;
247 });
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.
248
238 chrome.developerPrivate.onItemStateChanged.addListener( 249 chrome.developerPrivate.onItemStateChanged.addListener(
239 function(eventData) { 250 function(eventData) {
240 var EventType = chrome.developerPrivate.EventType; 251 var EventType = chrome.developerPrivate.EventType;
241 switch (eventData.event_type) { 252 switch (eventData.event_type) {
242 case EventType.VIEW_REGISTERED: 253 case EventType.VIEW_REGISTERED:
243 case EventType.VIEW_UNREGISTERED: 254 case EventType.VIEW_UNREGISTERED:
244 // For now, view notifications are handled through the WebUI. 255 // For now, view notifications are handled through the WebUI.
245 // TODO(devlin): Transition these. 256 // TODO(devlin): Transition these.
246 break; 257 break;
247 case EventType.INSTALLED: 258 case EventType.INSTALLED:
(...skipping 30 matching lines...) Expand all
278 this.extensionsUpdated_ = new Promise(function(resolve, reject) { 289 this.extensionsUpdated_ = new Promise(function(resolve, reject) {
279 chrome.developerPrivate.getExtensionsInfo( 290 chrome.developerPrivate.getExtensionsInfo(
280 {includeDisabled: true, includeTerminated: true}, 291 {includeDisabled: true, includeTerminated: true},
281 function(extensions) { 292 function(extensions) {
282 // Sort in order of unpacked vs. packed, followed by name, followed by 293 // Sort in order of unpacked vs. packed, followed by name, followed by
283 // id. 294 // id.
284 extensions.sort(compareExtensions); 295 extensions.sort(compareExtensions);
285 this.extensions_ = extensions; 296 this.extensions_ = extensions;
286 this.showExtensionNodes_(); 297 this.showExtensionNodes_();
287 resolve(); 298 resolve();
299
300 this.extensionsUpdated_.then(function() {
301 // |onUpdateFinished_| should be called after the list becomes
302 // visible in extensions.js. |resolve| is async, so
303 // |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.
304 if (extensions.length > 0)
305 this.onUpdateFinished_();
306
307 // |onLoadFinish_| will resolve the |loadFinished| promise for
308 // testing purposes.
309 this.onLoadFinish_();
310 }.bind(this));
288 }.bind(this)); 311 }.bind(this));
289 }.bind(this)); 312 }.bind(this));
290 return this.extensionsUpdated_; 313 return this.extensionsUpdated_;
291 }, 314 },
292 315
316 /** Updates elements that need to be visible in order to update properly. */
317 onUpdateFinished_: function() {
318 assert(!this.hidden);
319 assert(!this.parentElement.hidden);
320
321 this.updateFocusableElements();
322
323 var idToHighlight = this.getIdQueryParam_();
324 if (idToHighlight && $(idToHighlight))
325 this.scrollToNode_(idToHighlight);
326
327 var idToOpenOptions = this.getOptionsQueryParam_();
328 if (idToOpenOptions && $(idToOpenOptions))
329 this.showEmbeddedExtensionOptions_(idToOpenOptions, true);
330 },
331
293 /** @return {number} The number of extensions being displayed. */ 332 /** @return {number} The number of extensions being displayed. */
294 getNumExtensions: function() { 333 getNumExtensions: function() {
295 return this.extensions_.length; 334 return this.extensions_.length;
296 }, 335 },
297 336
298 getIdQueryParam_: function() { 337 getIdQueryParam_: function() {
299 return parseQueryParams(document.location)['id']; 338 return parseQueryParams(document.location)['id'];
300 }, 339 },
301 340
302 getOptionsQueryParam_: function() { 341 getOptionsQueryParam_: function() {
(...skipping 29 matching lines...) Expand all
332 focusableNode.getEquivalentElement( 371 focusableNode.getEquivalentElement(
333 document.activeElement).focus(); 372 document.activeElement).focus();
334 } 373 }
335 } 374 }
336 375
337 node.parentElement.removeChild(node); 376 node.parentElement.removeChild(node);
338 // Unregister the removed node from events. 377 // Unregister the removed node from events.
339 assertInstanceof(node, ExtensionFocusRow).destroy(); 378 assertInstanceof(node, ExtensionFocusRow).destroy();
340 } 379 }
341 } 380 }
342
343 var idToHighlight = this.getIdQueryParam_();
344 if (idToHighlight && $(idToHighlight))
345 this.scrollToNode_(idToHighlight);
346
347 var idToOpenOptions = this.getOptionsQueryParam_();
348 if (idToOpenOptions && $(idToOpenOptions))
349 this.showEmbeddedExtensionOptions_(idToOpenOptions, true);
350 }, 381 },
351 382
352 /** Updates each row's focusable elements without rebuilding the grid. */ 383 /** Updates each row's focusable elements without rebuilding the grid. */
353 updateFocusableElements: function() { 384 updateFocusableElements: function() {
354 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]'); 385 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]');
355 for (var i = 0; i < rows.length; ++i) { 386 for (var i = 0; i < rows.length; ++i) {
356 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements(); 387 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements();
357 } 388 }
358 }, 389 },
359 390
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1]; 1089 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1];
1059 this.createNode_(extension, nextExt ? $(nextExt.id) : null); 1090 this.createNode_(extension, nextExt ? $(nextExt.id) : null);
1060 } 1091 }
1061 } 1092 }
1062 }; 1093 };
1063 1094
1064 return { 1095 return {
1065 ExtensionList: ExtensionList 1096 ExtensionList: ExtensionList
1066 }; 1097 };
1067 }); 1098 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/extensions/extensions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698