OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_H_ | 5 #ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ |
6 #define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ | 6 #define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "chrome/common/notification_registrar.h" | 11 #include "chrome/common/notification_registrar.h" |
(...skipping 28 matching lines...) Expand all Loading... |
40 // Add/RemoveObserver methods. | 40 // Add/RemoveObserver methods. |
41 // | 41 // |
42 //////////////////////////////////////////////////////////////////////////////// | 42 //////////////////////////////////////////////////////////////////////////////// |
43 class TabStripModelObserver { | 43 class TabStripModelObserver { |
44 public: | 44 public: |
45 // A new TabContents was inserted into the TabStripModel at the specified | 45 // A new TabContents was inserted into the TabStripModel at the specified |
46 // index. |foreground| is whether or not it was opened in the foreground | 46 // index. |foreground| is whether or not it was opened in the foreground |
47 // (selected). | 47 // (selected). |
48 virtual void TabInsertedAt(TabContents* contents, | 48 virtual void TabInsertedAt(TabContents* contents, |
49 int index, | 49 int index, |
50 bool foreground) {} | 50 bool foreground) { } |
51 | 51 |
52 // The specified TabContents at |index| is being closed (and eventually | 52 // The specified TabContents at |index| is being closed (and eventually |
53 // destroyed). | 53 // destroyed). |
54 virtual void TabClosingAt(TabContents* contents, int index) {} | 54 virtual void TabClosingAt(TabContents* contents, int index) { } |
55 | 55 |
56 // The specified TabContents at |index| is being detached, perhaps to be | 56 // The specified TabContents at |index| is being detached, perhaps to be |
57 // inserted in another TabStripModel. The implementer should take whatever | 57 // inserted in another TabStripModel. The implementer should take whatever |
58 // action is necessary to deal with the TabContents no longer being present. | 58 // action is necessary to deal with the TabContents no longer being present. |
59 virtual void TabDetachedAt(TabContents* contents, int index) {} | 59 virtual void TabDetachedAt(TabContents* contents, int index) { } |
60 | 60 |
61 // The selected TabContents is about to change from |old_contents| at |index|. | 61 // The selected TabContents is about to change from |old_contents| at |index|. |
62 // This gives observers a chance to prepare for an impending switch before it | 62 // This gives observers a chance to prepare for an impending switch before it |
63 // happens. | 63 // happens. |
64 virtual void TabDeselectedAt(TabContents* contents, int index) {} | 64 virtual void TabDeselectedAt(TabContents* contents, int index) { } |
65 | 65 |
66 // The selected TabContents changed from |old_contents| to |new_contents| at | 66 // The selected TabContents changed from |old_contents| to |new_contents| at |
67 // |index|. |user_gesture| specifies whether or not this was done by a user | 67 // |index|. |user_gesture| specifies whether or not this was done by a user |
68 // input event (e.g. clicking on a tab, keystroke) or as a side-effect of | 68 // input event (e.g. clicking on a tab, keystroke) or as a side-effect of |
69 // some other function. | 69 // some other function. |
70 virtual void TabSelectedAt(TabContents* old_contents, | 70 virtual void TabSelectedAt(TabContents* old_contents, |
71 TabContents* new_contents, | 71 TabContents* new_contents, |
72 int index, | 72 int index, |
73 bool user_gesture) {} | 73 bool user_gesture) { } |
74 | 74 |
75 // The specified TabContents at |from_index| was moved to |to_index|. If | 75 // The specified TabContents at |from_index| was moved to |to_index|. If |
76 // the pinned state of the tab is changing |pinned_state_changed| is true. | 76 // the pinned state of the tab is changing |pinned_state_changed| is true. |
77 virtual void TabMoved(TabContents* contents, | 77 virtual void TabMoved(TabContents* contents, |
78 int from_index, | 78 int from_index, |
79 int to_index, | 79 int to_index, |
80 bool pinned_state_changed) {} | 80 bool pinned_state_changed) { } |
81 | 81 |
82 // The specified TabContents at |index| changed in some way. |contents| may | 82 // The specified TabContents at |index| changed in some way. |contents| may |
83 // be an entirely different object and the old value is no longer available | 83 // be an entirely different object and the old value is no longer available |
84 // by the time this message is delivered. | 84 // by the time this message is delivered. |
85 // | 85 // |
86 // If only the loading state was updated, the loading_only flag should be | 86 // If only the loading state was updated, the loading_only flag should be |
87 // specified. The tab model will update only the throbber, loading status, | 87 // specified. The tab model will update only the throbber, loading status, |
88 // and crashed state. | 88 // and crashed state. |
89 // | 89 // |
90 // If other things change, set this flag to false to update all state, | 90 // If other things change, set this flag to false to update all state, |
91 // including the title and favicon. This allows us to start/stop throbbing | 91 // including the title and favicon. This allows us to start/stop throbbing |
92 // without updating the title (which may be an ugly URL if the real title | 92 // without updating the title (which may be an ugly URL if the real title |
93 // hasn't come in yet). | 93 // hasn't come in yet). |
94 virtual void TabChangedAt(TabContents* contents, int index, | 94 virtual void TabChangedAt(TabContents* contents, int index, |
95 bool loading_only) {} | 95 bool loading_only) { } |
96 | 96 |
97 // Invoked when the pinned state of a tab changes. | 97 // Invoked when the pinned state of a tab changes. |
98 // NOTE: this is only invoked if the tab doesn't move as a result of its | 98 // NOTE: this is only invoked if the tab doesn't move as a result of its |
99 // pinned state changing. If the tab moves as a result, the observer is | 99 // pinned state changing. If the tab moves as a result, the observer is |
100 // notified by way of the TabMoved method with |pinned_state_changed| true. | 100 // notified by way of the TabMoved method with |pinned_state_changed| true. |
101 virtual void TabPinnedStateChanged(TabContents* contents, int index) {} | 101 virtual void TabPinnedStateChanged(TabContents* contents, int index) { } |
102 | 102 |
103 // The TabStripModel now no longer has any "significant" (user created or | 103 // The TabStripModel now no longer has any "significant" (user created or |
104 // user manipulated) tabs. The implementer may use this as a trigger to try | 104 // user manipulated) tabs. The implementer may use this as a trigger to try |
105 // and close the window containing the TabStripModel, for example... | 105 // and close the window containing the TabStripModel, for example... |
106 virtual void TabStripEmpty() {} | 106 virtual void TabStripEmpty() { } |
107 | |
108 protected: | |
109 ~TabStripModelObserver() {} | |
110 }; | 107 }; |
111 | 108 |
112 /////////////////////////////////////////////////////////////////////////////// | 109 /////////////////////////////////////////////////////////////////////////////// |
113 // | 110 // |
114 // TabStripModelDelegate | 111 // TabStripModelDelegate |
115 // | 112 // |
116 // A delegate interface that the TabStripModel uses to perform work that it | 113 // A delegate interface that the TabStripModel uses to perform work that it |
117 // can't do itself, such as obtain a container HWND for creating new | 114 // can't do itself, such as obtain a container HWND for creating new |
118 // TabContents, creating new TabStripModels for detached tabs, etc. | 115 // TabContents, creating new TabStripModels for detached tabs, etc. |
119 // | 116 // |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; | 192 virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; |
196 | 193 |
197 // Returns true if a tab can be restored. | 194 // Returns true if a tab can be restored. |
198 virtual bool CanRestoreTab() = 0; | 195 virtual bool CanRestoreTab() = 0; |
199 | 196 |
200 // Restores the last closed tab if CanRestoreTab would return true. | 197 // Restores the last closed tab if CanRestoreTab would return true. |
201 virtual void RestoreTab() = 0; | 198 virtual void RestoreTab() = 0; |
202 | 199 |
203 // Returns whether some contents can be closed. | 200 // Returns whether some contents can be closed. |
204 virtual bool CanCloseContentsAt(int index) = 0; | 201 virtual bool CanCloseContentsAt(int index) = 0; |
205 | |
206 protected: | |
207 ~TabStripModelDelegate() {} | |
208 }; | 202 }; |
209 | 203 |
210 //////////////////////////////////////////////////////////////////////////////// | 204 //////////////////////////////////////////////////////////////////////////////// |
211 // | 205 // |
212 // TabStripModel | 206 // TabStripModel |
213 // | 207 // |
214 // A model & low level controller of a Browser Window tabstrip. Holds a vector | 208 // A model & low level controller of a Browser Window tabstrip. Holds a vector |
215 // of TabContents, and provides an API for adding, removing and shuffling | 209 // of TabContents, and provides an API for adding, removing and shuffling |
216 // them, as well as a higher level API for doing specific Browser-related | 210 // them, as well as a higher level API for doing specific Browser-related |
217 // tasks like adding new Tabs from just a URL, etc. | 211 // tasks like adding new Tabs from just a URL, etc. |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 typedef ObserverList<TabStripModelObserver> TabStripModelObservers; | 622 typedef ObserverList<TabStripModelObserver> TabStripModelObservers; |
629 TabStripModelObservers observers_; | 623 TabStripModelObservers observers_; |
630 | 624 |
631 // A scoped container for notification registries. | 625 // A scoped container for notification registries. |
632 NotificationRegistrar registrar_; | 626 NotificationRegistrar registrar_; |
633 | 627 |
634 DISALLOW_COPY_AND_ASSIGN(TabStripModel); | 628 DISALLOW_COPY_AND_ASSIGN(TabStripModel); |
635 }; | 629 }; |
636 | 630 |
637 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ | 631 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ |
OLD | NEW |