Home | History | Annotate | Download | only in tabs
      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.
      4 
      5 #ifndef CHROME_BROWSER_UI_TABS_HOVER_TAB_SELECTOR_H_
      6 #define CHROME_BROWSER_UI_TABS_HOVER_TAB_SELECTOR_H_
      7 
      8 #include "base/memory/weak_ptr.h"
      9 
     10 class TabStripModel;
     11 
     12 // Helper class to perform "spring-loaded" tab transitions. Manages
     13 // the lifecycle of delayed tab transition tasks.
     14 class HoverTabSelector {
     15  public:
     16   explicit HoverTabSelector(TabStripModel* tab_strip_model);
     17   ~HoverTabSelector();
     18 
     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);
     24 
     25   // Cancel a pending tab transition. No-op if there is no pending transition.
     26   void CancelTabTransition();
     27 
     28  private:
     29   // Performs the tab transition.
     30   void PerformTabTransition();
     31 
     32   // Model of the tab strip on which this class operates.
     33   TabStripModel* tab_strip_model_;
     34 
     35   // The model index of the tab to transition to.
     36   int tab_transition_tab_index_;
     37 
     38   // Factory for creating tab transition tasks.
     39   base::WeakPtrFactory<HoverTabSelector> weak_factory_;
     40 
     41   DISALLOW_COPY_AND_ASSIGN(HoverTabSelector);
     42 };
     43 
     44 #endif  // CHROME_BROWSER_UI_TABS_HOVER_TAB_SELECTOR_H_
     45 
     46