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_PERSISTENT_TAB_RESTORE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_PERSISTENT_TAB_RESTORE_SERVICE_H_ |
6 #define CHROME_BROWSER_SESSIONS_PERSISTENT_TAB_RESTORE_SERVICE_H_ | 6 #define CHROME_BROWSER_SESSIONS_PERSISTENT_TAB_RESTORE_SERVICE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/sessions/tab_restore_service.h" | 13 #include "chrome/browser/sessions/tab_restore_service.h" |
14 #include "chrome/browser/sessions/tab_restore_service_helper.h" | 14 #include "chrome/browser/sessions/tab_restore_service_helper.h" |
15 | 15 |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 // Tab restore service that persists data on disk. | 18 // Tab restore service that persists data on disk. |
19 class PersistentTabRestoreService : public TabRestoreService { | 19 class PersistentTabRestoreService : public TabRestoreService { |
20 public: | 20 public: |
21 // Does not take ownership of |time_factory|. | 21 // Does not take ownership of |time_factory|. |
22 PersistentTabRestoreService(Profile* profile, | 22 PersistentTabRestoreService(Profile* profile, |
23 TimeFactory* time_factory); | 23 TimeFactory* time_factory); |
24 | 24 |
25 virtual ~PersistentTabRestoreService(); | 25 ~PersistentTabRestoreService() override; |
26 | 26 |
27 // TabRestoreService: | 27 // TabRestoreService: |
28 virtual void AddObserver(TabRestoreServiceObserver* observer) override; | 28 void AddObserver(TabRestoreServiceObserver* observer) override; |
29 virtual void RemoveObserver(TabRestoreServiceObserver* observer) override; | 29 void RemoveObserver(TabRestoreServiceObserver* observer) override; |
30 virtual void CreateHistoricalTab(content::WebContents* contents, | 30 void CreateHistoricalTab(content::WebContents* contents, int index) override; |
31 int index) override; | 31 void BrowserClosing(TabRestoreServiceDelegate* delegate) override; |
32 virtual void BrowserClosing(TabRestoreServiceDelegate* delegate) override; | 32 void BrowserClosed(TabRestoreServiceDelegate* delegate) override; |
33 virtual void BrowserClosed(TabRestoreServiceDelegate* delegate) override; | 33 void ClearEntries() override; |
34 virtual void ClearEntries() override; | 34 const Entries& entries() const override; |
35 virtual const Entries& entries() const override; | 35 std::vector<content::WebContents*> RestoreMostRecentEntry( |
36 virtual std::vector<content::WebContents*> RestoreMostRecentEntry( | |
37 TabRestoreServiceDelegate* delegate, | 36 TabRestoreServiceDelegate* delegate, |
38 chrome::HostDesktopType host_desktop_type) override; | 37 chrome::HostDesktopType host_desktop_type) override; |
39 virtual Tab* RemoveTabEntryById(SessionID::id_type id) override; | 38 Tab* RemoveTabEntryById(SessionID::id_type id) override; |
40 virtual std::vector<content::WebContents*> RestoreEntryById( | 39 std::vector<content::WebContents*> RestoreEntryById( |
41 TabRestoreServiceDelegate* delegate, | 40 TabRestoreServiceDelegate* delegate, |
42 SessionID::id_type id, | 41 SessionID::id_type id, |
43 chrome::HostDesktopType host_desktop_type, | 42 chrome::HostDesktopType host_desktop_type, |
44 WindowOpenDisposition disposition) override; | 43 WindowOpenDisposition disposition) override; |
45 virtual void LoadTabsFromLastSession() override; | 44 void LoadTabsFromLastSession() override; |
46 virtual bool IsLoaded() const override; | 45 bool IsLoaded() const override; |
47 virtual void DeleteLastSession() override; | 46 void DeleteLastSession() override; |
48 virtual void Shutdown() override; | 47 void Shutdown() override; |
49 | 48 |
50 private: | 49 private: |
51 friend class PersistentTabRestoreServiceTest; | 50 friend class PersistentTabRestoreServiceTest; |
52 | 51 |
53 class Delegate; | 52 class Delegate; |
54 | 53 |
55 // Exposed for testing. | 54 // Exposed for testing. |
56 Entries* mutable_entries(); | 55 Entries* mutable_entries(); |
57 void PruneEntries(); | 56 void PruneEntries(); |
58 | 57 |
59 scoped_ptr<Delegate> delegate_; | 58 scoped_ptr<Delegate> delegate_; |
60 TabRestoreServiceHelper helper_; | 59 TabRestoreServiceHelper helper_; |
61 | 60 |
62 DISALLOW_COPY_AND_ASSIGN(PersistentTabRestoreService); | 61 DISALLOW_COPY_AND_ASSIGN(PersistentTabRestoreService); |
63 }; | 62 }; |
64 | 63 |
65 #endif // CHROME_BROWSER_SESSIONS_PERSISTENT_TAB_RESTORE_SERVICE_H_ | 64 #endif // CHROME_BROWSER_SESSIONS_PERSISTENT_TAB_RESTORE_SERVICE_H_ |
OLD | NEW |