Chromium Code Reviews| 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/ref_counted.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 class SESSIONS_EXPORT TabClientData : public base::RefCounted<TabClientData> { | |
|
blundell
2015/09/15 19:38:57
Note that this class needs to be refcounted becaus
sky
2015/09/15 21:59:49
I hate to propagate that. How about a Clone() meth
blundell
2015/09/16 11:53:51
Done.
| |
| 45 protected: | |
| 46 virtual ~TabClientData() {} | |
| 47 | |
| 48 private: | |
| 49 friend class base::RefCounted<TabClientData>; | |
| 50 }; | |
| 51 | |
| 40 // A client interface that needs to be supplied to the tab restore service by | 52 // A client interface that needs to be supplied to the tab restore service by |
| 41 // the embedder. | 53 // the embedder. |
| 42 class TabRestoreServiceClient { | 54 class SESSIONS_EXPORT TabRestoreServiceClient { |
| 43 public: | 55 public: |
| 44 virtual ~TabRestoreServiceClient() {} | 56 virtual ~TabRestoreServiceClient() {} |
| 45 | 57 |
| 46 // Creates a TabRestoreServiceDelegate instance that is associated with | 58 // Creates a TabRestoreServiceDelegate instance that is associated with |
| 47 // |host_desktop_type| and |app_name|. May return nullptr (e.g., if the | 59 // |host_desktop_type| and |app_name|. May return nullptr (e.g., if the |
| 48 // embedder does not support TabRestoreServiceDelegate functionality). | 60 // embedder does not support TabRestoreServiceDelegate functionality). |
| 49 // Note that |host_desktop_type| is opaque to the component; the only values | 61 // 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 | 62 // that will be passed here are those that have been passed *in* to the |
| 51 // component from the embedder via TabRestoreService. | 63 // component from the embedder via TabRestoreService. |
| 52 virtual TabRestoreServiceDelegate* CreateTabRestoreServiceDelegate( | 64 virtual TabRestoreServiceDelegate* CreateTabRestoreServiceDelegate( |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 74 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0; | 86 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0; |
| 75 | 87 |
| 76 // Returns the extension app ID for the given WebContents, or the empty string | 88 // 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 | 89 // if there is no such ID (e.g., if extensions are not supported by the |
| 78 // embedder). | 90 // embedder). |
| 79 // TODO(blundell): Replace the usage of WebContents here with the cross- | 91 // TODO(blundell): Replace the usage of WebContents here with the cross- |
| 80 // platform interface that will abstract it. crbug.com/530174 | 92 // platform interface that will abstract it. crbug.com/530174 |
| 81 virtual std::string GetExtensionAppIDForWebContents( | 93 virtual std::string GetExtensionAppIDForWebContents( |
| 82 content::WebContents* web_contents) = 0; | 94 content::WebContents* web_contents) = 0; |
| 83 | 95 |
| 96 // Returns any client data that should be associated with the | |
| 97 // TabRestoreService::Tab corresponding to |web_contents|. That tab will own | |
| 98 // this reference to the returned data. | |
| 99 virtual scoped_refptr<TabClientData> GetTabClientDataForWebContents( | |
| 100 content::WebContents* web_contents) = 0; | |
| 101 | |
| 84 // Get the sequenced worker pool for running tasks on the backend thread as | 102 // Get the sequenced worker pool for running tasks on the backend thread as |
| 85 // long as the system is not shutting down. | 103 // long as the system is not shutting down. |
| 86 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; | 104 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; |
| 87 | 105 |
| 88 // Returns the path of the directory to save state into. | 106 // Returns the path of the directory to save state into. |
| 89 virtual base::FilePath GetPathToSaveTo() = 0; | 107 virtual base::FilePath GetPathToSaveTo() = 0; |
| 90 | 108 |
| 91 // Returns the URL that corresponds to the new tab page. | 109 // Returns the URL that corresponds to the new tab page. |
| 92 virtual GURL GetNewTabURL() = 0; | 110 virtual GURL GetNewTabURL() = 0; |
| 93 | 111 |
| 94 // Returns whether there is a previous session to load. | 112 // Returns whether there is a previous session to load. |
| 95 virtual bool HasLastSession() = 0; | 113 virtual bool HasLastSession() = 0; |
| 96 | 114 |
| 97 // Fetches the contents of the last session, notifying the callback when | 115 // Fetches the contents of the last session, notifying the callback when |
| 98 // done. If the callback is supplied an empty vector of SessionWindows | 116 // done. If the callback is supplied an empty vector of SessionWindows |
| 99 // it means the session could not be restored. | 117 // it means the session could not be restored. |
| 100 virtual void GetLastSession(const GetLastSessionCallback& callback, | 118 virtual void GetLastSession(const GetLastSessionCallback& callback, |
| 101 base::CancelableTaskTracker* tracker) = 0; | 119 base::CancelableTaskTracker* tracker) = 0; |
| 102 | 120 |
| 103 // Called when a tab is restored. |url| is the URL that the tab is currently | 121 // Called when a tab is restored. |url| is the URL that the tab is currently |
| 104 // visiting. | 122 // visiting. |
| 105 virtual void OnTabRestored(const GURL& url) {} | 123 virtual void OnTabRestored(const GURL& url) {} |
| 106 }; | 124 }; |
| 107 | 125 |
| 108 } // namespace sessions | 126 } // namespace sessions |
| 109 | 127 |
| 110 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ | 128 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ |
| OLD | NEW |