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