| 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 #include "webkit/glue/window_open_disposition.h" |
| 21 | 21 |
| 22 class NavigationController; | |
| 23 class Profile; | 22 class Profile; |
| 24 class TabRestoreServiceDelegate; | 23 class TabRestoreServiceDelegate; |
| 25 class TabRestoreServiceObserver; | 24 class TabRestoreServiceObserver; |
| 26 struct SessionWindow; | 25 struct SessionWindow; |
| 27 | 26 |
| 27 namespace content { |
| 28 class NavigationController; |
| 29 } |
| 30 |
| 28 // TabRestoreService is responsible for maintaining the most recently closed | 31 // TabRestoreService is responsible for maintaining the most recently closed |
| 29 // tabs and windows. When a tab is closed | 32 // tabs and windows. When a tab is closed |
| 30 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to | 33 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to |
| 31 // represent the tab. Similarly, when a browser is closed, BrowserClosing is | 34 // represent the tab. Similarly, when a browser is closed, BrowserClosing is |
| 32 // invoked and a Window is created to represent the window. | 35 // invoked and a Window is created to represent the window. |
| 33 // | 36 // |
| 34 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById | 37 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById |
| 35 // or RestoreMostRecentEntry. | 38 // or RestoreMostRecentEntry. |
| 36 // | 39 // |
| 37 // To listen for changes to the set of entries managed by the TabRestoreService | 40 // To listen for changes to the set of entries managed by the TabRestoreService |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 126 |
| 124 virtual ~TabRestoreService(); | 127 virtual ~TabRestoreService(); |
| 125 | 128 |
| 126 // Adds/removes an observer. TabRestoreService does not take ownership of | 129 // Adds/removes an observer. TabRestoreService does not take ownership of |
| 127 // the observer. | 130 // the observer. |
| 128 void AddObserver(TabRestoreServiceObserver* observer); | 131 void AddObserver(TabRestoreServiceObserver* observer); |
| 129 void RemoveObserver(TabRestoreServiceObserver* observer); | 132 void RemoveObserver(TabRestoreServiceObserver* observer); |
| 130 | 133 |
| 131 // Creates a Tab to represent |tab| and notifies observers the list of | 134 // Creates a Tab to represent |tab| and notifies observers the list of |
| 132 // entries has changed. | 135 // entries has changed. |
| 133 void CreateHistoricalTab(NavigationController* tab, int index); | 136 void CreateHistoricalTab(content::NavigationController* tab, int index); |
| 134 | 137 |
| 135 // Invoked when a browser is closing. If |delegate| is a tabbed browser with | 138 // Invoked when a browser is closing. If |delegate| is a tabbed browser with |
| 136 // at least one tab, a Window is created, added to entries and observers are | 139 // at least one tab, a Window is created, added to entries and observers are |
| 137 // notified. | 140 // notified. |
| 138 void BrowserClosing(TabRestoreServiceDelegate* delegate); | 141 void BrowserClosing(TabRestoreServiceDelegate* delegate); |
| 139 | 142 |
| 140 // Invoked when the browser is done closing. | 143 // Invoked when the browser is done closing. |
| 141 void BrowserClosed(TabRestoreServiceDelegate* delegate); | 144 void BrowserClosed(TabRestoreServiceDelegate* delegate); |
| 142 | 145 |
| 143 // Removes all entries from the list and notifies observers the list | 146 // Removes all entries from the list and notifies observers the list |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Indicates we finished loading the last session (but not necessarily the | 200 // Indicates we finished loading the last session (but not necessarily the |
| 198 // last tabs). | 201 // last tabs). |
| 199 LOADED_LAST_SESSION = 1 << 4 | 202 LOADED_LAST_SESSION = 1 << 4 |
| 200 }; | 203 }; |
| 201 | 204 |
| 202 // Populates the tab's navigations from the NavigationController, and its | 205 // Populates the tab's navigations from the NavigationController, and its |
| 203 // browser_id and pinned state from the browser. | 206 // browser_id and pinned state from the browser. |
| 204 void PopulateTab(Tab* tab, | 207 void PopulateTab(Tab* tab, |
| 205 int index, | 208 int index, |
| 206 TabRestoreServiceDelegate* delegate, | 209 TabRestoreServiceDelegate* delegate, |
| 207 NavigationController* controller); | 210 content::NavigationController* controller); |
| 208 | 211 |
| 209 // Notifies observers the tabs have changed. | 212 // Notifies observers the tabs have changed. |
| 210 void NotifyTabsChanged(); | 213 void NotifyTabsChanged(); |
| 211 | 214 |
| 212 // Adds |entry| to the list of entries and takes ownership. If |prune| is true | 215 // Adds |entry| to the list of entries and takes ownership. If |prune| is true |
| 213 // |PruneAndNotify| is invoked. If |to_front| is true the entry is added to | 216 // |PruneAndNotify| is invoked. If |to_front| is true the entry is added to |
| 214 // the front, otherwise the back. Normal closes go to the front, but | 217 // the front, otherwise the back. Normal closes go to the front, but |
| 215 // tab/window closes from the previous session are added to the back. | 218 // tab/window closes from the previous session are added to the back. |
| 216 void AddEntry(Entry* entry, bool prune, bool to_front); | 219 void AddEntry(Entry* entry, bool prune, bool to_front); |
| 217 | 220 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // loading LoadStateChanged is invoked, which adds these entries to | 361 // loading LoadStateChanged is invoked, which adds these entries to |
| 359 // entries_. | 362 // entries_. |
| 360 std::vector<Entry*> staging_entries_; | 363 std::vector<Entry*> staging_entries_; |
| 361 | 364 |
| 362 TimeFactory* time_factory_; | 365 TimeFactory* time_factory_; |
| 363 | 366 |
| 364 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); | 367 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); |
| 365 }; | 368 }; |
| 366 | 369 |
| 367 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ | 370 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
| OLD | NEW |