OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "chrome/browser/sessions/base_session_service.h" | 15 #include "chrome/browser/sessions/base_session_service.h" |
16 #include "chrome/browser/sessions/session_id.h" | 16 #include "chrome/browser/sessions/session_id.h" |
17 #include "chrome/browser/sessions/session_types.h" | 17 #include "chrome/browser/sessions/session_types.h" |
18 #include "content/public/browser/session_storage_namespace.h" | 18 #include "content/public/browser/session_storage_namespace.h" |
19 #include "webkit/glue/window_open_disposition.h" | 19 #include "webkit/glue/window_open_disposition.h" |
20 | 20 |
21 class Profile; | 21 class Profile; |
22 class TabRestoreServiceDelegate; | 22 class TabRestoreServiceDelegate; |
23 class TabRestoreServiceObserver; | 23 class TabRestoreServiceObserver; |
24 struct SessionWindow; | 24 struct SessionWindow; |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 class NavigationController; | 27 class NavigationController; |
28 class SessionStorageNamespace; | 28 class SessionStorageNamespace; |
| 29 class WebContents; |
29 } | 30 } |
30 | 31 |
31 // TabRestoreService is responsible for maintaining the most recently closed | 32 // TabRestoreService is responsible for maintaining the most recently closed |
32 // tabs and windows. When a tab is closed | 33 // tabs and windows. When a tab is closed |
33 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to | 34 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to |
34 // represent the tab. Similarly, when a browser is closed, BrowserClosing is | 35 // represent the tab. Similarly, when a browser is closed, BrowserClosing is |
35 // invoked and a Window is created to represent the window. | 36 // invoked and a Window is created to represent the window. |
36 // | 37 // |
37 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById | 38 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById |
38 // or RestoreMostRecentEntry. | 39 // or RestoreMostRecentEntry. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // |time_factory_|. | 131 // |time_factory_|. |
131 TabRestoreService(Profile* profile, TimeFactory* time_factory_ = NULL); | 132 TabRestoreService(Profile* profile, TimeFactory* time_factory_ = NULL); |
132 | 133 |
133 virtual ~TabRestoreService(); | 134 virtual ~TabRestoreService(); |
134 | 135 |
135 // Adds/removes an observer. TabRestoreService does not take ownership of | 136 // Adds/removes an observer. TabRestoreService does not take ownership of |
136 // the observer. | 137 // the observer. |
137 void AddObserver(TabRestoreServiceObserver* observer); | 138 void AddObserver(TabRestoreServiceObserver* observer); |
138 void RemoveObserver(TabRestoreServiceObserver* observer); | 139 void RemoveObserver(TabRestoreServiceObserver* observer); |
139 | 140 |
140 // Creates a Tab to represent |tab| and notifies observers the list of | 141 // Creates a Tab to represent |contents| and notifies observers the list of |
141 // entries has changed. | 142 // entries has changed. |
142 void CreateHistoricalTab(content::NavigationController* tab, int index); | 143 void CreateHistoricalTab(content::WebContents* contents, int index); |
143 | 144 |
144 // Invoked when a browser is closing. If |delegate| is a tabbed browser with | 145 // Invoked when a browser is closing. If |delegate| is a tabbed browser with |
145 // at least one tab, a Window is created, added to entries and observers are | 146 // at least one tab, a Window is created, added to entries and observers are |
146 // notified. | 147 // notified. |
147 void BrowserClosing(TabRestoreServiceDelegate* delegate); | 148 void BrowserClosing(TabRestoreServiceDelegate* delegate); |
148 | 149 |
149 // Invoked when the browser is done closing. | 150 // Invoked when the browser is done closing. |
150 void BrowserClosed(TabRestoreServiceDelegate* delegate); | 151 void BrowserClosed(TabRestoreServiceDelegate* delegate); |
151 | 152 |
152 // Removes all entries from the list and notifies observers the list | 153 // Removes all entries from the list and notifies observers the list |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 // loading LoadStateChanged is invoked, which adds these entries to | 379 // loading LoadStateChanged is invoked, which adds these entries to |
379 // entries_. | 380 // entries_. |
380 std::vector<Entry*> staging_entries_; | 381 std::vector<Entry*> staging_entries_; |
381 | 382 |
382 TimeFactory* time_factory_; | 383 TimeFactory* time_factory_; |
383 | 384 |
384 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); | 385 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); |
385 }; | 386 }; |
386 | 387 |
387 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ | 388 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
OLD | NEW |