From 31f2db3de431af43175c912298addbb4f7465c50 Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Wed, 18 Nov 2009 17:36:33 +0000 Subject: Fixes several focus issue with popup in the extensions' browser actions: - when opening a browser action popup, it gets the focus. - tab traversal now works in the popup - pressing esc closes the popup (if the keyboard event is not processed by the page) BUG=22654, 28087, 28086 TEST=Create an extension with a browser extension that shows a popup. Make the popup so that it has a textfield (that gets focused when the popup show) and a button. Install the extension. Open the popup, the textfield should have focus. Press tab, the focus should go to the button. Press Esc, the popup should be closed. Review URL: http://codereview.chromium.org/402036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32335 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/views/extensions/extension_view.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'chrome/browser/views/extensions/extension_view.cc') diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc index c0118ba..7945307 100644 --- a/chrome/browser/views/extensions/extension_view.cc +++ b/chrome/browser/views/extensions/extension_view.cc @@ -22,6 +22,11 @@ ExtensionView::ExtensionView(ExtensionHost* host, Browser* browser) container_(NULL), is_clipped_(false) { host_->set_view(this); + + // This view needs to be focusable so it can act as the focused view for the + // focus manager. This is required to have SkipDefaultKeyEventProcessing + // called so the tab key events are forwarded to the renderer. + SetFocusable(true); } ExtensionView::~ExtensionView() { @@ -170,6 +175,12 @@ void ExtensionView::PreferredSizeChanged() { } } +bool ExtensionView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { + // Let the tab key event be processed by the renderer (instead of moving the + // focus to the next focusable view). + return (e.GetKeyCode() == base::VKEY_TAB); +} + void ExtensionView::HandleMouseEvent() { if (container_) container_->OnExtensionMouseEvent(this); -- cgit v1.1