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/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 return; | 28 return; |
29 CancelTabTransition(); | 29 CancelTabTransition(); |
30 } | 30 } |
31 // Start a new transition if the target isn't active already. | 31 // Start a new transition if the target isn't active already. |
32 if (index != tab_strip_model_->active_index()) { | 32 if (index != tab_strip_model_->active_index()) { |
33 // The delay between beginning to hover over a tab and the transition | 33 // The delay between beginning to hover over a tab and the transition |
34 // to that tab taking place. | 34 // to that tab taking place. |
35 const base::TimeDelta kHoverTransitionDelay = | 35 const base::TimeDelta kHoverTransitionDelay = |
36 base::TimeDelta::FromMilliseconds(500); | 36 base::TimeDelta::FromMilliseconds(500); |
37 tab_transition_tab_index_ = index; | 37 tab_transition_tab_index_ = index; |
38 MessageLoop::current()->PostDelayedTask( | 38 base::MessageLoop::current()->PostDelayedTask( |
39 FROM_HERE, base::Bind(&HoverTabSelector::PerformTabTransition, | 39 FROM_HERE, |
40 weak_factory_.GetWeakPtr()), | 40 base::Bind(&HoverTabSelector::PerformTabTransition, |
| 41 weak_factory_.GetWeakPtr()), |
41 kHoverTransitionDelay); | 42 kHoverTransitionDelay); |
42 } | 43 } |
43 } | 44 } |
44 | 45 |
45 void HoverTabSelector::CancelTabTransition() { | 46 void HoverTabSelector::CancelTabTransition() { |
46 weak_factory_.InvalidateWeakPtrs(); | 47 weak_factory_.InvalidateWeakPtrs(); |
47 } | 48 } |
48 | 49 |
49 void HoverTabSelector::PerformTabTransition() { | 50 void HoverTabSelector::PerformTabTransition() { |
50 DCHECK(tab_transition_tab_index_ >= 0 && | 51 DCHECK(tab_transition_tab_index_ >= 0 && |
51 tab_transition_tab_index_ < tab_strip_model_->count()); | 52 tab_transition_tab_index_ < tab_strip_model_->count()); |
52 tab_strip_model_->ActivateTabAt(tab_transition_tab_index_, true); | 53 tab_strip_model_->ActivateTabAt(tab_transition_tab_index_, true); |
53 } | 54 } |
54 | 55 |
OLD | NEW |