Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/resources/extensions/extension_list.js

Issue 1128953004: Fix regression where rows could become non-focusable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply feedback Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/focus_grid.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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;
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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
672 this.updateNode_(extension, row); 674 this.updateNode_(extension, row);
675
676 var nextRow = null;
677 if (nextNode)
678 nextRow = assertInstanceof(nextNode, ExtensionFocusRow);
679
680 this.focusGrid_.addRowBefore(row, nextRow);
673 }, 681 },
674 682
675 /** 683 /**
676 * Updates an HTML element for the extension metadata given in |extension|. 684 * Updates an HTML element for the extension metadata given in |extension|.
677 * @param {!ExtensionInfo} extension A dictionary of extension metadata. 685 * @param {!ExtensionInfo} extension A dictionary of extension metadata.
678 * @param {!ExtensionFocusRow} row The node that is being updated. 686 * @param {!ExtensionFocusRow} row The node that is being updated.
679 * @private 687 * @private
680 */ 688 */
681 updateNode_: function(extension, row) { 689 updateNode_: function(extension, row) {
682 var isActive = 690 var isActive =
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 // Scroll beneath the fixed header so that the extension is not 1026 // Scroll beneath the fixed header so that the extension is not
1019 // obscured. 1027 // obscured.
1020 var topScroll = row.offsetTop - $('page-header').offsetHeight; 1028 var topScroll = row.offsetTop - $('page-header').offsetHeight;
1021 var pad = parseInt(window.getComputedStyle(row, null).marginTop, 10); 1029 var pad = parseInt(window.getComputedStyle(row, null).marginTop, 10);
1022 if (!isNaN(pad)) 1030 if (!isNaN(pad))
1023 topScroll -= pad / 2; 1031 topScroll -= pad / 2;
1024 setScrollTopForDocument(document, topScroll); 1032 setScrollTopForDocument(document, topScroll);
1025 } 1033 }
1026 1034
1027 row.updateFocusableElements(); 1035 row.updateFocusableElements();
1028 this.focusGrid_.addRow(row);
1029 }, 1036 },
1030 1037
1031 /** 1038 /**
1032 * Updates an element's textContent. 1039 * Updates an element's textContent.
1033 * @param {Element} node Ancestor of the element specified by |query|. 1040 * @param {Element} node Ancestor of the element specified by |query|.
1034 * @param {string} query A query to select an element in |node|. 1041 * @param {string} query A query to select an element in |node|.
1035 * @param {string} textContent 1042 * @param {string} textContent
1036 * @private 1043 * @private
1037 */ 1044 */
1038 setText_: function(node, query, textContent) { 1045 setText_: function(node, query, textContent) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 this.createNode_(extension, nextExt ? $(nextExt.id) : null); 1162 this.createNode_(extension, nextExt ? $(nextExt.id) : null);
1156 } 1163 }
1157 } 1164 }
1158 }; 1165 };
1159 1166
1160 return { 1167 return {
1161 ExtensionList: ExtensionList, 1168 ExtensionList: ExtensionList,
1162 ExtensionListDelegate: ExtensionListDelegate 1169 ExtensionListDelegate: ExtensionListDelegate
1163 }; 1170 };
1164 }); 1171 });
OLDNEW
« no previous file with comments | « no previous file | ui/webui/resources/js/cr/ui/focus_grid.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698