OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/renderer/service_worker/service_worker_script_context.h" | 5 #include "content/renderer/service_worker/service_worker_script_context.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "content/child/notifications/notification_data_conversions.h" | 10 #include "content/child/notifications/notification_data_conversions.h" |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 clients.size()); | 461 clients.size()); |
462 for (size_t i = 0; i < clients.size(); ++i) | 462 for (size_t i = 0; i < clients.size(); ++i) |
463 convertedClients[i] = ToWebServiceWorkerClientInfo(clients[i]); | 463 convertedClients[i] = ToWebServiceWorkerClientInfo(clients[i]); |
464 info->clients.swap(convertedClients); | 464 info->clients.swap(convertedClients); |
465 callbacks->onSuccess(info.release()); | 465 callbacks->onSuccess(info.release()); |
466 pending_clients_callbacks_.Remove(request_id); | 466 pending_clients_callbacks_.Remove(request_id); |
467 } | 467 } |
468 | 468 |
469 void ServiceWorkerScriptContext::OnOpenWindowResponse( | 469 void ServiceWorkerScriptContext::OnOpenWindowResponse( |
470 int request_id, | 470 int request_id, |
| 471 const GURL& url, |
471 const ServiceWorkerClientInfo& client) { | 472 const ServiceWorkerClientInfo& client) { |
472 TRACE_EVENT0("ServiceWorker", | 473 TRACE_EVENT0("ServiceWorker", |
473 "ServiceWorkerScriptContext::OnOpenWindowResponse"); | 474 "ServiceWorkerScriptContext::OnOpenWindowResponse"); |
474 blink::WebServiceWorkerClientCallbacks* callbacks = | 475 blink::WebServiceWorkerClientCallbacks* callbacks = |
475 pending_client_callbacks_.Lookup(request_id); | 476 pending_client_callbacks_.Lookup(request_id); |
476 if (!callbacks) { | 477 if (!callbacks) { |
477 NOTREACHED() << "Got stray response: " << request_id; | 478 NOTREACHED() << "Got stray response: " << request_id; |
478 return; | 479 return; |
479 } | 480 } |
480 scoped_ptr<blink::WebServiceWorkerClientInfo> web_client; | 481 scoped_ptr<blink::WebServiceWorkerClientInfo> web_client; |
481 if (!client.IsEmpty()) { | 482 if (!client.IsEmpty()) { |
482 DCHECK(client.IsValid()); | 483 DCHECK(client.IsValid()); |
483 web_client.reset(new blink::WebServiceWorkerClientInfo( | 484 web_client.reset(new blink::WebServiceWorkerClientInfo( |
484 ToWebServiceWorkerClientInfo(client))); | 485 ToWebServiceWorkerClientInfo(client))); |
485 } | 486 } |
486 callbacks->onSuccess(web_client.release()); | 487 if (url.GetOrigin() != client.url.GetOrigin()) |
| 488 callbacks->onSuccess(nullptr); |
| 489 else |
| 490 callbacks->onSuccess(web_client.release()); |
487 pending_client_callbacks_.Remove(request_id); | 491 pending_client_callbacks_.Remove(request_id); |
488 } | 492 } |
489 | 493 |
490 void ServiceWorkerScriptContext::OnOpenWindowError(int request_id) { | 494 void ServiceWorkerScriptContext::OnOpenWindowError(int request_id) { |
491 TRACE_EVENT0("ServiceWorker", | 495 TRACE_EVENT0("ServiceWorker", |
492 "ServiceWorkerScriptContext::OnOpenWindowError"); | 496 "ServiceWorkerScriptContext::OnOpenWindowError"); |
493 blink::WebServiceWorkerClientCallbacks* callbacks = | 497 blink::WebServiceWorkerClientCallbacks* callbacks = |
494 pending_client_callbacks_.Lookup(request_id); | 498 pending_client_callbacks_.Lookup(request_id); |
495 if (!callbacks) { | 499 if (!callbacks) { |
496 NOTREACHED() << "Got stray response: " << request_id; | 500 NOTREACHED() << "Got stray response: " << request_id; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 new blink::WebServiceWorkerError(error_type, message)); | 577 new blink::WebServiceWorkerError(error_type, message)); |
574 callbacks->onError(error.release()); | 578 callbacks->onError(error.release()); |
575 pending_claim_clients_callbacks_.Remove(request_id); | 579 pending_claim_clients_callbacks_.Remove(request_id); |
576 } | 580 } |
577 | 581 |
578 void ServiceWorkerScriptContext::OnPing() { | 582 void ServiceWorkerScriptContext::OnPing() { |
579 Send(new ServiceWorkerHostMsg_Pong(GetRoutingID())); | 583 Send(new ServiceWorkerHostMsg_Pong(GetRoutingID())); |
580 } | 584 } |
581 | 585 |
582 } // namespace content | 586 } // namespace content |
OLD | NEW |