| 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 CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_NAVIGATION_UTILS_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_UTILS_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_NAVIGATION_UTILS_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_UTILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 12 #include "content/common/service_worker/service_worker_status_code.h" | 13 #include "content/common/service_worker/service_worker_status_code.h" |
| 13 | 14 |
| 14 class GURL; | 15 class GURL; |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 class ServiceWorkerContextCore; | 19 class ServiceWorkerContextCore; |
| 20 class ServiceWorkerVersion; |
| 19 struct ServiceWorkerClientInfo; | 21 struct ServiceWorkerClientInfo; |
| 22 struct ServiceWorkerClientQueryOptions; |
| 20 | 23 |
| 21 namespace service_worker_client_navigation_utils { | 24 namespace service_worker_client_utils { |
| 22 | 25 |
| 23 using NavigationCallback = | 26 using NavigationCallback = |
| 24 base::Callback<void(ServiceWorkerStatusCode status, | 27 base::Callback<void(ServiceWorkerStatusCode status, |
| 25 const std::string& client_uuid, | 28 const std::string& client_uuid, |
| 26 const ServiceWorkerClientInfo& client_info)>; | 29 const ServiceWorkerClientInfo& client_info)>; |
| 30 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; |
| 31 using ClientsCallback = base::Callback<void(ServiceWorkerClients* clients)>; |
| 27 | 32 |
| 28 // Opens a new window and navigates it to |url|. |callback| is called with the | 33 // Opens a new window and navigates it to |url|. |callback| is called with the |
| 29 // window's client information on completion. | 34 // window's client information on completion. |
| 30 void OpenWindow(const GURL& url, | 35 void OpenWindow(const GURL& url, |
| 31 const GURL& script_url, | 36 const GURL& script_url, |
| 32 int worker_process_id, | 37 int worker_process_id, |
| 33 const base::WeakPtr<ServiceWorkerContextCore>& context, | 38 const base::WeakPtr<ServiceWorkerContextCore>& context, |
| 34 const NavigationCallback& callback); | 39 const NavigationCallback& callback); |
| 35 | 40 |
| 36 // Navigates the client specified by |process_id| and |frame_id| to |url|. | 41 // Navigates the client specified by |process_id| and |frame_id| to |url|. |
| 37 // |callback| is called with the client information on completion. | 42 // |callback| is called with the client information on completion. |
| 38 void NavigateClient(const GURL& url, | 43 void NavigateClient(const GURL& url, |
| 39 const GURL& script_url, | 44 const GURL& script_url, |
| 40 int process_id, | 45 int process_id, |
| 41 int frame_id, | 46 int frame_id, |
| 42 const base::WeakPtr<ServiceWorkerContextCore>& context, | 47 const base::WeakPtr<ServiceWorkerContextCore>& context, |
| 43 const NavigationCallback& callback); | 48 const NavigationCallback& callback); |
| 44 | 49 |
| 45 } // namespace service_worker_client_navigation_utils | 50 // Collects clients matched with |options|. |callback| is called with the client |
| 51 // information sorted in MRU order (most recently focused order) on completion. |
| 52 void GetClients(const base::WeakPtr<ServiceWorkerVersion>& controller, |
| 53 const ServiceWorkerClientQueryOptions& options, |
| 54 const ClientsCallback& callback); |
| 55 |
| 56 } // namespace service_worker_client_utils |
| 46 | 57 |
| 47 } // namespace content | 58 } // namespace content |
| 48 | 59 |
| 49 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_NAVIGATION_UTILS
_H_ | 60 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CLIENT_UTILS_H_ |
| OLD | NEW |