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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SESSIONS_CORE_PERSISTENT_TAB_RESTORE_SERVICE_H_
6 #define COMPONENTS_SESSIONS_CORE_PERSISTENT_TAB_RESTORE_SERVICE_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/sessions/core/tab_restore_service.h"
14 #include "components/sessions/core/tab_restore_service_client.h"
15 #include "components/sessions/core/tab_restore_service_helper.h"
16 #include "components/sessions/sessions_export.h"
18 class PersistentTabRestoreServiceTest
;
22 // Tab restore service that persists data on disk.
23 class SESSIONS_EXPORT PersistentTabRestoreService
: public TabRestoreService
{
25 // Does not take ownership of |time_factory|.
26 PersistentTabRestoreService(scoped_ptr
<TabRestoreServiceClient
> client
,
27 TimeFactory
* time_factory
);
29 ~PersistentTabRestoreService() override
;
32 void AddObserver(TabRestoreServiceObserver
* observer
) override
;
33 void RemoveObserver(TabRestoreServiceObserver
* observer
) override
;
34 void CreateHistoricalTab(LiveTab
* live_tab
, int index
) override
;
35 void BrowserClosing(TabRestoreServiceDelegate
* delegate
) override
;
36 void BrowserClosed(TabRestoreServiceDelegate
* delegate
) override
;
37 void ClearEntries() override
;
38 const Entries
& entries() const override
;
39 std::vector
<LiveTab
*> RestoreMostRecentEntry(
40 TabRestoreServiceDelegate
* delegate
,
41 int host_desktop_type
) override
;
42 Tab
* RemoveTabEntryById(SessionID::id_type id
) override
;
43 std::vector
<LiveTab
*> RestoreEntryById(
44 TabRestoreServiceDelegate
* delegate
,
45 SessionID::id_type id
,
46 int host_desktop_type
,
47 WindowOpenDisposition disposition
) override
;
48 void LoadTabsFromLastSession() override
;
49 bool IsLoaded() const override
;
50 void DeleteLastSession() override
;
51 void Shutdown() override
;
54 friend class ::PersistentTabRestoreServiceTest
;
58 // Exposed for testing.
59 Entries
* mutable_entries();
62 scoped_ptr
<TabRestoreServiceClient
> client_
;
63 scoped_ptr
<Delegate
> delegate_
;
64 TabRestoreServiceHelper helper_
;
66 DISALLOW_COPY_AND_ASSIGN(PersistentTabRestoreService
);
69 } // namespace sessions
71 #endif // COMPONENTS_SESSIONS_CORE_PERSISTENT_TAB_RESTORE_SERVICE_H_