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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
// 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_OBSERVER_H_
#define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_
#pragma once
class TabContents;
class TabStripModel;
////////////////////////////////////////////////////////////////////////////////
//
// TabStripModelObserver
//
// Objects implement this interface when they wish to be notified of changes
// to the TabStripModel.
//
// Two major implementers are the TabStrip, which uses notifications sent
// via this interface to update the presentation of the strip, and the Browser
// object, which updates bookkeeping and shows/hides individual TabContentses.
//
// Register your TabStripModelObserver with the TabStripModel using its
// Add/RemoveObserver methods.
//
////////////////////////////////////////////////////////////////////////////////
class TabStripModelObserver {
public:
// Enumeration of the possible values supplied to TabChangedAt.
enum TabChangeType {
// Only the loading state changed.
LOADING_ONLY,
// Only the title changed and page isn't loading.
TITLE_NOT_LOADING,
// Change not characterized by LOADING_ONLY or TITLE_NOT_LOADING.
ALL
};
// A new TabContents was inserted into the TabStripModel at the specified
// index. |foreground| is whether or not it was opened in the foreground
// (selected).
virtual void TabInsertedAt(TabContents* contents,
int index,
bool foreground);
// The specified TabContents at |index| is being closed (and eventually
// destroyed). |tab_strip_model| is the TabStripModel the tab was part of.
virtual void TabClosingAt(TabStripModel* tab_strip_model,
TabContents* contents,
int index);
// The specified TabContents at |index| is being detached, perhaps to be
// inserted in another TabStripModel. The implementer should take whatever
// action is necessary to deal with the TabContents no longer being present.
virtual void TabDetachedAt(TabContents* contents, int index);
// The selected TabContents is about to change from |old_contents| at |index|.
// This gives observers a chance to prepare for an impending switch before it
// happens.
virtual void TabDeselectedAt(TabContents* contents, int index);
// The selected TabContents changed from |old_contents| to |new_contents| at
// |index|. |user_gesture| specifies whether or not this was done by a user
// input event (e.g. clicking on a tab, keystroke) or as a side-effect of
// some other function.
virtual void TabSelectedAt(TabContents* old_contents,
TabContents* new_contents,
int index,
bool user_gesture);
// The specified TabContents at |from_index| was moved to |to_index|.
virtual void TabMoved(TabContents* contents,
int from_index,
int to_index);
// The specified TabContents at |index| changed in some way. |contents| may
// be an entirely different object and the old value is no longer available
// by the time this message is delivered.
//
// See TabChangeType for a description of |change_type|.
virtual void TabChangedAt(TabContents* contents,
int index,
TabChangeType change_type);
// The tab contents was replaced at the specified index. This is invoked when
// a tab becomes phantom. See description of phantom tabs in class description
// of TabStripModel for details.
virtual void TabReplacedAt(TabContents* old_contents,
TabContents* new_contents,
int index);
// Invoked when the pinned state of a tab changes. This is not invoked if the
// tab ends up moving as a result of the mini state changing.
// See note in TabMiniStateChanged as to how this relates to
// TabMiniStateChanged.
virtual void TabPinnedStateChanged(TabContents* contents, int index);
// Invoked if the mini state of a tab changes. This is not invoked if the
// tab ends up moving as a result of the mini state changing.
// NOTE: this is sent when the pinned state of a non-app tab changes and is
// sent in addition to TabPinnedStateChanged. UI code typically need not care
// about TabPinnedStateChanged, but instead this.
virtual void TabMiniStateChanged(TabContents* contents, int index);
// Invoked when the blocked state of a tab changes.
// NOTE: This is invoked when a tab becomes blocked/unblocked by a tab modal
// window.
virtual void TabBlockedStateChanged(TabContents* contents, int index);
// The TabStripModel now no longer has any phantom tabs. The implementer may
// use this as a trigger to try and close the window containing the
// TabStripModel, for example...
virtual void TabStripEmpty();
// Sent when the tabstrip model is about to be deleted and any reference held
// must be dropped.
virtual void TabStripModelDeleted();
protected:
virtual ~TabStripModelObserver() {}
};
#endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_
|