summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-10 19:14:12 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-10 19:14:12 +0000
commit2dd3dc1948312256f1321c0ba0186acffda12fcd (patch)
treeea8f0552cc2b632e71021dbae737b7b04caeb9b9
parentc2b5ed357576bdb64e842794a59fd8c89a95f1bd (diff)
downloadchromium_src-2dd3dc1948312256f1321c0ba0186acffda12fcd.zip
chromium_src-2dd3dc1948312256f1321c0ba0186acffda12fcd.tar.gz
chromium_src-2dd3dc1948312256f1321c0ba0186acffda12fcd.tar.bz2
aura: Fix focus on web contents for popup windows
On Aura when the BrowserView attempts to set focus during its setup it is blocked because this parent BrowserFrameAura isn't yet visible. This means the RenderWidgetHostViewAura doesn't gain focus, so JavaScript calls to element.focus() don't result in being able to type into a field. This was affecting chat apps that open popups for chat sessions. Fixed by calling BrowserView::RestoreFocus() when the browser's window becomes visible. BUG=144342 TEST=existing focus tests, sample pages in bug, manual exercise of focus in location bar and web page during window creation and show/hide during minimize/restore Review URL: https://chromiumcodereview.appspot.com/10908151 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155791 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_aura.cc11
-rw-r--r--chrome/browser/ui/views/frame/browser_frame_aura.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/chrome/browser/ui/views/frame/browser_frame_aura.cc b/chrome/browser/ui/views/frame/browser_frame_aura.cc
index bbea5f0..df46354 100644
--- a/chrome/browser/ui/views/frame/browser_frame_aura.cc
+++ b/chrome/browser/ui/views/frame/browser_frame_aura.cc
@@ -138,6 +138,17 @@ void BrowserFrameAura::OnWindowDestroying() {
views::NativeWidgetAura::OnWindowDestroying();
}
+void BrowserFrameAura::OnWindowTargetVisibilityChanged(bool visible) {
+ // On Aura when the BrowserView is shown it tries to restore focus, but can
+ // be blocked when this parent BrowserFrameAura isn't visible. Therefore we
+ // RestoreFocus() when we become visible, which results in the web contents
+ // being asked to focus, which places focus either in the web contents or in
+ // the location bar as appropriate.
+ if (visible)
+ browser_view_->RestoreFocus();
+ views::NativeWidgetAura::OnWindowTargetVisibilityChanged(visible);
+}
+
////////////////////////////////////////////////////////////////////////////////
// BrowserFrameAura, NativeBrowserFrame implementation:
diff --git a/chrome/browser/ui/views/frame/browser_frame_aura.h b/chrome/browser/ui/views/frame/browser_frame_aura.h
index 7b7f30e..d4e0dbd 100644
--- a/chrome/browser/ui/views/frame/browser_frame_aura.h
+++ b/chrome/browser/ui/views/frame/browser_frame_aura.h
@@ -39,6 +39,7 @@ class BrowserFrameAura : public views::ContextMenuController,
// Overridden from views::NativeWidgetAura:
virtual void OnWindowDestroying() OVERRIDE;
+ virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE;
// Overridden from NativeBrowserFrame:
virtual views::NativeWidget* AsNativeWidget() OVERRIDE;