blob: 5ecaa2c948b65896a4c3ca068f27bc78cb7771d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_ORDER_CONTROLLER_H_
#define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_ORDER_CONTROLLER_H_
#pragma once
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/common/page_transition_types.h"
class TabContentsWrapper;
///////////////////////////////////////////////////////////////////////////////
// TabStripModelOrderController
//
// An object that allows different types of ordering and reselection to be
// heuristics plugged into a TabStripModel.
//
class TabStripModelOrderController : public TabStripModelObserver {
public:
explicit TabStripModelOrderController(TabStripModel* tabstrip);
virtual ~TabStripModelOrderController();
// Sets the insertion policy. Default is INSERT_AFTER.
void set_insertion_policy(TabStripModel::InsertionPolicy policy) {
insertion_policy_ = policy;
}
TabStripModel::InsertionPolicy insertion_policy() const {
return insertion_policy_;
}
// Determine where to place a newly opened tab by using the supplied
// transition and foreground flag to figure out how it was opened.
int DetermineInsertionIndex(TabContentsWrapper* new_contents,
PageTransition::Type transition,
bool foreground);
// Returns the index to append tabs at.
int DetermineInsertionIndexForAppending();
// Determine where to shift selection after a tab is closed.
int DetermineNewSelectedIndex(int removed_index) const;
// Overridden from TabStripModelObserver:
virtual void TabSelectedAt(TabContentsWrapper* old_contents,
TabContentsWrapper* new_contents,
int index,
bool user_gesture);
private:
// Returns a valid index to be selected after the tab at |removing_index| is
// closed. If |index| is after |removing_index|, |index| is adjusted to
// reflect the fact that |removing_index| is going away.
int GetValidIndex(int index, int removing_index) const;
TabStripModel* tabstrip_;
TabStripModel::InsertionPolicy insertion_policy_;
DISALLOW_COPY_AND_ASSIGN(TabStripModelOrderController);
};
#endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_ORDER_CONTROLLER_H_
|