OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/service_worker/service_worker_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 326 |
327 std::string error_message; | 327 std::string error_message; |
328 if (ServiceWorkerUtils::ContainsDisallowedCharacter(pattern, script_url, | 328 if (ServiceWorkerUtils::ContainsDisallowedCharacter(pattern, script_url, |
329 &error_message)) { | 329 &error_message)) { |
330 bad_message::ReceivedBadMessage(this, bad_message::SWDH_REGISTER_CANNOT); | 330 bad_message::ReceivedBadMessage(this, bad_message::SWDH_REGISTER_CANNOT); |
331 return; | 331 return; |
332 } | 332 } |
333 | 333 |
334 std::vector<GURL> urls = {provider_host->document_url(), pattern, script_url}; | 334 std::vector<GURL> urls = {provider_host->document_url(), pattern, script_url}; |
335 if (!ServiceWorkerUtils::AllOriginsMatchAndCanAccessServiceWorkers(urls)) { | 335 if (!ServiceWorkerUtils::AllOriginsMatchAndCanAccessServiceWorkers(urls)) { |
336 // Temporary debugging for https://crbug.com/630495 | |
337 base::debug::ScopedCrashKey host_url_key( | |
338 "swdh_register_cannot_host_url", provider_host->document_url().spec()); | |
339 base::debug::ScopedCrashKey scope_url_key("swdh_register_cannot_scope_url", | |
340 pattern.spec()); | |
341 base::debug::ScopedCrashKey script_url_key( | |
342 "swdh_register_cannot_script_url", script_url.spec()); | |
343 bad_message::ReceivedBadMessage(this, bad_message::SWDH_REGISTER_CANNOT); | 336 bad_message::ReceivedBadMessage(this, bad_message::SWDH_REGISTER_CANNOT); |
344 return; | 337 return; |
345 } | 338 } |
346 | 339 |
347 if (!GetContentClient()->browser()->AllowServiceWorker( | 340 if (!GetContentClient()->browser()->AllowServiceWorker( |
348 pattern, provider_host->topmost_frame_url(), resource_context_, | 341 pattern, provider_host->topmost_frame_url(), resource_context_, |
349 base::Bind(&GetWebContents, render_process_id_, | 342 base::Bind(&GetWebContents, render_process_id_, |
350 provider_host->frame_id()))) { | 343 provider_host->frame_id()))) { |
351 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 344 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
352 thread_id, request_id, WebServiceWorkerError::ErrorTypeDisabled, | 345 thread_id, request_id, WebServiceWorkerError::ErrorTypeDisabled, |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 } | 544 } |
552 | 545 |
553 if (!document_url.is_valid()) { | 546 if (!document_url.is_valid()) { |
554 bad_message::ReceivedBadMessage(this, | 547 bad_message::ReceivedBadMessage(this, |
555 bad_message::SWDH_GET_REGISTRATION_BAD_URL); | 548 bad_message::SWDH_GET_REGISTRATION_BAD_URL); |
556 return; | 549 return; |
557 } | 550 } |
558 | 551 |
559 std::vector<GURL> urls = {provider_host->document_url(), document_url}; | 552 std::vector<GURL> urls = {provider_host->document_url(), document_url}; |
560 if (!ServiceWorkerUtils::AllOriginsMatchAndCanAccessServiceWorkers(urls)) { | 553 if (!ServiceWorkerUtils::AllOriginsMatchAndCanAccessServiceWorkers(urls)) { |
561 // Temporary debugging for https://crbug.com/630496 | |
562 base::debug::ScopedCrashKey host_url_key( | |
563 "swdh_get_registration_cannot_host_url", | |
564 provider_host->document_url().spec()); | |
565 base::debug::ScopedCrashKey document_url_key( | |
566 "swdh_get_registration_cannot_document_url", document_url.spec()); | |
567 bad_message::ReceivedBadMessage(this, | 554 bad_message::ReceivedBadMessage(this, |
568 bad_message::SWDH_GET_REGISTRATION_CANNOT); | 555 bad_message::SWDH_GET_REGISTRATION_CANNOT); |
569 return; | 556 return; |
570 } | 557 } |
571 | 558 |
572 if (!GetContentClient()->browser()->AllowServiceWorker( | 559 if (!GetContentClient()->browser()->AllowServiceWorker( |
573 provider_host->document_url(), provider_host->topmost_frame_url(), | 560 provider_host->document_url(), provider_host->topmost_frame_url(), |
574 resource_context_, base::Bind(&GetWebContents, render_process_id_, | 561 resource_context_, base::Bind(&GetWebContents, render_process_id_, |
575 provider_host->frame_id()))) { | 562 provider_host->frame_id()))) { |
576 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( | 563 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 if (!handle) { | 1754 if (!handle) { |
1768 bad_message::ReceivedBadMessage(this, | 1755 bad_message::ReceivedBadMessage(this, |
1769 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1756 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
1770 return; | 1757 return; |
1771 } | 1758 } |
1772 handle->version()->StopWorker( | 1759 handle->version()->StopWorker( |
1773 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1760 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1774 } | 1761 } |
1775 | 1762 |
1776 } // namespace content | 1763 } // namespace content |
OLD | NEW |