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 |
| 289 // |onUpdateFinished_| should be called after the list becomes visible |
| 290 // in extensions.js. |resolve| is async, so |onUpdateFinished_| |
| 291 // shouldn't be called directly. |
| 292 this.extensionsUpdated_.then(this.onUpdateFinished_.bind(this)); |
288 }.bind(this)); | 293 }.bind(this)); |
289 }.bind(this)); | 294 }.bind(this)); |
290 return this.extensionsUpdated_; | 295 return this.extensionsUpdated_; |
291 }, | 296 }, |
292 | 297 |
| 298 /** Updates elements that need to be visible in order to update properly. */ |
| 299 onUpdateFinished_: function() { |
| 300 assert(!this.hidden); |
| 301 assert(!this.parentElement.hidden); |
| 302 |
| 303 this.updateFocusableElements(); |
| 304 |
| 305 var idToHighlight = this.getIdQueryParam_(); |
| 306 if (idToHighlight && $(idToHighlight)) |
| 307 this.scrollToNode_(idToHighlight); |
| 308 |
| 309 var idToOpenOptions = this.getOptionsQueryParam_(); |
| 310 if (idToOpenOptions && $(idToOpenOptions)) |
| 311 this.showEmbeddedExtensionOptions_(idToOpenOptions, true); |
| 312 }, |
| 313 |
293 /** @return {number} The number of extensions being displayed. */ | 314 /** @return {number} The number of extensions being displayed. */ |
294 getNumExtensions: function() { | 315 getNumExtensions: function() { |
295 return this.extensions_.length; | 316 return this.extensions_.length; |
296 }, | 317 }, |
297 | 318 |
298 getIdQueryParam_: function() { | 319 getIdQueryParam_: function() { |
299 return parseQueryParams(document.location)['id']; | 320 return parseQueryParams(document.location)['id']; |
300 }, | 321 }, |
301 | 322 |
302 getOptionsQueryParam_: function() { | 323 getOptionsQueryParam_: function() { |
(...skipping 29 matching lines...) Expand all Loading... |
332 focusableNode.getEquivalentElement( | 353 focusableNode.getEquivalentElement( |
333 document.activeElement).focus(); | 354 document.activeElement).focus(); |
334 } | 355 } |
335 } | 356 } |
336 | 357 |
337 node.parentElement.removeChild(node); | 358 node.parentElement.removeChild(node); |
338 // Unregister the removed node from events. | 359 // Unregister the removed node from events. |
339 assertInstanceof(node, ExtensionFocusRow).destroy(); | 360 assertInstanceof(node, ExtensionFocusRow).destroy(); |
340 } | 361 } |
341 } | 362 } |
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 }, | 363 }, |
351 | 364 |
352 /** Updates each row's focusable elements without rebuilding the grid. */ | 365 /** Updates each row's focusable elements without rebuilding the grid. */ |
353 updateFocusableElements: function() { | 366 updateFocusableElements: function() { |
354 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]'); | 367 var rows = document.querySelectorAll('.extension-list-item-wrapper[id]'); |
355 for (var i = 0; i < rows.length; ++i) { | 368 for (var i = 0; i < rows.length; ++i) { |
356 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements(); | 369 assertInstanceof(rows[i], ExtensionFocusRow).updateFocusableElements(); |
357 } | 370 } |
358 }, | 371 }, |
359 | 372 |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1]; | 1071 var nextExt = this.extensions_[this.extensions_.indexOf(extension) + 1]; |
1059 this.createNode_(extension, nextExt ? $(nextExt.id) : null); | 1072 this.createNode_(extension, nextExt ? $(nextExt.id) : null); |
1060 } | 1073 } |
1061 } | 1074 } |
1062 }; | 1075 }; |
1063 | 1076 |
1064 return { | 1077 return { |
1065 ExtensionList: ExtensionList | 1078 ExtensionList: ExtensionList |
1066 }; | 1079 }; |
1067 }); | 1080 }); |
OLD | NEW |