| 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/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (IsTriggerableEvent(event) && enabled() && ShouldShowMenu() && | 63 if (IsTriggerableEvent(event) && enabled() && ShouldShowMenu() && |
| 64 HitTestPoint(event.location())) { | 64 HitTestPoint(event.location())) { |
| 65 // Store the y pos of the mouse coordinates so we can use them later to | 65 // Store the y pos of the mouse coordinates so we can use them later to |
| 66 // determine if the user dragged the mouse down (which should pop up the | 66 // determine if the user dragged the mouse down (which should pop up the |
| 67 // drag down menu immediately, instead of waiting for the timer) | 67 // drag down menu immediately, instead of waiting for the timer) |
| 68 y_position_on_lbuttondown_ = event.y(); | 68 y_position_on_lbuttondown_ = event.y(); |
| 69 | 69 |
| 70 // Schedule a task that will show the menu. | 70 // Schedule a task that will show the menu. |
| 71 const int kMenuTimerDelay = 500; | 71 const int kMenuTimerDelay = 500; |
| 72 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 72 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 73 FROM_HERE, base::Bind(&ToolbarButton::ShowDropDownMenu, | 73 FROM_HERE, |
| 74 show_menu_factory_.GetWeakPtr(), | 74 base::BindOnce(&ToolbarButton::ShowDropDownMenu, |
| 75 ui::GetMenuSourceTypeForEvent(event)), | 75 show_menu_factory_.GetWeakPtr(), |
| 76 ui::GetMenuSourceTypeForEvent(event)), |
| 76 base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); | 77 base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); |
| 77 } | 78 } |
| 78 | 79 |
| 79 return LabelButton::OnMousePressed(event); | 80 return LabelButton::OnMousePressed(event); |
| 80 } | 81 } |
| 81 | 82 |
| 82 bool ToolbarButton::OnMouseDragged(const ui::MouseEvent& event) { | 83 bool ToolbarButton::OnMouseDragged(const ui::MouseEvent& event) { |
| 83 bool result = LabelButton::OnMouseDragged(event); | 84 bool result = LabelButton::OnMouseDragged(event); |
| 84 | 85 |
| 85 if (show_menu_factory_.HasWeakPtrs()) { | 86 if (show_menu_factory_.HasWeakPtrs()) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 if (state() != STATE_DISABLED) | 231 if (state() != STATE_DISABLED) |
| 231 SetState(STATE_NORMAL); | 232 SetState(STATE_NORMAL); |
| 232 | 233 |
| 233 menu_runner_.reset(); | 234 menu_runner_.reset(); |
| 234 menu_model_adapter_.reset(); | 235 menu_model_adapter_.reset(); |
| 235 } | 236 } |
| 236 | 237 |
| 237 const char* ToolbarButton::GetClassName() const { | 238 const char* ToolbarButton::GetClassName() const { |
| 238 return "ToolbarButton"; | 239 return "ToolbarButton"; |
| 239 } | 240 } |
| OLD | NEW |