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; | |
30 } | 29 } |
31 | 30 |
32 // TabRestoreService is responsible for maintaining the most recently closed | 31 // TabRestoreService is responsible for maintaining the most recently closed |
33 // tabs and windows. When a tab is closed | 32 // tabs and windows. When a tab is closed |
34 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to | 33 // TabRestoreService::CreateHistoricalTab is invoked and a Tab is created to |
35 // represent the tab. Similarly, when a browser is closed, BrowserClosing is | 34 // represent the tab. Similarly, when a browser is closed, BrowserClosing is |
36 // invoked and a Window is created to represent the window. | 35 // invoked and a Window is created to represent the window. |
37 // | 36 // |
38 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById | 37 // To restore a tab/window from the TabRestoreService invoke RestoreEntryById |
39 // or RestoreMostRecentEntry. | 38 // or RestoreMostRecentEntry. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // |time_factory_|. | 130 // |time_factory_|. |
132 TabRestoreService(Profile* profile, TimeFactory* time_factory_ = NULL); | 131 TabRestoreService(Profile* profile, TimeFactory* time_factory_ = NULL); |
133 | 132 |
134 virtual ~TabRestoreService(); | 133 virtual ~TabRestoreService(); |
135 | 134 |
136 // Adds/removes an observer. TabRestoreService does not take ownership of | 135 // Adds/removes an observer. TabRestoreService does not take ownership of |
137 // the observer. | 136 // the observer. |
138 void AddObserver(TabRestoreServiceObserver* observer); | 137 void AddObserver(TabRestoreServiceObserver* observer); |
139 void RemoveObserver(TabRestoreServiceObserver* observer); | 138 void RemoveObserver(TabRestoreServiceObserver* observer); |
140 | 139 |
141 // Creates a Tab to represent |contents| and notifies observers the list of | 140 // Creates a Tab to represent |tab| and notifies observers the list of |
142 // entries has changed. | 141 // entries has changed. |
143 void CreateHistoricalTab(content::WebContents* contents, int index); | 142 void CreateHistoricalTab(content::NavigationController* tab, int index); |
144 | 143 |
145 // Invoked when a browser is closing. If |delegate| is a tabbed browser with | 144 // Invoked when a browser is closing. If |delegate| is a tabbed browser with |
146 // at least one tab, a Window is created, added to entries and observers are | 145 // at least one tab, a Window is created, added to entries and observers are |
147 // notified. | 146 // notified. |
148 void BrowserClosing(TabRestoreServiceDelegate* delegate); | 147 void BrowserClosing(TabRestoreServiceDelegate* delegate); |
149 | 148 |
150 // Invoked when the browser is done closing. | 149 // Invoked when the browser is done closing. |
151 void BrowserClosed(TabRestoreServiceDelegate* delegate); | 150 void BrowserClosed(TabRestoreServiceDelegate* delegate); |
152 | 151 |
153 // Removes all entries from the list and notifies observers the list | 152 // Removes all entries from the list and notifies observers the list |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // loading LoadStateChanged is invoked, which adds these entries to | 378 // loading LoadStateChanged is invoked, which adds these entries to |
380 // entries_. | 379 // entries_. |
381 std::vector<Entry*> staging_entries_; | 380 std::vector<Entry*> staging_entries_; |
382 | 381 |
383 TimeFactory* time_factory_; | 382 TimeFactory* time_factory_; |
384 | 383 |
385 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); | 384 DISALLOW_COPY_AND_ASSIGN(TabRestoreService); |
386 }; | 385 }; |
387 | 386 |
388 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ | 387 #endif // CHROME_BROWSER_SESSIONS_TAB_RESTORE_SERVICE_H_ |
OLD | NEW |