OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tabs/hover_tab_selector.h" | 5 #include "chrome/browser/ui/tabs/hover_tab_selector.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 CancelTabTransition(); | 31 CancelTabTransition(); |
32 } | 32 } |
33 // Start a new transition if the target isn't active already. | 33 // Start a new transition if the target isn't active already. |
34 if (index != tab_strip_model_->active_index()) { | 34 if (index != tab_strip_model_->active_index()) { |
35 // The delay between beginning to hover over a tab and the transition | 35 // The delay between beginning to hover over a tab and the transition |
36 // to that tab taking place. | 36 // to that tab taking place. |
37 const base::TimeDelta kHoverTransitionDelay = | 37 const base::TimeDelta kHoverTransitionDelay = |
38 base::TimeDelta::FromMilliseconds(500); | 38 base::TimeDelta::FromMilliseconds(500); |
39 tab_transition_tab_index_ = index; | 39 tab_transition_tab_index_ = index; |
40 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 40 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
41 FROM_HERE, base::Bind(&HoverTabSelector::PerformTabTransition, | 41 FROM_HERE, |
42 weak_factory_.GetWeakPtr()), | 42 base::BindOnce(&HoverTabSelector::PerformTabTransition, |
| 43 weak_factory_.GetWeakPtr()), |
43 kHoverTransitionDelay); | 44 kHoverTransitionDelay); |
44 } | 45 } |
45 } | 46 } |
46 | 47 |
47 void HoverTabSelector::CancelTabTransition() { | 48 void HoverTabSelector::CancelTabTransition() { |
48 weak_factory_.InvalidateWeakPtrs(); | 49 weak_factory_.InvalidateWeakPtrs(); |
49 } | 50 } |
50 | 51 |
51 void HoverTabSelector::PerformTabTransition() { | 52 void HoverTabSelector::PerformTabTransition() { |
52 DCHECK(tab_transition_tab_index_ >= 0 && | 53 DCHECK(tab_transition_tab_index_ >= 0 && |
53 tab_transition_tab_index_ < tab_strip_model_->count()); | 54 tab_transition_tab_index_ < tab_strip_model_->count()); |
54 tab_strip_model_->ActivateTabAt(tab_transition_tab_index_, true); | 55 tab_strip_model_->ActivateTabAt(tab_transition_tab_index_, true); |
55 } | 56 } |
56 | 57 |
OLD | NEW |