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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_ORDER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_ORDER_CONTROLLER_H_
8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "content/public/common/page_transition_types.h"
11 ///////////////////////////////////////////////////////////////////////////////
12 // TabStripModelOrderController
14 // An object that allows different types of ordering and reselection to be
15 // heuristics plugged into a TabStripModel.
17 class TabStripModelOrderController
: public TabStripModelObserver
{
19 explicit TabStripModelOrderController(TabStripModel
* tabstrip
);
20 virtual ~TabStripModelOrderController();
22 // Determine where to place a newly opened tab by using the supplied
23 // transition and foreground flag to figure out how it was opened.
24 int DetermineInsertionIndex(content::PageTransition transition
,
27 // Determine where to shift selection after a tab is closed.
28 int DetermineNewSelectedIndex(int removed_index
) const;
30 // Overridden from TabStripModelObserver:
31 virtual void ActiveTabChanged(content::WebContents
* old_contents
,
32 content::WebContents
* new_contents
,
37 // Returns a valid index to be selected after the tab at |removing_index| is
38 // closed. If |index| is after |removing_index|, |index| is adjusted to
39 // reflect the fact that |removing_index| is going away.
40 int GetValidIndex(int index
, int removing_index
) const;
42 TabStripModel
* tabstrip_
;
44 DISALLOW_COPY_AND_ASSIGN(TabStripModelOrderController
);
47 #endif // CHROME_BROWSER_UI_TABS_TAB_STRIP_MODEL_ORDER_CONTROLLER_H_