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

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

Issue 862403006: extensions: fix focus management for all dialogs (not just options). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@classList-fix
Patch Set: kalman@ review Created 5 years, 10 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
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 * The type of the extension data object. The definition is based on 8 * The type of the extension data object. The definition is based on
9 * chrome/browser/ui/webui/extensions/extension_basic_info.cc 9 * chrome/browser/ui/webui/extensions/extension_basic_info.cc
10 * and 10 * and
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 this.data_.extensions.forEach(this.createNode_, this); 126 this.data_.extensions.forEach(this.createNode_, this);
127 127
128 var idToHighlight = this.getIdQueryParam_(); 128 var idToHighlight = this.getIdQueryParam_();
129 if (idToHighlight && $(idToHighlight)) 129 if (idToHighlight && $(idToHighlight))
130 this.scrollToNode_(idToHighlight); 130 this.scrollToNode_(idToHighlight);
131 131
132 var idToOpenOptions = this.getOptionsQueryParam_(); 132 var idToOpenOptions = this.getOptionsQueryParam_();
133 if (idToOpenOptions && $(idToOpenOptions)) 133 if (idToOpenOptions && $(idToOpenOptions))
134 this.showEmbeddedExtensionOptions_(idToOpenOptions, true); 134 this.showEmbeddedExtensionOptions_(idToOpenOptions, true);
135 135
136 if (this.data_.extensions.length == 0) 136 var noExtensions = this.data_.extensions.length == 0;
137 this.classList.add('empty-extension-list'); 137 this.classList.toggle('empty-extension-list', noExtensions);
138 else
139 this.classList.remove('empty-extension-list');
140 }, 138 },
141 139
142 /** 140 /**
143 * Scrolls the page down to the extension node with the given id. 141 * Scrolls the page down to the extension node with the given id.
144 * @param {string} extensionId The id of the extension to scroll to. 142 * @param {string} extensionId The id of the extension to scroll to.
145 * @private 143 * @private
146 */ 144 */
147 scrollToNode_: function(extensionId) { 145 scrollToNode_: function(extensionId) {
148 // Scroll offset should be calculated slightly higher than the actual 146 // Scroll offset should be calculated slightly higher than the actual
149 // offset of the element being scrolled to, so that it ends up not all 147 // offset of the element being scrolled to, so that it ends up not all
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 var extension = this.data_.extensions.filter(function(extension) { 559 var extension = this.data_.extensions.filter(function(extension) {
562 return extension.enabled && extension.id == extensionId; 560 return extension.enabled && extension.id == extensionId;
563 })[0]; 561 })[0];
564 562
565 if (!extension) 563 if (!extension)
566 return; 564 return;
567 565
568 if (scroll) 566 if (scroll)
569 this.scrollToNode_(extensionId); 567 this.scrollToNode_(extensionId);
570 568
571 document.activeElement.blur();
572
573 // Add the options query string. Corner case: the 'options' query string 569 // Add the options query string. Corner case: the 'options' query string
574 // will clobber the 'id' query string if the options link is clicked when 570 // will clobber the 'id' query string if the options link is clicked when
575 // 'id' is in the URL, or if both query strings are in the URL. 571 // 'id' is in the URL, or if both query strings are in the URL.
576 uber.replaceState({}, '?options=' + extensionId); 572 uber.replaceState({}, '?options=' + extensionId);
577 573
574 var overlay = extensions.ExtensionOptionsOverlay.getInstance();
578 var shownCallback = function() { 575 var shownCallback = function() {
576 // This overlay doesn't get focused automatically as <extensionoptions>
577 // is created after the overlay is shown.
579 if (cr.ui.FocusOutlineManager.forDocument(document).visible) 578 if (cr.ui.FocusOutlineManager.forDocument(document).visible)
580 overlay.setInitialFocus(); 579 overlay.setInitialFocus();
581 }; 580 };
582
583 var overlay = extensions.ExtensionOptionsOverlay.getInstance();
584 overlay.setExtensionAndShowOverlay(extensionId, extension.name, 581 overlay.setExtensionAndShowOverlay(extensionId, extension.name,
585 extension.icon, shownCallback); 582 extension.icon, shownCallback);
586 this.optionsShown_ = true; 583 this.optionsShown_ = true;
587 584
588 var self = this; 585 var self = this;
589 $('overlay').addEventListener('cancelOverlay', function f() { 586 $('overlay').addEventListener('cancelOverlay', function f() {
590 // Restore focus instead of just blurring when this page isn't rebuild
591 // crazy. http://crbug.com/450818
592 document.activeElement.blur();
593 self.optionsShown_ = false; 587 self.optionsShown_ = false;
594 $('overlay').removeEventListener('cancelOverlay', f); 588 $('overlay').removeEventListener('cancelOverlay', f);
595 }); 589 });
596 590
597 // TODO(dbeam): guestview's focus is weird. Only when this is called from 591 // TODO(dbeam): why do we need to focus <extensionoptions> before and
598 // within this event handler *and* after the showing animation completes 592 // after its showing animation? Makes very little sense to me.
599 // does this work. 593 overlay.setInitialFocus();
600 shownCallback();
601 }, 594 },
602 }; 595 };
603 596
604 return { 597 return {
605 ExtensionsList: ExtensionsList 598 ExtensionsList: ExtensionsList
606 }; 599 };
607 }); 600 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698