1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_TABS_HOVER_TAB_SELECTOR_H_
6 #define CHROME_BROWSER_UI_TABS_HOVER_TAB_SELECTOR_H_
8 #include "base/memory/weak_ptr.h"
12 // Helper class to perform "spring-loaded" tab transitions. Manages
13 // the lifecycle of delayed tab transition tasks.
14 class HoverTabSelector
{
16 explicit HoverTabSelector(TabStripModel
* tab_strip_model
);
19 // Begin a delayed tab transition to the tab at |index|. Only starts
20 // the transition if the specified tab is not active and there isn't
21 // already a transition to it scheduled. Cancels the pending transition
22 // to any other tab, if there is one.
23 void StartTabTransition(int index
);
25 // Cancel a pending tab transition. No-op if there is no pending transition.
26 void CancelTabTransition();
29 // Performs the tab transition.
30 void PerformTabTransition();
32 // Model of the tab strip on which this class operates.
33 TabStripModel
* tab_strip_model_
;
35 // The model index of the tab to transition to.
36 int tab_transition_tab_index_
;
38 // Factory for creating tab transition tasks.
39 base::WeakPtrFactory
<HoverTabSelector
> weak_factory_
;
41 DISALLOW_COPY_AND_ASSIGN(HoverTabSelector
);
44 #endif // CHROME_BROWSER_UI_TABS_HOVER_TAB_SELECTOR_H_