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_SESSIONS_TAB_RESTORE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
6 #define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ | 6 #define CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <set> | 10 #include <set> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "chrome/browser/sessions/base_session_service.h" | 16 #include "chrome/browser/sessions/base_session_service.h" |
17 #include "chrome/browser/sessions/session_id.h" | 17 #include "chrome/browser/sessions/session_id.h" |
18 #include "chrome/browser/sessions/session_types.h" | 18 #include "chrome/browser/sessions/session_types.h" |
19 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 19 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
| 20 #include "webkit/glue/window_open_disposition.h" |
20 | 21 |
21 class NavigationController; | 22 class NavigationController; |
22 class Profile; | 23 class Profile; |
23 class TabRestoreServiceDelegate; | 24 class TabRestoreServiceDelegate; |
24 class TabRestoreServiceObserver; | 25 class TabRestoreServiceObserver; |
25 struct SessionWindow; | 26 struct SessionWindow; |
26 | 27 |
27 // TabRestoreService is responsible for maintaining the most recently closed | 28 // TabRestoreService is responsible for maintaining the most recently closed |
28 // tabs and windows. When a tab is closed | 29 // tabs and windows. When a tab is closed |
29 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to | 30 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Returns the entries, ordered with most recently closed entries at the | 147 // Returns the entries, ordered with most recently closed entries at the |
147 // front. | 148 // front. |
148 virtual const Entries& entries() const; | 149 virtual const Entries& entries() const; |
149 | 150 |
150 // Restores the most recently closed entry. Does nothing if there are no | 151 // Restores the most recently closed entry. Does nothing if there are no |
151 // entries to restore. If the most recently restored entry is a tab, it is | 152 // entries to restore. If the most recently restored entry is a tab, it is |
152 // added to |delegate|. | 153 // added to |delegate|. |
153 void RestoreMostRecentEntry(TabRestoreServiceDelegate* delegate); | 154 void RestoreMostRecentEntry(TabRestoreServiceDelegate* delegate); |
154 | 155 |
155 // Restores an entry by id. If there is no entry with an id matching |id|, | 156 // Restores an entry by id. If there is no entry with an id matching |id|, |
156 // this does nothing. If |replace_existing_tab| is true and id identifies a | 157 // this does nothing. If |delegate| is NULL, this creates a new window for the |
157 // tab, the newly created tab replaces the selected tab in |delegate|. If | 158 // entry. |disposition| is respected, but the attributes (tabstrip index, |
158 // |delegate| is NULL, this creates a new window for the entry. | 159 // browser window) of the tab when it was closed will be respected if |
| 160 // disposition is UNKNOWN. |
159 void RestoreEntryById(TabRestoreServiceDelegate* delegate, | 161 void RestoreEntryById(TabRestoreServiceDelegate* delegate, |
160 SessionID::id_type id, | 162 SessionID::id_type id, |
161 bool replace_existing_tab); | 163 WindowOpenDisposition disposition); |
162 | 164 |
163 // Loads the tabs and previous session. This does nothing if the tabs | 165 // Loads the tabs and previous session. This does nothing if the tabs |
164 // from the previous session have already been loaded. | 166 // from the previous session have already been loaded. |
165 void LoadTabsFromLastSession(); | 167 void LoadTabsFromLastSession(); |
166 | 168 |
167 // Max number of entries we'll keep around. | 169 // Max number of entries we'll keep around. |
168 static const size_t kMaxEntries; | 170 static const size_t kMaxEntries; |
169 | 171 |
170 // Creates and add entries to |entries| for each of the windows in |windows|. | 172 // Creates and add entries to |entries| for each of the windows in |windows|. |
171 void CreateEntriesFromWindows(std::vector<SessionWindow*>* windows, | 173 void CreateEntriesFromWindows(std::vector<SessionWindow*>* windows, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 void OnGotLastSessionCommands( | 258 void OnGotLastSessionCommands( |
257 Handle handle, | 259 Handle handle, |
258 scoped_refptr<InternalGetCommandsRequest> request); | 260 scoped_refptr<InternalGetCommandsRequest> request); |
259 | 261 |
260 // Populates |loaded_entries| with Entries from |request|. | 262 // Populates |loaded_entries| with Entries from |request|. |
261 void CreateEntriesFromCommands( | 263 void CreateEntriesFromCommands( |
262 scoped_refptr<InternalGetCommandsRequest> request, | 264 scoped_refptr<InternalGetCommandsRequest> request, |
263 std::vector<Entry*>* loaded_entries); | 265 std::vector<Entry*>* loaded_entries); |
264 | 266 |
265 // This is a helper function for RestoreEntryById() for restoring a single | 267 // This is a helper function for RestoreEntryById() for restoring a single |
266 // tab. If |replace_existing_tab| is true, the newly created tab replaces the | 268 // tab. If |delegate| is NULL, this creates a new window for the entry. This |
267 // selected tab in |delegate|. If |delegate| is NULL, this creates a new | 269 // returns the TabRestoreServiceDelegate into which the tab was restored. |
268 // window for the entry. This returns the TabRestoreServiceDelegate into which | 270 // |disposition| will be respected, but if it is UNKNOWN then the tab's |
269 // the tab was restored. | 271 // original attributes will be respected instead. |
270 TabRestoreServiceDelegate* RestoreTab(const Tab& tab, | 272 TabRestoreServiceDelegate* RestoreTab(const Tab& tab, |
271 TabRestoreServiceDelegate* delegate, | 273 TabRestoreServiceDelegate* delegate, |
272 bool replace_existing_tab); | 274 WindowOpenDisposition disposition); |
273 | 275 |
274 // Returns true if |tab| has more than one navigation. If |tab| has more | 276 // Returns true if |tab| has more than one navigation. If |tab| has more |
275 // than one navigation |tab->current_navigation_index| is constrained based | 277 // than one navigation |tab->current_navigation_index| is constrained based |
276 // on the number of navigations. | 278 // on the number of navigations. |
277 static bool ValidateTab(Tab* tab); | 279 static bool ValidateTab(Tab* tab); |
278 | 280 |
279 // Validates all the tabs in a window, plus the window's active tab index. | 281 // Validates all the tabs in a window, plus the window's active tab index. |
280 static bool ValidateWindow(Window* window); | 282 static bool ValidateWindow(Window* window); |
281 | 283 |
282 // Calls either ValidateTab or ValidateWindow as appropriate. | 284 // Calls either ValidateTab or ValidateWindow as appropriate. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 // loading LoadStateChanged is invoked, which adds these entries to | 357 // loading LoadStateChanged is invoked, which adds these entries to |
356 // entries_. | 358 // entries_. |
357 std::vector<Entry*> staging_entries_; | 359 std::vector<Entry*> staging_entries_; |
358 | 360 |
359 TimeFactory* time_factory_; | 361 TimeFactory* time_factory_; |
360 | 362 |
361 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); | 363 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); |
362 }; | 364 }; |
363 | 365 |
364 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ | 366 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
OLD | NEW |