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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 /** | |
| 239 * |loadFinished| should be used for testing purposes and will be | |
| 240 * fulfilled when this list has finished loading the first time. | |
| 241 * @type {Promise} | |
| 242 * */ | |
| 243 this.loadFinished = new Promise(function(resolve, reject) { | |
| 244 /** @private {function(?)} */ | |
| 245 this.onLoadFinish_ = resolve; | |
| 246 }.bind(this)); | |
| 247 | |
| 238 chrome.developerPrivate.onItemStateChanged.addListener( | 248 chrome.developerPrivate.onItemStateChanged.addListener( |
| 239 function(eventData) { | 249 function(eventData) { |
| 240 var EventType = chrome.developerPrivate.EventType; | 250 var EventType = chrome.developerPrivate.EventType; |
| 241 switch (eventData.event_type) { | 251 switch (eventData.event_type) { |
| 242 case EventType.VIEW_REGISTERED: | 252 case EventType.VIEW_REGISTERED: |
| 243 case EventType.VIEW_UNREGISTERED: | 253 case EventType.VIEW_UNREGISTERED: |
| 244 // For now, view notifications are handled through the WebUI. | 254 // For now, view notifications are handled through the WebUI. |
| 245 // TODO(devlin): Transition these. | 255 // TODO(devlin): Transition these. |
| 246 break; | 256 break; |
| 247 case EventType.INSTALLED: | 257 case EventType.INSTALLED: |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 278 this.extensionsUpdated_ = new Promise(function(resolve, reject) { | 288 this.extensionsUpdated_ = new Promise(function(resolve, reject) { |
| 279 chrome.developerPrivate.getExtensionsInfo( | 289 chrome.developerPrivate.getExtensionsInfo( |
| 280 {includeDisabled: true, includeTerminated: true}, | 290 {includeDisabled: true, includeTerminated: true}, |
| 281 function(extensions) { | 291 function(extensions) { |
| 282 // Sort in order of unpacked vs. packed, followed by name, followed by | 292 // Sort in order of unpacked vs. packed, followed by name, followed by |
| 283 // id. | 293 // id. |
| 284 extensions.sort(compareExtensions); | 294 extensions.sort(compareExtensions); |
| 285 this.extensions_ = extensions; | 295 this.extensions_ = extensions; |
| 286 this.showExtensionNodes_(); | 296 this.showExtensionNodes_(); |
| 287 resolve(); | 297 resolve(); |
| 298 | |
| 299 // |resolve| is async so it's necessary to use |then| here in order to | |
| 300 // do work after other |then|s have finished. | |
| 301 this.extensionsUpdated_.then(function() { | |
| 302 // |onUpdateFinished_| should be called after the list becomes | |
| 303 // visible in extensions.js. | |
|
Dan Beam
2015/04/20 17:56:00
^ this is no longer true, is it? probably OK to j
hcarmona
2015/04/20 18:46:56
Updated other comment to show that this is intende
| |
| 304 this.onUpdateFinished_(); | |
| 305 | |
| 306 // |onLoadFinish_| will resolve the |loadFinished| promise for | |
| 307 // testing purposes. | |
| 308 this.onLoadFinish_(); | |
|
Dan Beam
2015/04/20 17:56:00
nit: maybe name this resolveLoadFinished_(); and r
hcarmona
2015/04/20 18:46:56
Done.
| |
| 309 }.bind(this)); | |
| 288 }.bind(this)); | 310 }.bind(this)); |
| 289 }.bind(this)); | 311 }.bind(this)); |
| 290 return this.extensionsUpdated_; | 312 return this.extensionsUpdated_; |
| 291 }, | 313 }, |
| 292 | 314 |
| 315 /** | |
| 316 * Updates elements that need to be visible in order to update properly. | |
| 317 * @private | |
| 318 */ | |
| 319 onUpdateFinished_: function() { | |
| 320 // Cannot focus or highlight a extension if there are none. | |
| 321 if (this.extensions_.length == 0) | |
| 322 return; | |
| 323 | |
| 324 assert(!this.hidden); | |
| 325 assert(!this.parentElement.hidden); | |
| 326 | |
| 327 this.updateFocusableElements(); | |
| 328 | |
| 329 var idToHighlight = this.getIdQueryParam_(); | |
| 330 if (idToHighlight && $(idToHighlight)) | |
| 331 this.scrollToNode_(idToHighlight); | |
| 332 | |
| 333 var idToOpenOptions = this.getOptionsQueryParam_(); | |
| 334 if (idToOpenOptions && $(idToOpenOptions)) | |
| 335 this.showEmbeddedExtensionOptions_(idToOpenOptions, true); | |
| 336 }, | |
| 337 | |
| 293 /** @return {number} The number of extensions being displayed. */ | 338 /** @return {number} The number of extensions being displayed. */ |
| 294 getNumExtensions: function() { | 339 getNumExtensions: function() { |
| 295 return this.extensions_.length; | 340 return this.extensions_.length; |
| 296 }, | 341 }, |
| 297 | 342 |
| 298 getIdQueryParam_: function() { | 343 getIdQueryParam_: function() { |
| 299 return parseQueryParams(document.location)['id']; | 344 return parseQueryParams(document.location)['id']; |
| 300 }, | 345 }, |
| 301 | 346 |
| 302 getOptionsQueryParam_: function() { | 347 getOptionsQueryParam_: function() { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 332 focusableNode.getEquivalentElement( | 377 focusableNode.getEquivalentElement( |
| 333 document.activeElement).focus(); | 378 document.activeElement).focus(); |
| 334 } | 379 } |
| 335 } | 380 } |
| 336 | 381 |
| 337 node.parentElement.removeChild(node); | 382 node.parentElement.removeChild(node); |
| 338 // Unregister the removed node from events. | 383 // Unregister the removed node from events. |
| 339 assertInstanceof(node, ExtensionFocusRow).destroy(); | 384 assertInstanceof(node, ExtensionFocusRow).destroy(); |
| 340 } | 385 } |
| 341 } | 386 } |
| 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 }, | 387 }, |
| 351 | 388 |
| 352 /** Updates each row's focusable elements without rebuilding the grid. */ | 389 /** Updates each row's focusable elements without rebuilding the grid. */ |
| 353 updateFocusableElements: function() { | 390 updateFocusableElements: function() { |
| 354 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]'); | 391 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]'); |
| 355 for (var i = 0; i < rows.length; ++i) { | 392 for (var i = 0; i < rows.length; ++i) { |
| 356 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements(); | 393 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements(); |
| 357 } | 394 } |
| 358 }, | 395 }, |
| 359 | 396 |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1058 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1]; | 1095 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1]; |
| 1059 this.createNode_(extension, nextExt ? $(nextExt.id) : null); | 1096 this.createNode_(extension, nextExt ? $(nextExt.id) : null); |
| 1060 } | 1097 } |
| 1061 } | 1098 } |
| 1062 }; | 1099 }; |
| 1063 | 1100 |
| 1064 return { | 1101 return { |
| 1065 ExtensionList: ExtensionList | 1102 ExtensionList: ExtensionList |
| 1066 }; | 1103 }; |
| 1067 }); | 1104 }); |
| OLD | NEW |