Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 this.extensionsUpdated_ = new Promise(function(resolve, reject) { | 278 this.extensionsUpdated_ = new Promise(function(resolve, reject) { |
| 279 chrome.developerPrivate.getExtensionsInfo( | 279 chrome.developerPrivate.getExtensionsInfo( |
| 280 {includeDisabled: true, includeTerminated: true}, | 280 {includeDisabled: true, includeTerminated: true}, |
| 281 function(extensions) { | 281 function(extensions) { |
| 282 // Sort in order of unpacked vs. packed, followed by name, followed by | 282 // Sort in order of unpacked vs. packed, followed by name, followed by |
| 283 // id. | 283 // id. |
| 284 extensions.sort(compareExtensions); | 284 extensions.sort(compareExtensions); |
| 285 this.extensions_ = extensions; | 285 this.extensions_ = extensions; |
| 286 this.showExtensionNodes_(); | 286 this.showExtensionNodes_(); |
| 287 resolve(); | 287 resolve(); |
| 288 this.extensionsUpdated_.then(this.onUpdateFinished_.bind(this)); | |
|
not at google - send to devlin
2015/04/14 23:35:25
Since the promise has already resolved, this shoul
hcarmona
2015/04/14 23:49:06
|resolve| is async and it's important that |onUpda
not at google - send to devlin
2015/04/14 23:56:22
Mind... blown. Maybe add a comment. Are you sure t
| |
| 288 }.bind(this)); | 289 }.bind(this)); |
| 289 }.bind(this)); | 290 }.bind(this)); |
| 290 return this.extensionsUpdated_; | 291 return this.extensionsUpdated_; |
| 291 }, | 292 }, |
| 292 | 293 |
| 294 /** Updates any element that needs to be visible to update properly. */ | |
| 295 onUpdateFinished_: function() { | |
| 296 assert(!this.hidden); | |
| 297 assert(!this.parentElement.hidden); | |
| 298 | |
| 299 this.updateFocusableElements(); | |
| 300 | |
| 301 var idToHighlight = this.getIdQueryParam_(); | |
| 302 if (idToHighlight && $(idToHighlight)) | |
| 303 this.scrollToNode_(idToHighlight); | |
| 304 | |
| 305 var idToOpenOptions = this.getOptionsQueryParam_(); | |
| 306 if (idToOpenOptions && $(idToOpenOptions)) | |
| 307 this.showEmbeddedExtensionOptions_(idToOpenOptions, true); | |
| 308 }, | |
| 309 | |
| 293 /** @return {number} The number of extensions being displayed. */ | 310 /** @return {number} The number of extensions being displayed. */ |
| 294 getNumExtensions: function() { | 311 getNumExtensions: function() { |
| 295 return this.extensions_.length; | 312 return this.extensions_.length; |
| 296 }, | 313 }, |
| 297 | 314 |
| 298 getIdQueryParam_: function() { | 315 getIdQueryParam_: function() { |
| 299 return parseQueryParams(document.location)['id']; | 316 return parseQueryParams(document.location)['id']; |
| 300 }, | 317 }, |
| 301 | 318 |
| 302 getOptionsQueryParam_: function() { | 319 getOptionsQueryParam_: function() { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 332 focusableNode.getEquivalentElement( | 349 focusableNode.getEquivalentElement( |
| 333 document.activeElement).focus(); | 350 document.activeElement).focus(); |
| 334 } | 351 } |
| 335 } | 352 } |
| 336 | 353 |
| 337 node.parentElement.removeChild(node); | 354 node.parentElement.removeChild(node); |
| 338 // Unregister the removed node from events. | 355 // Unregister the removed node from events. |
| 339 assertInstanceof(node, ExtensionFocusRow).destroy(); | 356 assertInstanceof(node, ExtensionFocusRow).destroy(); |
| 340 } | 357 } |
| 341 } | 358 } |
| 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 }, | 359 }, |
| 351 | 360 |
| 352 /** Updates each row's focusable elements without rebuilding the grid. */ | 361 /** Updates each row's focusable elements without rebuilding the grid. */ |
| 353 updateFocusableElements: function() { | 362 updateFocusableElements: function() { |
| 354 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]'); | 363 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]'); |
| 355 for (var i = 0; i < rows.length; ++i) { | 364 for (var i = 0; i < rows.length; ++i) { |
| 356 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements(); | 365 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements(); |
| 357 } | 366 } |
| 358 }, | 367 }, |
| 359 | 368 |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1058 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1]; | 1067 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1]; |
| 1059 this.createNode_(extension, nextExt ? $(nextExt.id) : null); | 1068 this.createNode_(extension, nextExt ? $(nextExt.id) : null); |
| 1060 } | 1069 } |
| 1061 } | 1070 } |
| 1062 }; | 1071 }; |
| 1063 | 1072 |
| 1064 return { | 1073 return { |
| 1065 ExtensionList: ExtensionList | 1074 ExtensionList: ExtensionList |
| 1066 }; | 1075 }; |
| 1067 }); | 1076 }); |
| OLD | NEW |