Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / sessions / core / tab_restore_service_client.h
blob6a2cc367108311a54ce43aaee219efa9ea2f2e7a
1 // Copyright 2015 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_TAB_RESTORE_SERVICE_CLIENT_H_
6 #define COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_
8 #include "base/callback.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "components/sessions/session_id.h"
13 #include "components/sessions/sessions_export.h"
15 namespace base {
16 class CancelableTaskTracker;
17 class SequencedWorkerPool;
20 class GURL;
22 namespace sessions {
24 class LiveTab;
25 struct SessionWindow;
26 class TabRestoreServiceDelegate;
28 // Callback from TabRestoreServiceClient::GetLastSession.
29 // The second parameter is the id of the window that was last active.
30 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)>
31 GetLastSessionCallback;
33 // A client interface that needs to be supplied to the tab restore service by
34 // the embedder.
35 class SESSIONS_EXPORT TabRestoreServiceClient {
36 public:
37 virtual ~TabRestoreServiceClient();
39 // Creates a TabRestoreServiceDelegate instance that is associated with
40 // |host_desktop_type| and |app_name|. May return nullptr (e.g., if the
41 // embedder does not support TabRestoreServiceDelegate functionality).
42 // Note that |host_desktop_type| is opaque to the component; the only values
43 // that will be passed here are those that have been passed *in* to the
44 // component from the embedder via TabRestoreService.
45 virtual TabRestoreServiceDelegate* CreateTabRestoreServiceDelegate(
46 int host_desktop_type,
47 const std::string& app_name) = 0;
49 // Returns the TabRestoreServiceDelegate instance that is associated with
50 // |tab|, or null if there is no such instance.
51 virtual TabRestoreServiceDelegate* FindTabRestoreServiceDelegateForTab(
52 const LiveTab* tab) = 0;
54 // Returns the TabRestoreServiceDelegate instance that is associated with
55 // |desired_id| and |host_desktop_type|, or null if there is no such instance.
56 // Note that |host_desktop_type| is opaque to the component; the only values
57 // that will be passed here are those that have been passed *in* to the
58 // component from the embedder via TabRestoreService.
59 virtual TabRestoreServiceDelegate* FindTabRestoreServiceDelegateWithID(
60 SessionID::id_type desired_id,
61 int host_desktop_type) = 0;
63 // Returns whether a given URL should be tracked for restoring.
64 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0;
66 // Returns the extension app ID for the given LiveTab, or the empty string
67 // if there is no such ID (e.g., if extensions are not supported by the
68 // embedder).
69 virtual std::string GetExtensionAppIDForTab(LiveTab* tab) = 0;
71 // Get the sequenced worker pool for running tasks on the backend thread as
72 // long as the system is not shutting down.
73 virtual base::SequencedWorkerPool* GetBlockingPool() = 0;
75 // Returns the path of the directory to save state into.
76 virtual base::FilePath GetPathToSaveTo() = 0;
78 // Returns the URL that corresponds to the new tab page.
79 virtual GURL GetNewTabURL() = 0;
81 // Returns whether there is a previous session to load.
82 virtual bool HasLastSession() = 0;
84 // Fetches the contents of the last session, notifying the callback when
85 // done. If the callback is supplied an empty vector of SessionWindows
86 // it means the session could not be restored.
87 virtual void GetLastSession(const GetLastSessionCallback& callback,
88 base::CancelableTaskTracker* tracker) = 0;
90 // Called when a tab is restored. |url| is the URL that the tab is currently
91 // visiting.
92 virtual void OnTabRestored(const GURL& url);
95 } // namespace sessions
97 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_