OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ |
6 #define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ | 6 #define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 class TabContentsWrapper; | 9 class TabContentsWrapper; |
10 class TabStripModel; | 10 class TabStripModel; |
| 11 class TabStripSelectionModel; |
11 | 12 |
12 //////////////////////////////////////////////////////////////////////////////// | 13 //////////////////////////////////////////////////////////////////////////////// |
13 // | 14 // |
14 // TabStripModelObserver | 15 // TabStripModelObserver |
15 // | 16 // |
16 // Objects implement this interface when they wish to be notified of changes | 17 // Objects implement this interface when they wish to be notified of changes |
17 // to the TabStripModel. | 18 // to the TabStripModel. |
18 // | 19 // |
19 // Two major implementers are the TabStrip, which uses notifications sent | 20 // Two major implementers are the TabStrip, which uses notifications sent |
20 // via this interface to update the presentation of the strip, and the Browser | 21 // via this interface to update the presentation of the strip, and the Browser |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // The specified TabContents at |index| is being detached, perhaps to be | 55 // The specified TabContents at |index| is being detached, perhaps to be |
55 // inserted in another TabStripModel. The implementer should take whatever | 56 // inserted in another TabStripModel. The implementer should take whatever |
56 // action is necessary to deal with the TabContents no longer being present. | 57 // action is necessary to deal with the TabContents no longer being present. |
57 virtual void TabDetachedAt(TabContentsWrapper* contents, int index); | 58 virtual void TabDetachedAt(TabContentsWrapper* contents, int index); |
58 | 59 |
59 // The active TabContents is about to change from |old_contents|. | 60 // The active TabContents is about to change from |old_contents|. |
60 // This gives observers a chance to prepare for an impending switch before it | 61 // This gives observers a chance to prepare for an impending switch before it |
61 // happens. | 62 // happens. |
62 virtual void TabDeactivated(TabContentsWrapper* contents); | 63 virtual void TabDeactivated(TabContentsWrapper* contents); |
63 | 64 |
64 // Sent when the selection changes. The previously selected tab is identified | 65 // Sent when the active tab changes. The previously active tab is identified |
65 // by |old_contents| and the newly selected tab by |new_contents|. |index| is | 66 // by |old_contents| and the newly active tab by |new_contents|. |index| is |
66 // the index of |new_contents|. When using multiple selection this may be sent | 67 // the index of |new_contents|. |user_gesture| specifies whether or not this |
67 // even when the active tab has not changed. For example, if the selection is | |
68 // extended this method is invoked to inform observers the selection has | |
69 // changed, but |old_contents| and |new_contents| are the same. If you only | |
70 // care about when the active tab changes, check for when |old_contents| | |
71 // differs from |new_contents|. |user_gesture| specifies whether or not this | |
72 // was done by a user input event (e.g. clicking on a tab, keystroke) or as a | 68 // was done by a user input event (e.g. clicking on a tab, keystroke) or as a |
73 // side-effect of some other function. | 69 // side-effect of some other function. |
74 // | 70 // Note: It is possible for the selection to change while the active tab |
75 // TODO(dpapad): Add TabSelectionChanged method for when the selected tabs | 71 // remains unchanged. For example, control-click may not change the active tab |
76 // change. | 72 // but does change the selection. In this case |ActiveTabChanged| is not sent. |
| 73 // If you care about any changes to the selection, override |
| 74 // TabSelectionChanged. |
77 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, | 75 virtual void ActiveTabChanged(TabContentsWrapper* old_contents, |
78 TabContentsWrapper* new_contents, | 76 TabContentsWrapper* new_contents, |
79 int index, | 77 int index, |
80 bool user_gesture); | 78 bool user_gesture); |
81 | 79 |
| 80 // Sent when the selection changes. More precisely when selected tabs, anchor |
| 81 // tab or active tab change. |old_model| is a snapshot of the selection model |
| 82 // before the change. See also ActiveTabChanged for details. |
| 83 virtual void TabSelectionChanged(const TabStripSelectionModel& old_model); |
| 84 |
82 // The specified TabContents at |from_index| was moved to |to_index|. | 85 // The specified TabContents at |from_index| was moved to |to_index|. |
83 virtual void TabMoved(TabContentsWrapper* contents, | 86 virtual void TabMoved(TabContentsWrapper* contents, |
84 int from_index, | 87 int from_index, |
85 int to_index); | 88 int to_index); |
86 | 89 |
87 // The specified TabContents at |index| changed in some way. |contents| may | 90 // The specified TabContents at |index| changed in some way. |contents| may |
88 // be an entirely different object and the old value is no longer available | 91 // be an entirely different object and the old value is no longer available |
89 // by the time this message is delivered. | 92 // by the time this message is delivered. |
90 // | 93 // |
91 // See TabChangeType for a description of |change_type|. | 94 // See TabChangeType for a description of |change_type|. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 130 |
128 // Invoked when an active/selected tab at |index| is selected again (ie - the | 131 // Invoked when an active/selected tab at |index| is selected again (ie - the |
129 // active/foreground tab is clicked). | 132 // active/foreground tab is clicked). |
130 virtual void ActiveTabClicked(int index); | 133 virtual void ActiveTabClicked(int index); |
131 | 134 |
132 protected: | 135 protected: |
133 virtual ~TabStripModelObserver() {} | 136 virtual ~TabStripModelObserver() {} |
134 }; | 137 }; |
135 | 138 |
136 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ | 139 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_OBSERVER_H_ |
OLD | NEW |