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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 show_menu_factory_.InvalidateWeakPtrs(); | 147 show_menu_factory_.InvalidateWeakPtrs(); |
148 } | 148 } |
149 | 149 |
150 void ToolbarButton::OnMouseCaptureLost() { | 150 void ToolbarButton::OnMouseCaptureLost() { |
151 } | 151 } |
152 | 152 |
153 void ToolbarButton::OnMouseExited(const ui::MouseEvent& event) { | 153 void ToolbarButton::OnMouseExited(const ui::MouseEvent& event) { |
154 // Starting a drag results in a MouseExited, we need to ignore it. | 154 // Starting a drag results in a MouseExited, we need to ignore it. |
155 // A right click release triggers an exit event. We want to | 155 // A right click release triggers an exit event. We want to |
156 // remain in a PUSHED state until the drop down menu closes. | 156 // remain in a PUSHED state until the drop down menu closes. |
157 if (state_ != STATE_DISABLED && !InDrag() && state_ != STATE_PRESSED) | 157 if (state() != STATE_DISABLED && !InDrag() && state() != STATE_PRESSED) |
158 SetState(STATE_NORMAL); | 158 SetState(STATE_NORMAL); |
159 } | 159 } |
160 | 160 |
161 void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { | 161 void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { |
162 if (menu_showing_) { | 162 if (menu_showing_) { |
163 // While dropdown menu is showing the button should not handle gestures. | 163 // While dropdown menu is showing the button should not handle gestures. |
164 event->StopPropagation(); | 164 event->StopPropagation(); |
165 return; | 165 return; |
166 } | 166 } |
167 | 167 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 views::InkDropState::DEACTIVATED); | 339 views::InkDropState::DEACTIVATED); |
340 | 340 |
341 menu_showing_ = false; | 341 menu_showing_ = false; |
342 | 342 |
343 // Need to explicitly clear mouse handler so that events get sent | 343 // Need to explicitly clear mouse handler so that events get sent |
344 // properly after the menu finishes running. If we don't do this, then | 344 // properly after the menu finishes running. If we don't do this, then |
345 // the first click to other parts of the UI is eaten. | 345 // the first click to other parts of the UI is eaten. |
346 SetMouseHandler(nullptr); | 346 SetMouseHandler(nullptr); |
347 | 347 |
348 // Set the state back to normal after the drop down menu is closed. | 348 // Set the state back to normal after the drop down menu is closed. |
349 if (state_ != STATE_DISABLED) | 349 if (state() != STATE_DISABLED) |
350 SetState(STATE_NORMAL); | 350 SetState(STATE_NORMAL); |
351 } | 351 } |
352 | 352 |
353 const char* ToolbarButton::GetClassName() const { | 353 const char* ToolbarButton::GetClassName() const { |
354 return "ToolbarButton"; | 354 return "ToolbarButton"; |
355 } | 355 } |
356 | 356 |
357 gfx::Point ToolbarButton::CalculateInkDropCenter() const { | 357 gfx::Point ToolbarButton::CalculateInkDropCenter() const { |
358 return GetLocalBounds().CenterPoint(); | 358 return GetLocalBounds().CenterPoint(); |
359 } | 359 } |
OLD | NEW |