diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-02 01:48:35 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-02 01:48:35 +0000 |
commit | 74f34b094a7b21f0c057f493abee5db30b988592 (patch) | |
tree | f3e7e9169b46331718e9ae7932f9108644dee0db /chrome/browser/views | |
parent | 17b4f9a87ce73e5f6d87c21c5b593cbd23f797fa (diff) | |
download | chromium_src-74f34b094a7b21f0c057f493abee5db30b988592.zip chromium_src-74f34b094a7b21f0c057f493abee5db30b988592.tar.gz chromium_src-74f34b094a7b21f0c057f493abee5db30b988592.tar.bz2 |
Make sure we don't dismiss extension popups when the focus
changes for a child window of the popup, as it is the case
with select popups.
BUG=28110
TEST=Make sure extension popups are still working as expected.
Open an extension popup with a select popup (combo box)
in it. Click on the select to bring up its popup, the
extension popup should stay opened.
Review URL: http://codereview.chromium.org/459005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/browser_actions_container.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/browser_actions_container.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/browser_bubble.h | 8 | ||||
-rw-r--r-- | chrome/browser/views/browser_bubble_win.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.h | 3 |
6 files changed, 31 insertions, 8 deletions
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc index b405906..2ca49a9 100644 --- a/chrome/browser/views/browser_actions_container.cc +++ b/chrome/browser/views/browser_actions_container.cc @@ -459,10 +459,24 @@ void BrowserActionsContainer::BubbleGotFocus(BrowserBubble* bubble) { popup_->host()->render_view_host()->view()->Focus(); } -void BrowserActionsContainer::BubbleLostFocus(BrowserBubble* bubble) { +void BrowserActionsContainer::BubbleLostFocus(BrowserBubble* bubble, + gfx::NativeView focused_view) { if (!popup_) return; +#if defined(OS_WIN) + // Don't hide when we are loosing focus to a child window. This is the case + // with select popups. + // TODO(jcampan): http://crbugs.com/29131 make that work on toolkit views + // so this #if defined can be removed. + gfx::NativeView popup_native_view = popup_->native_view(); + gfx::NativeView parent = focused_view; + while (parent = ::GetParent(parent)) { + if (parent == popup_native_view) + return; + } +#endif + // This is a bit annoying. If you click on the button that generated the // current popup, then we first get this lost focus message, and then // we get the click action. This results in the popup being immediately diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h index 4e3f53b..2499007 100644 --- a/chrome/browser/views/browser_actions_container.h +++ b/chrome/browser/views/browser_actions_container.h @@ -178,7 +178,8 @@ class BrowserActionsContainer : public views::View, virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble); virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble); virtual void BubbleGotFocus(BrowserBubble* bubble); - virtual void BubbleLostFocus(BrowserBubble* bubble); + virtual void BubbleLostFocus(BrowserBubble* bubble, + gfx::NativeView focused_view); // Get clipped width required to precisely fit the browser action icons // given a tentative available width. The minimum size it returns is not diff --git a/chrome/browser/views/browser_bubble.h b/chrome/browser/views/browser_bubble.h index eaf3d0b..f796a22 100644 --- a/chrome/browser/views/browser_bubble.h +++ b/chrome/browser/views/browser_bubble.h @@ -29,7 +29,10 @@ class BrowserBubble { virtual void BubbleGotFocus(BrowserBubble* bubble) {} // Called when the bubble became inactive / lost focus. - virtual void BubbleLostFocus(BrowserBubble* bubble) {} + // |focused_view| is the NativeView getting the focus, it may be NULL if the + // popup was closed programatically. + virtual void BubbleLostFocus(BrowserBubble* bubble, + gfx::NativeView focused_view) {} }; // Note that the bubble will size itself to the preferred size of |view|. @@ -81,6 +84,9 @@ class BrowserBubble { // Resize the bubble to fit the view. void ResizeToView(); + // Returns the NativeView containing that popup. + gfx::NativeView native_view() const { return frame_native_view_; } + protected: // Create the popup widget. virtual void InitPopup(); diff --git a/chrome/browser/views/browser_bubble_win.cc b/chrome/browser/views/browser_bubble_win.cc index 33a57e1..076e4e6 100644 --- a/chrome/browser/views/browser_bubble_win.cc +++ b/chrome/browser/views/browser_bubble_win.cc @@ -32,7 +32,7 @@ class BubbleWidget : public views::WidgetWin { if (IsActive()) { BrowserBubble::Delegate* delegate = bubble_->delegate(); if (delegate) - delegate->BubbleLostFocus(bubble_); + delegate->BubbleLostFocus(bubble_, NULL); } views::WidgetWin::Close(); } @@ -41,7 +41,7 @@ class BubbleWidget : public views::WidgetWin { if (IsActive()) { BrowserBubble::Delegate* delegate = bubble_->delegate(); if (delegate) - delegate->BubbleLostFocus(bubble_); + delegate->BubbleLostFocus(bubble_, NULL); } views::WidgetWin::Hide(); } @@ -57,7 +57,7 @@ class BubbleWidget : public views::WidgetWin { } if (action == WA_INACTIVE && !closed_) { - delegate->BubbleLostFocus(bubble_); + delegate->BubbleLostFocus(bubble_, window); } } diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index c3ec267..b0b9069 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -1463,7 +1463,8 @@ void LocationBarView::PageActionImageView::BubbleBrowserWindowClosing( } void LocationBarView::PageActionImageView::BubbleLostFocus( - BrowserBubble* bubble) { + BrowserBubble* bubble, + gfx::NativeView focused_view) { if (!popup_) return; diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h index 64c937d..85d1d89 100644 --- a/chrome/browser/views/location_bar_view.h +++ b/chrome/browser/views/location_bar_view.h @@ -394,7 +394,8 @@ class LocationBarView : public LocationBar, // Overridden from BrowserBubble::Delegate virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble); - virtual void BubbleLostFocus(BrowserBubble* bubble); + virtual void BubbleLostFocus(BrowserBubble* bubble, + gfx::NativeView focused_view); // Called to notify the PageAction that it should determine whether to be // visible or hidden. |contents| is the TabContents that is active, |url| |