Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(842)

Side by Side Diff: components/sessions/core/tab_restore_service_client.h

Issue 1343833002: Abstract content::SessionStorageNamespace from core TabRestore code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extension_tab_helper
Patch Set: Response to review Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ 5 #ifndef COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_
6 #define COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ 6 #define COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
11 #include "components/sessions/session_id.h" 12 #include "components/sessions/session_id.h"
13 #include "components/sessions/sessions_export.h"
12 14
13 namespace base { 15 namespace base {
14 class CancelableTaskTracker; 16 class CancelableTaskTracker;
15 class SequencedWorkerPool; 17 class SequencedWorkerPool;
16 } 18 }
17 19
18 // TODO(blundell): Remove all references to WebContents from 20 // TODO(blundell): Remove all references to WebContents from
19 // TabRestoreServiceClient and get rid of this. crbug.com/530174 21 // TabRestoreServiceClient and get rid of this. crbug.com/530174
20 namespace content { 22 namespace content {
21 class WebContents; 23 class WebContents;
22 } 24 }
23 25
24 namespace sessions { 26 namespace sessions {
25 struct SessionWindow; 27 struct SessionWindow;
26 } 28 }
27 29
28 class GURL; 30 class GURL;
29 class TabRestoreServiceDelegate; 31 class TabRestoreServiceDelegate;
30 32
31 namespace sessions { 33 namespace sessions {
32 34
33 struct SessionWindow; 35 struct SessionWindow;
34 36
35 // Callback from TabRestoreServiceClient::GetLastSession. 37 // Callback from TabRestoreServiceClient::GetLastSession.
36 // The second parameter is the id of the window that was last active. 38 // The second parameter is the id of the window that was last active.
37 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)> 39 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)>
38 GetLastSessionCallback; 40 GetLastSessionCallback;
39 41
42 // A class that is used to associate embedder-specific data with
43 // TabRestoreService::Tab. See TabRestoreServiceClient::GetClientData().
44 // Subclasses of this class must be copyable by implementing the Clone() method
45 // for usage by the Tab struct, which is itself copyable and assignable.
46 class SESSIONS_EXPORT TabClientData {
47 public:
48 // TODO(blundell): Make this private once tab_restore_service.h is in the
49 // component and declare TabRestoreService::Tab a friend of this class.
50 virtual scoped_ptr<TabClientData> Clone() = 0;
51 virtual ~TabClientData();
52 };
53
40 // A client interface that needs to be supplied to the tab restore service by 54 // A client interface that needs to be supplied to the tab restore service by
41 // the embedder. 55 // the embedder.
42 class TabRestoreServiceClient { 56 class SESSIONS_EXPORT TabRestoreServiceClient {
43 public: 57 public:
44 virtual ~TabRestoreServiceClient() {} 58 virtual ~TabRestoreServiceClient();
45 59
46 // Creates a TabRestoreServiceDelegate instance that is associated with 60 // Creates a TabRestoreServiceDelegate instance that is associated with
47 // |host_desktop_type| and |app_name|. May return nullptr (e.g., if the 61 // |host_desktop_type| and |app_name|. May return nullptr (e.g., if the
48 // embedder does not support TabRestoreServiceDelegate functionality). 62 // embedder does not support TabRestoreServiceDelegate functionality).
49 // Note that |host_desktop_type| is opaque to the component; the only values 63 // Note that |host_desktop_type| is opaque to the component; the only values
50 // that will be passed here are those that have been passed *in* to the 64 // that will be passed here are those that have been passed *in* to the
51 // component from the embedder via TabRestoreService. 65 // component from the embedder via TabRestoreService.
52 virtual TabRestoreServiceDelegate* CreateTabRestoreServiceDelegate( 66 virtual TabRestoreServiceDelegate* CreateTabRestoreServiceDelegate(
53 int host_desktop_type, 67 int host_desktop_type,
54 const std::string& app_name) = 0; 68 const std::string& app_name) = 0;
(...skipping 19 matching lines...) Expand all
74 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0; 88 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0;
75 89
76 // Returns the extension app ID for the given WebContents, or the empty string 90 // Returns the extension app ID for the given WebContents, or the empty string
77 // if there is no such ID (e.g., if extensions are not supported by the 91 // if there is no such ID (e.g., if extensions are not supported by the
78 // embedder). 92 // embedder).
79 // TODO(blundell): Replace the usage of WebContents here with the cross- 93 // TODO(blundell): Replace the usage of WebContents here with the cross-
80 // platform interface that will abstract it. crbug.com/530174 94 // platform interface that will abstract it. crbug.com/530174
81 virtual std::string GetExtensionAppIDForWebContents( 95 virtual std::string GetExtensionAppIDForWebContents(
82 content::WebContents* web_contents) = 0; 96 content::WebContents* web_contents) = 0;
83 97
98 // Returns any client data that should be associated with the
99 // TabRestoreService::Tab corresponding to |web_contents|. That tab will own
100 // this TabClientData instance. The default implementation returns null.
101 virtual scoped_ptr<TabClientData> GetTabClientDataForWebContents(
102 content::WebContents* web_contents);
103
84 // Get the sequenced worker pool for running tasks on the backend thread as 104 // Get the sequenced worker pool for running tasks on the backend thread as
85 // long as the system is not shutting down. 105 // long as the system is not shutting down.
86 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; 106 virtual base::SequencedWorkerPool* GetBlockingPool() = 0;
87 107
88 // Returns the path of the directory to save state into. 108 // Returns the path of the directory to save state into.
89 virtual base::FilePath GetPathToSaveTo() = 0; 109 virtual base::FilePath GetPathToSaveTo() = 0;
90 110
91 // Returns the URL that corresponds to the new tab page. 111 // Returns the URL that corresponds to the new tab page.
92 virtual GURL GetNewTabURL() = 0; 112 virtual GURL GetNewTabURL() = 0;
93 113
94 // Returns whether there is a previous session to load. 114 // Returns whether there is a previous session to load.
95 virtual bool HasLastSession() = 0; 115 virtual bool HasLastSession() = 0;
96 116
97 // Fetches the contents of the last session, notifying the callback when 117 // Fetches the contents of the last session, notifying the callback when
98 // done. If the callback is supplied an empty vector of SessionWindows 118 // done. If the callback is supplied an empty vector of SessionWindows
99 // it means the session could not be restored. 119 // it means the session could not be restored.
100 virtual void GetLastSession(const GetLastSessionCallback& callback, 120 virtual void GetLastSession(const GetLastSessionCallback& callback,
101 base::CancelableTaskTracker* tracker) = 0; 121 base::CancelableTaskTracker* tracker) = 0;
102 122
103 // Called when a tab is restored. |url| is the URL that the tab is currently 123 // Called when a tab is restored. |url| is the URL that the tab is currently
104 // visiting. 124 // visiting.
105 virtual void OnTabRestored(const GURL& url) {} 125 virtual void OnTabRestored(const GURL& url);
106 }; 126 };
107 127
108 } // namespace sessions 128 } // namespace sessions
109 129
110 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ 130 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_
OLDNEW
« no previous file with comments | « components/sessions/content/content_tab_client_data.cc ('k') | components/sessions/core/tab_restore_service_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698