| OLD | NEW |
| 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_ptr.h" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "components/sessions/session_id.h" | 12 #include "components/sessions/session_id.h" |
| 13 #include "components/sessions/sessions_export.h" | 13 #include "components/sessions/sessions_export.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class CancelableTaskTracker; | 16 class CancelableTaskTracker; |
| 17 class SequencedWorkerPool; | 17 class SequencedWorkerPool; |
| 18 } | 18 } |
| 19 | 19 |
| 20 // TODO(blundell): Remove all references to WebContents from | 20 // TODO(blundell): Remove all references to WebContents from |
| 21 // TabRestoreServiceClient and get rid of this. crbug.com/530174 | 21 // TabRestoreServiceClient and get rid of this. crbug.com/530174 |
| 22 namespace content { | 22 namespace content { |
| 23 class WebContents; | 23 class WebContents; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace sessions { | |
| 27 struct SessionWindow; | |
| 28 } | |
| 29 | |
| 30 class GURL; | 26 class GURL; |
| 31 class TabRestoreServiceDelegate; | 27 class TabRestoreServiceDelegate; |
| 32 | 28 |
| 33 namespace sessions { | 29 namespace sessions { |
| 34 | 30 |
| 31 class OpenTab; |
| 35 struct SessionWindow; | 32 struct SessionWindow; |
| 36 | 33 |
| 37 // Callback from TabRestoreServiceClient::GetLastSession. | 34 // Callback from TabRestoreServiceClient::GetLastSession. |
| 38 // The second parameter is the id of the window that was last active. | 35 // The second parameter is the id of the window that was last active. |
| 39 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)> | 36 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)> |
| 40 GetLastSessionCallback; | 37 GetLastSessionCallback; |
| 41 | 38 |
| 42 // A class that is used to associate embedder-specific data with | 39 // A class that is used to associate embedder-specific data with |
| 43 // TabRestoreService::Tab. See TabRestoreServiceClient::GetClientData(). | 40 // TabRestoreService::Tab. See TabRestoreServiceClient::GetClientData(). |
| 44 // Subclasses of this class must be copyable by implementing the Clone() method | 41 // Subclasses of this class must be copyable by implementing the Clone() method |
| (...skipping 16 matching lines...) Expand all Loading... |
| 61 // |host_desktop_type| and |app_name|. May return nullptr (e.g., if the | 58 // |host_desktop_type| and |app_name|. May return nullptr (e.g., if the |
| 62 // embedder does not support TabRestoreServiceDelegate functionality). | 59 // embedder does not support TabRestoreServiceDelegate functionality). |
| 63 // Note that |host_desktop_type| is opaque to the component; the only values | 60 // Note that |host_desktop_type| is opaque to the component; the only values |
| 64 // that will be passed here are those that have been passed *in* to the | 61 // that will be passed here are those that have been passed *in* to the |
| 65 // component from the embedder via TabRestoreService. | 62 // component from the embedder via TabRestoreService. |
| 66 virtual TabRestoreServiceDelegate* CreateTabRestoreServiceDelegate( | 63 virtual TabRestoreServiceDelegate* CreateTabRestoreServiceDelegate( |
| 67 int host_desktop_type, | 64 int host_desktop_type, |
| 68 const std::string& app_name) = 0; | 65 const std::string& app_name) = 0; |
| 69 | 66 |
| 70 // Returns the TabRestoreServiceDelegate instance that is associated with | 67 // Returns the TabRestoreServiceDelegate instance that is associated with |
| 71 // |contents|, or null if there is no such instance. | 68 // |tab|, or null if there is no such instance. |
| 72 // TODO(blundell): Replace the usage of WebContents here with the cross- | 69 virtual TabRestoreServiceDelegate* FindTabRestoreServiceDelegateForTab( |
| 73 // platform interface that will abstract it. crbug.com/530174 | 70 const OpenTab* tab) = 0; |
| 74 virtual TabRestoreServiceDelegate* | |
| 75 FindTabRestoreServiceDelegateForWebContents( | |
| 76 const content::WebContents* contents) = 0; | |
| 77 | 71 |
| 78 // Returns the TabRestoreServiceDelegate instance that is associated with | 72 // Returns the TabRestoreServiceDelegate instance that is associated with |
| 79 // |desired_id| and |host_desktop_type|, or null if there is no such instance. | 73 // |desired_id| and |host_desktop_type|, or null if there is no such instance. |
| 80 // Note that |host_desktop_type| is opaque to the component; the only values | 74 // Note that |host_desktop_type| is opaque to the component; the only values |
| 81 // that will be passed here are those that have been passed *in* to the | 75 // that will be passed here are those that have been passed *in* to the |
| 82 // component from the embedder via TabRestoreService. | 76 // component from the embedder via TabRestoreService. |
| 83 virtual TabRestoreServiceDelegate* FindTabRestoreServiceDelegateWithID( | 77 virtual TabRestoreServiceDelegate* FindTabRestoreServiceDelegateWithID( |
| 84 SessionID::id_type desired_id, | 78 SessionID::id_type desired_id, |
| 85 int host_desktop_type) = 0; | 79 int host_desktop_type) = 0; |
| 86 | 80 |
| 87 // Returns whether a given URL should be tracked for restoring. | 81 // Returns whether a given URL should be tracked for restoring. |
| 88 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0; | 82 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0; |
| 89 | 83 |
| 90 // Returns the extension app ID for the given WebContents, or the empty string | 84 // Returns the extension app ID for the given WebContents, or the empty string |
| 91 // if there is no such ID (e.g., if extensions are not supported by the | 85 // if there is no such ID (e.g., if extensions are not supported by the |
| 92 // embedder). | 86 // embedder). |
| 93 // TODO(blundell): Replace the usage of WebContents here with the cross- | 87 virtual std::string GetExtensionAppIDForTab(OpenTab* tab) = 0; |
| 94 // platform interface that will abstract it. crbug.com/530174 | |
| 95 virtual std::string GetExtensionAppIDForWebContents( | |
| 96 content::WebContents* web_contents) = 0; | |
| 97 | 88 |
| 98 // Returns any client data that should be associated with the | 89 // Returns any client data that should be associated with the |
| 99 // TabRestoreService::Tab corresponding to |web_contents|. That tab will own | 90 // TabRestoreService::Tab corresponding to |tab|. That tab will own |
| 100 // this TabClientData instance. The default implementation returns null. | 91 // this TabClientData instance. The default implementation returns null. |
| 101 virtual scoped_ptr<TabClientData> GetTabClientDataForWebContents( | 92 virtual scoped_ptr<TabClientData> GetTabClientDataForTab(OpenTab* tab); |
| 102 content::WebContents* web_contents); | |
| 103 | 93 |
| 104 // Get the sequenced worker pool for running tasks on the backend thread as | 94 // Get the sequenced worker pool for running tasks on the backend thread as |
| 105 // long as the system is not shutting down. | 95 // long as the system is not shutting down. |
| 106 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; | 96 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; |
| 107 | 97 |
| 108 // Returns the path of the directory to save state into. | 98 // Returns the path of the directory to save state into. |
| 109 virtual base::FilePath GetPathToSaveTo() = 0; | 99 virtual base::FilePath GetPathToSaveTo() = 0; |
| 110 | 100 |
| 111 // Returns the URL that corresponds to the new tab page. | 101 // Returns the URL that corresponds to the new tab page. |
| 112 virtual GURL GetNewTabURL() = 0; | 102 virtual GURL GetNewTabURL() = 0; |
| 113 | 103 |
| 114 // Returns whether there is a previous session to load. | 104 // Returns whether there is a previous session to load. |
| 115 virtual bool HasLastSession() = 0; | 105 virtual bool HasLastSession() = 0; |
| 116 | 106 |
| 117 // Fetches the contents of the last session, notifying the callback when | 107 // Fetches the contents of the last session, notifying the callback when |
| 118 // done. If the callback is supplied an empty vector of SessionWindows | 108 // done. If the callback is supplied an empty vector of SessionWindows |
| 119 // it means the session could not be restored. | 109 // it means the session could not be restored. |
| 120 virtual void GetLastSession(const GetLastSessionCallback& callback, | 110 virtual void GetLastSession(const GetLastSessionCallback& callback, |
| 121 base::CancelableTaskTracker* tracker) = 0; | 111 base::CancelableTaskTracker* tracker) = 0; |
| 122 | 112 |
| 123 // Called when a tab is restored. |url| is the URL that the tab is currently | 113 // Called when a tab is restored. |url| is the URL that the tab is currently |
| 124 // visiting. | 114 // visiting. |
| 125 virtual void OnTabRestored(const GURL& url); | 115 virtual void OnTabRestored(const GURL& url); |
| 126 }; | 116 }; |
| 127 | 117 |
| 128 } // namespace sessions | 118 } // namespace sessions |
| 129 | 119 |
| 130 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ | 120 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ |
| OLD | NEW |