diff options
-rw-r--r-- | chrome/browser/extensions/extension_popup_host.cc | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_popup_host.h | 3 | ||||
-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 |
8 files changed, 35 insertions, 10 deletions
diff --git a/chrome/browser/extensions/extension_popup_host.cc b/chrome/browser/extensions/extension_popup_host.cc index 20dd1a1..f263494 100644 --- a/chrome/browser/extensions/extension_popup_host.cc +++ b/chrome/browser/extensions/extension_popup_host.cc @@ -55,7 +55,8 @@ void ExtensionPopupHost::BubbleBrowserWindowClosing(BrowserBubble* bubble) { void ExtensionPopupHost::BubbleGotFocus(BrowserBubble* bubble) { } -void ExtensionPopupHost::BubbleLostFocus(BrowserBubble* bubble) { +void ExtensionPopupHost::BubbleLostFocus(BrowserBubble* bubble, + gfx::NativeView focused_view) { // TODO(twiz): Dismiss the pop-up upon loss of focus of the bubble, but not // if the focus is transitioning to the host which owns the popup! // DismissPopup(); diff --git a/chrome/browser/extensions/extension_popup_host.h b/chrome/browser/extensions/extension_popup_host.h index 4e38470..f8e97a0 100644 --- a/chrome/browser/extensions/extension_popup_host.h +++ b/chrome/browser/extensions/extension_popup_host.h @@ -74,7 +74,8 @@ class ExtensionPopupHost : // NOLINT virtual void BubbleGotFocus(BrowserBubble* bubble); // Called when the bubble became inactive / lost focus. - virtual void BubbleLostFocus(BrowserBubble* bubble); + virtual void BubbleLostFocus(BrowserBubble* bubble, + gfx::NativeView focused_view); #endif // defined(TOOLKIT_VIEWS) // NotificationObserver implementation. 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| |