Index: content/browser/service_worker/service_worker_client_utils.cc |
diff --git a/content/browser/service_worker/service_worker_client_utils.cc b/content/browser/service_worker/service_worker_client_utils.cc |
index 26ef4d35f181bd9a43c4bb5922c5698da78e6aa3..22ccb54fb54c33146098e156f062be2dc7ff8eb8 100644 |
--- a/content/browser/service_worker/service_worker_client_utils.cc |
+++ b/content/browser/service_worker/service_worker_client_utils.cc |
@@ -225,15 +225,33 @@ void AddNonWindowClient(ServiceWorkerProviderHost* host, |
options.client_type != host_client_type) |
return; |
- ServiceWorkerClientInfo client_info(blink::WebPageVisibilityStateHidden, |
- false, // is_focused |
- host->document_url(), |
- REQUEST_CONTEXT_FRAME_TYPE_NONE, |
- base::TimeTicks(), host_client_type); |
- client_info.client_uuid = host->client_uuid(); |
+ ServiceWorkerClientInfo client_info( |
+ host->client_uuid(), blink::WebPageVisibilityStateHidden, |
+ false, // is_focused |
+ host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE, base::TimeTicks(), |
+ host_client_type); |
clients->push_back(client_info); |
} |
+void OnGetWindowClientOnUI( |
+ int process_id, |
+ int frame_id, |
+ const std::string& client_uuid, |
+ const GURL& script_url, |
+ const ServiceWorkerProviderHost::GetClientInfoCallback& callback) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ |
+ ServiceWorkerClientInfo info = |
+ ServiceWorkerProviderHost::GetWindowClientInfoOnUI(process_id, frame_id, |
+ client_uuid); |
+ |
+ if (info.url.GetOrigin() != script_url.GetOrigin()) |
+ info = ServiceWorkerClientInfo(); |
+ |
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
+ base::Bind(callback, info)); |
+} |
+ |
void OnGetWindowClientsOnUI( |
// The tuple contains process_id, frame_id, client_uuid. |
const std::vector<base::Tuple<int, int, std::string>>& clients_info, |
@@ -243,8 +261,8 @@ void OnGetWindowClientsOnUI( |
for (const auto& it : clients_info) { |
ServiceWorkerClientInfo info = |
- ServiceWorkerProviderHost::GetWindowClientInfoOnUI(base::get<0>(it), |
- base::get<1>(it)); |
+ ServiceWorkerProviderHost::GetWindowClientInfoOnUI( |
+ base::get<0>(it), base::get<1>(it), base::get<2>(it)); |
// If the request to the provider_host returned an empty |
// ServiceWorkerClientInfo, that means that it wasn't possible to associate |
@@ -259,7 +277,6 @@ void OnGetWindowClientsOnUI( |
if (info.url.GetOrigin() != script_url.GetOrigin()) |
continue; |
- info.client_uuid = base::get<2>(it); |
clients->push_back(info); |
} |
@@ -371,6 +388,48 @@ void NavigateClient(const GURL& url, |
base::Bind(&DidNavigate, context, script_url.GetOrigin(), callback))); |
} |
+void GetClient( |
+ const base::WeakPtr<ServiceWorkerVersion>& controller, |
+ const std::string& client_uuid, |
+ const base::WeakPtr<ServiceWorkerContextCore>& context, |
+ const ServiceWorkerProviderHost::GetClientInfoCallback& callback) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ |
+ ServiceWorkerProviderHost* provider_host = |
+ context->GetProviderHostByClientID(client_uuid); |
+ |
+ if (!provider_host) { |
+ // The client may already have been closed, just ignore. |
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
+ base::Bind(callback, ServiceWorkerClientInfo())); |
+ return; |
+ } |
+ |
+ if (provider_host->client_type() == blink::WebServiceWorkerClientTypeWindow) { |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind(&OnGetWindowClientOnUI, provider_host->process_id(), |
+ provider_host->frame_id(), provider_host->client_uuid(), |
+ controller->script_url(), callback)); |
+ return; |
+ } |
+ |
+ if (provider_host->document_url().GetOrigin() != |
+ controller->script_url().GetOrigin()) { |
nhiroki
2016/02/17 02:40:28
This origin check should be done before line 408.
jungkees
2016/02/17 14:01:12
I moved this origin check to before line 408 and r
|
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
+ base::Bind(callback, ServiceWorkerClientInfo())); |
+ return; |
+ } |
+ |
nhiroki
2016/02/17 02:40:28
Can you add DCHECK here?
DCHECK(provider_host->cl
jungkees
2016/02/17 14:01:12
Done.
|
+ ServiceWorkerClientInfo client_info( |
+ provider_host->client_uuid(), blink::WebPageVisibilityStateHidden, |
+ false, // is_focused |
+ provider_host->document_url(), REQUEST_CONTEXT_FRAME_TYPE_NONE, |
+ base::TimeTicks(), provider_host->client_type()); |
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
+ base::Bind(callback, client_info)); |
+} |
+ |
void GetClients(const base::WeakPtr<ServiceWorkerVersion>& controller, |
const ServiceWorkerClientQueryOptions& options, |
const ClientsCallback& callback) { |