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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 var EventType = chrome.developerPrivate.EventType; | 266 var EventType = chrome.developerPrivate.EventType; |
| 267 switch (eventData.event_type) { | 267 switch (eventData.event_type) { |
| 268 case EventType.VIEW_REGISTERED: | 268 case EventType.VIEW_REGISTERED: |
| 269 case EventType.VIEW_UNREGISTERED: | 269 case EventType.VIEW_UNREGISTERED: |
| 270 case EventType.INSTALLED: | 270 case EventType.INSTALLED: |
| 271 case EventType.LOADED: | 271 case EventType.LOADED: |
| 272 case EventType.UNLOADED: | 272 case EventType.UNLOADED: |
| 273 case EventType.ERROR_ADDED: | 273 case EventType.ERROR_ADDED: |
| 274 case EventType.ERRORS_REMOVED: | 274 case EventType.ERRORS_REMOVED: |
| 275 case EventType.PREFS_CHANGED: | 275 case EventType.PREFS_CHANGED: |
| 276 if (eventData.extensionInfo) | 276 if (eventData.extensionInfo) { |
| 277 this.updateExtension_(eventData.extensionInfo); | 277 this.updateExtension_(eventData.extensionInfo); |
| 278 this.focusGrid_.ensureRowActive(); | |
| 279 } | |
| 278 break; | 280 break; |
| 279 case EventType.UNINSTALLED: | 281 case EventType.UNINSTALLED: |
| 280 var index = this.getIndexOfExtension_(eventData.item_id); | 282 var index = this.getIndexOfExtension_(eventData.item_id); |
| 281 this.extensions_.splice(index, 1); | 283 this.extensions_.splice(index, 1); |
| 282 var childNode = $(eventData.item_id); | 284 var childNode = $(eventData.item_id); |
| 283 childNode.parentNode.removeChild(childNode); | 285 childNode.parentNode.removeChild(childNode); |
| 286 this.focusGrid_.removeRow(assertInstanceof(childNode, | |
| 287 ExtensionFocusRow)); | |
| 288 this.focusGrid_.ensureRowActive(); | |
| 284 break; | 289 break; |
| 285 default: | 290 default: |
| 286 assertNotReached(); | 291 assertNotReached(); |
| 287 } | 292 } |
| 288 | 293 |
| 289 if (eventData.event_type == EventType.UNLOADED) | 294 if (eventData.event_type == EventType.UNLOADED) |
| 290 this.hideEmbeddedExtensionOptions_(eventData.item_id); | 295 this.hideEmbeddedExtensionOptions_(eventData.item_id); |
| 291 | 296 |
| 292 if (eventData.event_type == EventType.INSTALLED || | 297 if (eventData.event_type == EventType.INSTALLED || |
| 293 eventData.event_type == EventType.UNINSTALLED) { | 298 eventData.event_type == EventType.UNINSTALLED) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 | 387 |
| 383 getOptionsQueryParam_: function() { | 388 getOptionsQueryParam_: function() { |
| 384 return parseQueryParams(document.location)['options']; | 389 return parseQueryParams(document.location)['options']; |
| 385 }, | 390 }, |
| 386 | 391 |
| 387 /** | 392 /** |
| 388 * Creates or updates all extension items from scratch. | 393 * Creates or updates all extension items from scratch. |
| 389 * @private | 394 * @private |
| 390 */ | 395 */ |
| 391 showExtensionNodes_: function() { | 396 showExtensionNodes_: function() { |
| 392 // Remove the rows from |focusGrid_| without destroying them. | |
| 393 this.focusGrid_.rows.length = 0; | |
|
Dan Beam
2015/05/12 01:28:42
why could we just clear this but can't now?
hcarmona
2015/05/12 02:00:47
This function used to be called every time the gri
| |
| 394 | |
| 395 // Any node that is not updated will be removed. | 397 // Any node that is not updated will be removed. |
| 396 var seenIds = []; | 398 var seenIds = []; |
| 397 | 399 |
| 398 // Iterate over the extension data and add each item to the list. | 400 // Iterate over the extension data and add each item to the list. |
| 399 this.extensions_.forEach(function(extension) { | 401 this.extensions_.forEach(function(extension) { |
| 400 seenIds.push(extension.id); | 402 seenIds.push(extension.id); |
| 401 this.updateExtension_(extension); | 403 this.updateExtension_(extension); |
| 402 }, this); | 404 }, this); |
| 403 this.focusGrid_.ensureRowActive(); | 405 this.focusGrid_.ensureRowActive(); |
| 404 | 406 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 662 // The path, if provided by unpacked extension. | 664 // The path, if provided by unpacked extension. |
| 663 row.setupColumn('.load-path a:first-of-type', 'dev-loadPath', 'click', | 665 row.setupColumn('.load-path a:first-of-type', 'dev-loadPath', 'click', |
| 664 function(e) { | 666 function(e) { |
| 665 chrome.developerPrivate.showPath(extension.id); | 667 chrome.developerPrivate.showPath(extension.id); |
| 666 e.preventDefault(); | 668 e.preventDefault(); |
| 667 }); | 669 }); |
| 668 | 670 |
| 669 // Maintain the order that nodes should be in when creating as well as | 671 // Maintain the order that nodes should be in when creating as well as |
| 670 // when adding only one new row. | 672 // when adding only one new row. |
| 671 this.insertBefore(row, nextNode); | 673 this.insertBefore(row, nextNode); |
| 674 var nextRow = null; | |
| 675 if (nextNode) | |
| 676 nextRow = assertInstanceof(nextNode, ExtensionFocusRow); | |
| 677 this.focusGrid_.addRowBefore(row, nextRow); | |
| 672 this.updateNode_(extension, row); | 678 this.updateNode_(extension, row); |
|
Dan Beam
2015/05/12 01:28:42
needs more \n
hcarmona
2015/05/12 02:00:47
Done.
| |
| 673 }, | 679 }, |
| 674 | 680 |
| 675 /** | 681 /** |
| 676 * Updates an HTML element for the extension metadata given in |extension|. | 682 * Updates an HTML element for the extension metadata given in |extension|. |
| 677 * @param {!ExtensionInfo} extension A dictionary of extension metadata. | 683 * @param {!ExtensionInfo} extension A dictionary of extension metadata. |
| 678 * @param {!ExtensionFocusRow} row The node that is being updated. | 684 * @param {!ExtensionFocusRow} row The node that is being updated. |
| 679 * @private | 685 * @private |
| 680 */ | 686 */ |
| 681 updateNode_: function(extension, row) { | 687 updateNode_: function(extension, row) { |
| 682 var isActive = | 688 var isActive = |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1018 // Scroll beneath the fixed header so that the extension is not | 1024 // Scroll beneath the fixed header so that the extension is not |
| 1019 // obscured. | 1025 // obscured. |
| 1020 var topScroll = row.offsetTop - $('page-header').offsetHeight; | 1026 var topScroll = row.offsetTop - $('page-header').offsetHeight; |
| 1021 var pad = parseInt(window.getComputedStyle(row, null).marginTop, 10); | 1027 var pad = parseInt(window.getComputedStyle(row, null).marginTop, 10); |
| 1022 if (!isNaN(pad)) | 1028 if (!isNaN(pad)) |
| 1023 topScroll -= pad / 2; | 1029 topScroll -= pad / 2; |
| 1024 setScrollTopForDocument(document, topScroll); | 1030 setScrollTopForDocument(document, topScroll); |
| 1025 } | 1031 } |
| 1026 | 1032 |
| 1027 row.updateFocusableElements(); | 1033 row.updateFocusableElements(); |
| 1028 this.focusGrid_.addRow(row); | |
| 1029 }, | 1034 }, |
| 1030 | 1035 |
| 1031 /** | 1036 /** |
| 1032 * Updates an element's textContent. | 1037 * Updates an element's textContent. |
| 1033 * @param {Element} node Ancestor of the element specified by |query|. | 1038 * @param {Element} node Ancestor of the element specified by |query|. |
| 1034 * @param {string} query A query to select an element in |node|. | 1039 * @param {string} query A query to select an element in |node|. |
| 1035 * @param {string} textContent | 1040 * @param {string} textContent |
| 1036 * @private | 1041 * @private |
| 1037 */ | 1042 */ |
| 1038 setText_: function(node, query, textContent) { | 1043 setText_: function(node, query, textContent) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1155 this.createNode_(extension, nextExt ? $(nextExt.id) : null); | 1160 this.createNode_(extension, nextExt ? $(nextExt.id) : null); |
| 1156 } | 1161 } |
| 1157 } | 1162 } |
| 1158 }; | 1163 }; |
| 1159 | 1164 |
| 1160 return { | 1165 return { |
| 1161 ExtensionList: ExtensionList, | 1166 ExtensionList: ExtensionList, |
| 1162 ExtensionListDelegate: ExtensionListDelegate | 1167 ExtensionListDelegate: ExtensionListDelegate |
| 1163 }; | 1168 }; |
| 1164 }); | 1169 }); |
| OLD | NEW |