| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 show_menu_factory_.InvalidateWeakPtrs(); | 135 show_menu_factory_.InvalidateWeakPtrs(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void ToolbarButton::OnMouseCaptureLost() { | 138 void ToolbarButton::OnMouseCaptureLost() { |
| 139 } | 139 } |
| 140 | 140 |
| 141 void ToolbarButton::OnMouseExited(const ui::MouseEvent& event) { | 141 void ToolbarButton::OnMouseExited(const ui::MouseEvent& event) { |
| 142 // Starting a drag results in a MouseExited, we need to ignore it. | 142 // Starting a drag results in a MouseExited, we need to ignore it. |
| 143 // A right click release triggers an exit event. We want to | 143 // A right click release triggers an exit event. We want to |
| 144 // remain in a PUSHED state until the drop down menu closes. | 144 // remain in a PUSHED state until the drop down menu closes. |
| 145 if (state_ != STATE_DISABLED && !InDrag() && state_ != STATE_PRESSED) | 145 if (state() != STATE_DISABLED && !InDrag() && state() != STATE_PRESSED) |
| 146 SetState(STATE_NORMAL); | 146 SetState(STATE_NORMAL); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { | 149 void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { |
| 150 if (menu_showing_) { | 150 if (menu_showing_) { |
| 151 // While dropdown menu is showing the button should not handle gestures. | 151 // While dropdown menu is showing the button should not handle gestures. |
| 152 event->StopPropagation(); | 152 event->StopPropagation(); |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 | 155 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 ink_drop_delegate()->OnAction(views::InkDropState::DEACTIVATED); | 288 ink_drop_delegate()->OnAction(views::InkDropState::DEACTIVATED); |
| 289 | 289 |
| 290 menu_showing_ = false; | 290 menu_showing_ = false; |
| 291 | 291 |
| 292 // Need to explicitly clear mouse handler so that events get sent | 292 // Need to explicitly clear mouse handler so that events get sent |
| 293 // properly after the menu finishes running. If we don't do this, then | 293 // properly after the menu finishes running. If we don't do this, then |
| 294 // the first click to other parts of the UI is eaten. | 294 // the first click to other parts of the UI is eaten. |
| 295 SetMouseHandler(nullptr); | 295 SetMouseHandler(nullptr); |
| 296 | 296 |
| 297 // Set the state back to normal after the drop down menu is closed. | 297 // Set the state back to normal after the drop down menu is closed. |
| 298 if (state_ != STATE_DISABLED) | 298 if (state() != STATE_DISABLED) |
| 299 SetState(STATE_NORMAL); | 299 SetState(STATE_NORMAL); |
| 300 } | 300 } |
| 301 | 301 |
| 302 const char* ToolbarButton::GetClassName() const { | 302 const char* ToolbarButton::GetClassName() const { |
| 303 return "ToolbarButton"; | 303 return "ToolbarButton"; |
| 304 } | 304 } |
| 305 | 305 |
| 306 gfx::Point ToolbarButton::CalculateInkDropCenter() const { | 306 gfx::Point ToolbarButton::CalculateInkDropCenter() const { |
| 307 return GetLocalBounds().CenterPoint(); | 307 return GetLocalBounds().CenterPoint(); |
| 308 } | 308 } |
| OLD | NEW |