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. | |
304 if (extensions.length > 0) | |
305 this.onUpdateFinished_(); | |
not at google - send to devlin
2015/04/17 21:50:11
Whether or not there are >0 extensions, the update
hcarmona
2015/04/17 22:43:44
Done.
| |
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 Loading... | |
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 Loading... | |
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 }); |
OLD | NEW |