OLD | NEW |
1 // Copyright (c) 2006-2008 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" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // This interface is typically implemented by the controller that instantiates | 102 // This interface is typically implemented by the controller that instantiates |
103 // the TabStripModel (in our case the Browser object). | 103 // the TabStripModel (in our case the Browser object). |
104 // | 104 // |
105 /////////////////////////////////////////////////////////////////////////////// | 105 /////////////////////////////////////////////////////////////////////////////// |
106 class TabStripModelDelegate { | 106 class TabStripModelDelegate { |
107 public: | 107 public: |
108 // Adds what the delegate considers to be a blank tab to the model. | 108 // Adds what the delegate considers to be a blank tab to the model. |
109 virtual TabContents* AddBlankTab(bool foreground) = 0; | 109 virtual TabContents* AddBlankTab(bool foreground) = 0; |
110 virtual TabContents* AddBlankTabAt(int index, bool foreground) = 0; | 110 virtual TabContents* AddBlankTabAt(int index, bool foreground) = 0; |
111 | 111 |
112 // Ask for a new TabStripModel to be created and the given tab contents to | 112 // Asks for a new TabStripModel to be created and the given tab contents to |
113 // be added to it. Its size and position are reflected in |window_bounds|. | 113 // be added to it. Its size and position are reflected in |window_bounds|. |
114 // If |dock_info|'s type is other than NONE, the newly created window should | 114 // If |dock_info|'s type is other than NONE, the newly created window should |
115 // be docked as identified by |dock_info|. Returns the Browser object | 115 // be docked as identified by |dock_info|. Returns the Browser object |
116 // representing the newly created window and tab strip. This does not | 116 // representing the newly created window and tab strip. This does not |
117 // show the window, it's up to the caller to do so. | 117 // show the window, it's up to the caller to do so. |
118 // TODO(pinkerton): I really don't like the fact that this is returning a | 118 // TODO(pinkerton): I really don't like the fact that this is returning a |
119 // Browser object, there may be some better abstraction we can achieve that | 119 // Browser object, there may be some better abstraction we can achieve that |
120 // the Browser implements, but for now, we'll experiment with returning | 120 // the Browser implements, but for now, we'll experiment with returning |
121 // that type. | 121 // that type. |
122 virtual Browser* CreateNewStripWithContents(TabContents* contents, | 122 virtual Browser* CreateNewStripWithContents(TabContents* contents, |
123 const gfx::Rect& window_bounds, | 123 const gfx::Rect& window_bounds, |
124 const DockInfo& dock_info) = 0; | 124 const DockInfo& dock_info) = 0; |
125 | 125 |
126 enum { | 126 enum { |
127 TAB_MOVE_ACTION = 1, | 127 TAB_MOVE_ACTION = 1, |
128 TAB_TEAROFF_ACTION = 2 | 128 TAB_TEAROFF_ACTION = 2 |
129 }; | 129 }; |
130 | 130 |
131 // Determine what drag actions are possible for the specified strip. | 131 // Determines what drag actions are possible for the specified strip. |
132 virtual int GetDragActions() const = 0; | 132 virtual int GetDragActions() const = 0; |
133 | 133 |
134 // Creates an appropriate TabContents for the given URL. This is handled by | 134 // Creates an appropriate TabContents for the given URL. This is handled by |
135 // the delegate since the TabContents may require special circumstances to | 135 // the delegate since the TabContents may require special circumstances to |
136 // exist for it to be constructed (e.g. a parent HWND). | 136 // exist for it to be constructed (e.g. a parent HWND). |
137 // If |defer_load| is true, the navigation controller doesn't load the url. | 137 // If |defer_load| is true, the navigation controller doesn't load the url. |
138 // If |instance| is not null, its process is used to render the tab. | 138 // If |instance| is not null, its process is used to render the tab. |
139 virtual TabContents* CreateTabContentsForURL( | 139 virtual TabContents* CreateTabContentsForURL( |
140 const GURL& url, | 140 const GURL& url, |
141 const GURL& referrer, | 141 const GURL& referrer, |
142 Profile* profile, | 142 Profile* profile, |
143 PageTransition::Type transition, | 143 PageTransition::Type transition, |
144 bool defer_load, | 144 bool defer_load, |
145 SiteInstance* instance) const = 0; | 145 SiteInstance* instance) const = 0; |
146 | 146 |
147 // Return whether some contents can be duplicated. | 147 // Returns whether some contents can be duplicated. |
148 virtual bool CanDuplicateContentsAt(int index) = 0; | 148 virtual bool CanDuplicateContentsAt(int index) = 0; |
149 | 149 |
150 // Duplicate the contents at the provided index and places it into its own | 150 // Duplicates the contents at the provided index and places it into its own |
151 // window. | 151 // window. |
152 virtual void DuplicateContentsAt(int index) = 0; | 152 virtual void DuplicateContentsAt(int index) = 0; |
153 | 153 |
154 // Called when a drag session has completed and the frame that initiated the | 154 // Called when a drag session has completed and the frame that initiated the |
155 // the session should be closed. | 155 // the session should be closed. |
156 virtual void CloseFrameAfterDragSession() = 0; | 156 virtual void CloseFrameAfterDragSession() = 0; |
157 | 157 |
158 // Creates an entry in the historical tab database for the specified | 158 // Creates an entry in the historical tab database for the specified |
159 // TabContents. | 159 // TabContents. |
160 virtual void CreateHistoricalTab(TabContents* contents) = 0; | 160 virtual void CreateHistoricalTab(TabContents* contents) = 0; |
161 | 161 |
162 // Runs any unload listeners associated with the specified TabContents before | 162 // Runs any unload listeners associated with the specified TabContents before |
163 // it is closed. If there are unload listeners that need to be run, this | 163 // it is closed. If there are unload listeners that need to be run, this |
164 // function returns true and the TabStripModel will wait before closing the | 164 // function returns true and the TabStripModel will wait before closing the |
165 // TabContents. If it returns false, there are no unload listeners and the | 165 // TabContents. If it returns false, there are no unload listeners and the |
166 // TabStripModel can close the TabContents immediately. | 166 // TabStripModel can close the TabContents immediately. |
167 virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; | 167 virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; |
168 | 168 |
169 // Returns true if a tab can be restored. | 169 // Returns true if a tab can be restored. |
170 virtual bool CanRestoreTab() = 0; | 170 virtual bool CanRestoreTab() = 0; |
171 | 171 |
172 // Restores the last closed tab if CanRestoreTab would return true. | 172 // Restores the last closed tab if CanRestoreTab would return true. |
173 virtual void RestoreTab() = 0; | 173 virtual void RestoreTab() = 0; |
| 174 |
| 175 // Returns whether some contents can be closed. |
| 176 virtual bool CanCloseContentsAt(int index) = 0; |
174 }; | 177 }; |
175 | 178 |
176 //////////////////////////////////////////////////////////////////////////////// | 179 //////////////////////////////////////////////////////////////////////////////// |
177 // | 180 // |
178 // TabStripModel | 181 // TabStripModel |
179 // | 182 // |
180 // A model & low level controller of a Browser Window tabstrip. Holds a vector | 183 // A model & low level controller of a Browser Window tabstrip. Holds a vector |
181 // of TabContents, and provides an API for adding, removing and shuffling | 184 // of TabContents, and provides an API for adding, removing and shuffling |
182 // them, as well as a higher level API for doing specific Browser-related | 185 // them, as well as a higher level API for doing specific Browser-related |
183 // tasks like adding new Tabs from just a URL, etc. | 186 // tasks like adding new Tabs from just a URL, etc. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // |inherit_group| is true, the new contents is linked to the current tab's | 250 // |inherit_group| is true, the new contents is linked to the current tab's |
248 // group. | 251 // group. |
249 void InsertTabContentsAt(int index, | 252 void InsertTabContentsAt(int index, |
250 TabContents* contents, | 253 TabContents* contents, |
251 bool foreground, | 254 bool foreground, |
252 bool inherit_group); | 255 bool inherit_group); |
253 | 256 |
254 // Closes the TabContents at the specified index. This causes the TabContents | 257 // Closes the TabContents at the specified index. This causes the TabContents |
255 // to be destroyed, but it may not happen immediately (e.g. if it's a | 258 // to be destroyed, but it may not happen immediately (e.g. if it's a |
256 // WebContents). | 259 // WebContents). |
257 // Returns true if the TabContents was closed immediately, false if we are | 260 // Returns true if the TabContents was closed immediately, false if it was not |
258 // waiting for a response from an onunload handler. | 261 // closed (we may be waiting for a response from an onunload handler, or |
| 262 // waiting for the user to confirm closure). |
259 bool CloseTabContentsAt(int index) { | 263 bool CloseTabContentsAt(int index) { |
260 return InternalCloseTabContentsAt(index, true); | 264 return InternalCloseTabContentsAt(index, true); |
261 } | 265 } |
262 | 266 |
263 // Replaces the entire state of a the tab at index by switching in a | 267 // Replaces the entire state of a the tab at index by switching in a |
264 // different NavigationController. This is used through the recently | 268 // different NavigationController. This is used through the recently |
265 // closed tabs list, which needs to replace a tab's current state | 269 // closed tabs list, which needs to replace a tab's current state |
266 // and history with another set of contents and history. | 270 // and history with another set of contents and history. |
267 // | 271 // |
268 // The old NavigationController is deallocated and this object takes | 272 // The old NavigationController is deallocated and this object takes |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 typedef ObserverList<TabStripModelObserver> TabStripModelObservers; | 564 typedef ObserverList<TabStripModelObserver> TabStripModelObservers; |
561 TabStripModelObservers observers_; | 565 TabStripModelObservers observers_; |
562 | 566 |
563 // A scoped container for notification registries. | 567 // A scoped container for notification registries. |
564 NotificationRegistrar registrar_; | 568 NotificationRegistrar registrar_; |
565 | 569 |
566 DISALLOW_COPY_AND_ASSIGN(TabStripModel); | 570 DISALLOW_COPY_AND_ASSIGN(TabStripModel); |
567 }; | 571 }; |
568 | 572 |
569 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ | 573 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ |
OLD | NEW |