Index: chrome/browser/ui/views/location_bar/zoom_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/zoom_view.cc b/chrome/browser/ui/views/location_bar/zoom_view.cc |
index 0ab6b72f98a4483e0beb796e085308a4726532af..4e9d6ad97af56f80c808d1d5b6a0c28099178916 100644 |
--- a/chrome/browser/ui/views/location_bar/zoom_view.cc |
+++ b/chrome/browser/ui/views/location_bar/zoom_view.cc |
@@ -17,7 +17,8 @@ |
#include "ui/gfx/size.h" |
ZoomView::ZoomView(LocationBarView::Delegate* location_bar_delegate) |
- : location_bar_delegate_(location_bar_delegate) { |
+ : location_bar_delegate_(location_bar_delegate), |
+ was_bubble_showing_(false) { |
SetAccessibilityFocusable(true); |
Update(NULL); |
} |
@@ -52,13 +53,23 @@ bool ZoomView::GetTooltipText(const gfx::Point& p, |
} |
bool ZoomView::OnMousePressed(const ui::MouseEvent& event) { |
+ // The Zoom bubble has its own widget. By the time this code is reached, it's |
+ // already lost activation and is closing as mouse presses on other widgets |
+ // immediately call Close(). |
+ was_bubble_showing_ = ZoomBubbleView::IsClosing(); |
+ |
// Do nothing until mouse is released. |
return true; |
} |
void ZoomView::OnMouseReleased(const ui::MouseEvent& event) { |
+ if (was_bubble_showing_) { |
+ was_bubble_showing_ = false; |
+ return; |
+ } |
+ |
if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) |
- ActivateBubble(); |
+ ToggleBubble(); |
} |
bool ZoomView::OnKeyPressed(const ui::KeyEvent& event) { |
@@ -67,17 +78,20 @@ bool ZoomView::OnKeyPressed(const ui::KeyEvent& event) { |
return false; |
} |
- ActivateBubble(); |
+ ToggleBubble(); |
return true; |
} |
void ZoomView::OnGestureEvent(ui::GestureEvent* event) { |
if (event->type() == ui::ET_GESTURE_TAP) { |
- ActivateBubble(); |
+ ToggleBubble(); |
event->SetHandled(); |
} |
} |
-void ZoomView::ActivateBubble() { |
- ZoomBubbleView::ShowBubble(location_bar_delegate_->GetWebContents(), false); |
+void ZoomView::ToggleBubble() { |
+ if (ZoomBubbleView::IsShowing()) |
+ ZoomBubbleView::CloseBubble(); |
+ else |
+ ZoomBubbleView::ShowBubble(location_bar_delegate_->GetWebContents(), false); |
} |