| 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_IN_MEMORY_TAB_RESTORE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_IN_MEMORY_TAB_RESTORE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SESSIONS_IN_MEMORY_TAB_RESTORE_SERVICE_H_ | 6 #define CHROME_BROWSER_SESSIONS_IN_MEMORY_TAB_RESTORE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/sessions/tab_restore_service.h" | 11 #include "chrome/browser/sessions/tab_restore_service.h" |
| 11 #include "chrome/browser/sessions/tab_restore_service_helper.h" | 12 #include "chrome/browser/sessions/tab_restore_service_helper.h" |
| 13 #include "components/sessions/core/tab_restore_service_client.h" |
| 14 |
| 15 namespace sessions { |
| 16 class TabRestoreServiceClient; |
| 17 } |
| 12 | 18 |
| 13 // Tab restore service that doesn't persist tabs on disk. This is used on | 19 // Tab restore service that doesn't persist tabs on disk. This is used on |
| 14 // Android where tabs persistence is implemented on the application side in | 20 // Android where tabs persistence is implemented on the application side in |
| 15 // Java. Other platforms should use PersistentTabRestoreService which can be | 21 // Java. Other platforms should use PersistentTabRestoreService which can be |
| 16 // instantiated through the TabRestoreServiceFactory. | 22 // instantiated through the TabRestoreServiceFactory. |
| 17 class InMemoryTabRestoreService : public TabRestoreService { | 23 class InMemoryTabRestoreService : public TabRestoreService { |
| 18 public: | 24 public: |
| 19 // Creates a new TabRestoreService and provides an object that provides the | 25 // Creates a new TabRestoreService and provides an object that provides the |
| 20 // current time. The TabRestoreService does not take ownership of | 26 // current time. The TabRestoreService does not take ownership of |
| 21 // |time_factory|. | 27 // |time_factory|. |
| 22 InMemoryTabRestoreService(Profile* profile, | 28 InMemoryTabRestoreService( |
| 23 TimeFactory* time_factory); | 29 Profile* profile, |
| 30 scoped_ptr<sessions::TabRestoreServiceClient> client, |
| 31 TimeFactory* time_factory); |
| 24 | 32 |
| 25 ~InMemoryTabRestoreService() override; | 33 ~InMemoryTabRestoreService() override; |
| 26 | 34 |
| 27 // TabRestoreService: | 35 // TabRestoreService: |
| 28 void AddObserver(TabRestoreServiceObserver* observer) override; | 36 void AddObserver(TabRestoreServiceObserver* observer) override; |
| 29 void RemoveObserver(TabRestoreServiceObserver* observer) override; | 37 void RemoveObserver(TabRestoreServiceObserver* observer) override; |
| 30 void CreateHistoricalTab(content::WebContents* contents, int index) override; | 38 void CreateHistoricalTab(content::WebContents* contents, int index) override; |
| 31 void BrowserClosing(TabRestoreServiceDelegate* delegate) override; | 39 void BrowserClosing(TabRestoreServiceDelegate* delegate) override; |
| 32 void BrowserClosed(TabRestoreServiceDelegate* delegate) override; | 40 void BrowserClosed(TabRestoreServiceDelegate* delegate) override; |
| 33 void ClearEntries() override; | 41 void ClearEntries() override; |
| 34 const Entries& entries() const override; | 42 const Entries& entries() const override; |
| 35 std::vector<content::WebContents*> RestoreMostRecentEntry( | 43 std::vector<content::WebContents*> RestoreMostRecentEntry( |
| 36 TabRestoreServiceDelegate* delegate, | 44 TabRestoreServiceDelegate* delegate, |
| 37 chrome::HostDesktopType host_desktop_type) override; | 45 chrome::HostDesktopType host_desktop_type) override; |
| 38 Tab* RemoveTabEntryById(SessionID::id_type id) override; | 46 Tab* RemoveTabEntryById(SessionID::id_type id) override; |
| 39 std::vector<content::WebContents*> RestoreEntryById( | 47 std::vector<content::WebContents*> RestoreEntryById( |
| 40 TabRestoreServiceDelegate* delegate, | 48 TabRestoreServiceDelegate* delegate, |
| 41 SessionID::id_type id, | 49 SessionID::id_type id, |
| 42 chrome::HostDesktopType host_desktop_type, | 50 chrome::HostDesktopType host_desktop_type, |
| 43 WindowOpenDisposition disposition) override; | 51 WindowOpenDisposition disposition) override; |
| 44 void LoadTabsFromLastSession() override; | 52 void LoadTabsFromLastSession() override; |
| 45 bool IsLoaded() const override; | 53 bool IsLoaded() const override; |
| 46 void DeleteLastSession() override; | 54 void DeleteLastSession() override; |
| 47 void Shutdown() override; | 55 void Shutdown() override; |
| 48 | 56 |
| 49 private: | 57 private: |
| 58 scoped_ptr<sessions::TabRestoreServiceClient> client_; |
| 50 TabRestoreServiceHelper helper_; | 59 TabRestoreServiceHelper helper_; |
| 51 | 60 |
| 52 DISALLOW_COPY_AND_ASSIGN(InMemoryTabRestoreService); | 61 DISALLOW_COPY_AND_ASSIGN(InMemoryTabRestoreService); |
| 53 }; | 62 }; |
| 54 | 63 |
| 55 #endif // CHROME_BROWSER_SESSIONS_IN_MEMORY_TAB_RESTORE_SERVICE_H_ | 64 #endif // CHROME_BROWSER_SESSIONS_IN_MEMORY_TAB_RESTORE_SERVICE_H_ |
| OLD | NEW |