| 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_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "components/sessions/session_id.h" | 11 #include "components/sessions/session_id.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 class CancelableTaskTracker; | 14 class CancelableTaskTracker; |
| 15 class SequencedWorkerPool; | 15 class SequencedWorkerPool; |
| 16 } | 16 } |
| 17 | 17 |
| 18 // TODO(blundell): Remove all references to WebContents from |
| 19 // TabRestoreServiceClient and get rid of this. crbug.com/530174 |
| 20 namespace content { |
| 21 class WebContents; |
| 22 } |
| 23 |
| 18 namespace sessions { | 24 namespace sessions { |
| 19 struct SessionWindow; | 25 struct SessionWindow; |
| 20 } | 26 } |
| 21 | 27 |
| 22 class GURL; | 28 class GURL; |
| 29 class TabRestoreServiceDelegate; |
| 23 | 30 |
| 24 namespace sessions { | 31 namespace sessions { |
| 25 | 32 |
| 26 struct SessionWindow; | 33 struct SessionWindow; |
| 27 | 34 |
| 28 // Callback from TabRestoreServiceClient::GetLastSession. | 35 // Callback from TabRestoreServiceClient::GetLastSession. |
| 29 // The second parameter is the id of the window that was last active. | 36 // The second parameter is the id of the window that was last active. |
| 30 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)> | 37 typedef base::Callback<void(ScopedVector<SessionWindow>, SessionID::id_type)> |
| 31 GetLastSessionCallback; | 38 GetLastSessionCallback; |
| 32 | 39 |
| 33 // A client interface that needs to be supplied to the tab restore service by | 40 // A client interface that needs to be supplied to the tab restore service by |
| 34 // the embedder. | 41 // the embedder. |
| 35 class TabRestoreServiceClient { | 42 class TabRestoreServiceClient { |
| 36 public: | 43 public: |
| 37 virtual ~TabRestoreServiceClient() {} | 44 virtual ~TabRestoreServiceClient() {} |
| 38 | 45 |
| 46 // Creates a TabRestoreServiceDelegate instance that is associated with |
| 47 // |host_desktop_type| and |app_name|. May return nullptr (e.g., if the |
| 48 // embedder does not support TabRestoreServiceDelegate functionality). |
| 49 // 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 |
| 51 // component from the embedder via TabRestoreService. |
| 52 virtual TabRestoreServiceDelegate* CreateTabRestoreServiceDelegate( |
| 53 int host_desktop_type, |
| 54 const std::string& app_name) = 0; |
| 55 |
| 56 // Returns the TabRestoreServiceDelegate instance that is associated with |
| 57 // |contents|, or null if there is no such instance. |
| 58 // TODO(blundell): Replace the usage of WebContents here with the cross- |
| 59 // platform interface that will abstract it. crbug.com/530174 |
| 60 virtual TabRestoreServiceDelegate* |
| 61 FindTabRestoreServiceDelegateForWebContents( |
| 62 const content::WebContents* contents) = 0; |
| 63 |
| 64 // Returns the TabRestoreServiceDelegate instance that is associated with |
| 65 // |desired_id| and |host_desktop_type|, or null if there is no such instance. |
| 66 // Note that |host_desktop_type| is opaque to the component; the only values |
| 67 // that will be passed here are those that have been passed *in* to the |
| 68 // component from the embedder via TabRestoreService. |
| 69 virtual TabRestoreServiceDelegate* FindTabRestoreServiceDelegateWithID( |
| 70 SessionID::id_type desired_id, |
| 71 int host_desktop_type) = 0; |
| 72 |
| 39 // Returns whether a given URL should be tracked for restoring. | 73 // Returns whether a given URL should be tracked for restoring. |
| 40 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0; | 74 virtual bool ShouldTrackURLForRestore(const GURL& url) = 0; |
| 41 | 75 |
| 42 // Get the sequenced worker pool for running tasks on the backend thread as | 76 // Get the sequenced worker pool for running tasks on the backend thread as |
| 43 // long as the system is not shutting down. | 77 // long as the system is not shutting down. |
| 44 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; | 78 virtual base::SequencedWorkerPool* GetBlockingPool() = 0; |
| 45 | 79 |
| 46 // Returns the path of the directory to save state into. | 80 // Returns the path of the directory to save state into. |
| 47 virtual base::FilePath GetPathToSaveTo() = 0; | 81 virtual base::FilePath GetPathToSaveTo() = 0; |
| 48 | 82 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 59 base::CancelableTaskTracker* tracker) = 0; | 93 base::CancelableTaskTracker* tracker) = 0; |
| 60 | 94 |
| 61 // Called when a tab is restored. |url| is the URL that the tab is currently | 95 // Called when a tab is restored. |url| is the URL that the tab is currently |
| 62 // visiting. | 96 // visiting. |
| 63 virtual void OnTabRestored(const GURL& url) {} | 97 virtual void OnTabRestored(const GURL& url) {} |
| 64 }; | 98 }; |
| 65 | 99 |
| 66 } // namespace sessions | 100 } // namespace sessions |
| 67 | 101 |
| 68 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ | 102 #endif // COMPONENTS_SESSIONS_CORE_TAB_RESTORE_SERVICE_CLIENT_H_ |
| OLD | NEW |