| 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/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/profiler/scoped_tracker.h" | 13 #include "base/profiler/scoped_tracker.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 16 #include "content/browser/bad_message.h" | 17 #include "content/browser/bad_message.h" |
| 17 #include "content/browser/message_port_message_filter.h" | 18 #include "content/browser/message_port_message_filter.h" |
| 18 #include "content/browser/message_port_service.h" | 19 #include "content/browser/message_port_service.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 if (provider_host->document_url().is_empty()) { | 314 if (provider_host->document_url().is_empty()) { |
| 314 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 315 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 315 thread_id, request_id, WebServiceWorkerError::ErrorTypeSecurity, | 316 thread_id, request_id, WebServiceWorkerError::ErrorTypeSecurity, |
| 316 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + | 317 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + |
| 317 base::ASCIIToUTF16(kNoDocumentURLErrorMessage))); | 318 base::ASCIIToUTF16(kNoDocumentURLErrorMessage))); |
| 318 return; | 319 return; |
| 319 } | 320 } |
| 320 | 321 |
| 321 if (!ServiceWorkerUtils::CanRegisterServiceWorker( | 322 if (!ServiceWorkerUtils::CanRegisterServiceWorker( |
| 322 provider_host->document_url(), pattern, script_url)) { | 323 provider_host->document_url(), pattern, script_url)) { |
| 324 // Temporary debugging for https://crbug.com/630495 |
| 325 base::debug::ScopedCrashKey host_url_key( |
| 326 "swdh_register_cannot_host_url", provider_host->document_url().spec()); |
| 327 base::debug::ScopedCrashKey scope_url_key("swdh_register_cannot_scope_url", |
| 328 pattern.spec()); |
| 329 base::debug::ScopedCrashKey script_url_key( |
| 330 "swdh_register_cannot_script_url", script_url.spec()); |
| 323 bad_message::ReceivedBadMessage(this, bad_message::SWDH_REGISTER_CANNOT); | 331 bad_message::ReceivedBadMessage(this, bad_message::SWDH_REGISTER_CANNOT); |
| 324 return; | 332 return; |
| 325 } | 333 } |
| 326 | 334 |
| 327 std::string error_message; | 335 std::string error_message; |
| 328 if (ServiceWorkerUtils::ContainsDisallowedCharacter(pattern, script_url, | 336 if (ServiceWorkerUtils::ContainsDisallowedCharacter(pattern, script_url, |
| 329 &error_message)) { | 337 &error_message)) { |
| 330 bad_message::ReceivedBadMessage(this, bad_message::SWDH_REGISTER_CANNOT); | 338 bad_message::ReceivedBadMessage(this, bad_message::SWDH_REGISTER_CANNOT); |
| 331 return; | 339 return; |
| 332 } | 340 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 if (!registration) { | 487 if (!registration) { |
| 480 // |registration| must be alive because a renderer retains a registration | 488 // |registration| must be alive because a renderer retains a registration |
| 481 // reference at this point. | 489 // reference at this point. |
| 482 bad_message::ReceivedBadMessage( | 490 bad_message::ReceivedBadMessage( |
| 483 this, bad_message::SWDH_UNREGISTER_BAD_REGISTRATION_ID); | 491 this, bad_message::SWDH_UNREGISTER_BAD_REGISTRATION_ID); |
| 484 return; | 492 return; |
| 485 } | 493 } |
| 486 | 494 |
| 487 if (!CanUnregisterServiceWorker(provider_host->document_url(), | 495 if (!CanUnregisterServiceWorker(provider_host->document_url(), |
| 488 registration->pattern())) { | 496 registration->pattern())) { |
| 497 // Temporary debugging for https://crbug.com/619294 |
| 498 base::debug::ScopedCrashKey host_url_key( |
| 499 "swdh_unregister_cannot_host_url", |
| 500 provider_host->document_url().spec()); |
| 501 base::debug::ScopedCrashKey scope_url_key( |
| 502 "swdh_unregister_cannot_scope_url", registration->pattern().spec()); |
| 489 bad_message::ReceivedBadMessage(this, bad_message::SWDH_UNREGISTER_CANNOT); | 503 bad_message::ReceivedBadMessage(this, bad_message::SWDH_UNREGISTER_CANNOT); |
| 490 return; | 504 return; |
| 491 } | 505 } |
| 492 | 506 |
| 493 if (!GetContentClient()->browser()->AllowServiceWorker( | 507 if (!GetContentClient()->browser()->AllowServiceWorker( |
| 494 registration->pattern(), provider_host->topmost_frame_url(), | 508 registration->pattern(), provider_host->topmost_frame_url(), |
| 495 resource_context_, render_process_id_, provider_host->frame_id())) { | 509 resource_context_, render_process_id_, provider_host->frame_id())) { |
| 496 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( | 510 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( |
| 497 thread_id, request_id, WebServiceWorkerError::ErrorTypeUnknown, | 511 thread_id, request_id, WebServiceWorkerError::ErrorTypeUnknown, |
| 498 base::ASCIIToUTF16(kUserDeniedPermissionMessage))); | 512 base::ASCIIToUTF16(kUserDeniedPermissionMessage))); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 // TODO(ksakamoto): This check can be removed once crbug.com/439697 is fixed. | 562 // TODO(ksakamoto): This check can be removed once crbug.com/439697 is fixed. |
| 549 if (provider_host->document_url().is_empty()) { | 563 if (provider_host->document_url().is_empty()) { |
| 550 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( | 564 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( |
| 551 thread_id, request_id, WebServiceWorkerError::ErrorTypeSecurity, | 565 thread_id, request_id, WebServiceWorkerError::ErrorTypeSecurity, |
| 552 base::ASCIIToUTF16(kServiceWorkerGetRegistrationErrorPrefix) + | 566 base::ASCIIToUTF16(kServiceWorkerGetRegistrationErrorPrefix) + |
| 553 base::ASCIIToUTF16(kNoDocumentURLErrorMessage))); | 567 base::ASCIIToUTF16(kNoDocumentURLErrorMessage))); |
| 554 return; | 568 return; |
| 555 } | 569 } |
| 556 | 570 |
| 557 if (!CanGetRegistration(provider_host->document_url(), document_url)) { | 571 if (!CanGetRegistration(provider_host->document_url(), document_url)) { |
| 572 // Temporary debugging for https://crbug.com/630496 |
| 573 base::debug::ScopedCrashKey host_url_key( |
| 574 "swdh_get_registration_cannot_host_url", |
| 575 provider_host->document_url().spec()); |
| 576 base::debug::ScopedCrashKey document_url_key( |
| 577 "swdh_get_registration_cannot_document_url", document_url.spec()); |
| 558 bad_message::ReceivedBadMessage(this, | 578 bad_message::ReceivedBadMessage(this, |
| 559 bad_message::SWDH_GET_REGISTRATION_CANNOT); | 579 bad_message::SWDH_GET_REGISTRATION_CANNOT); |
| 560 return; | 580 return; |
| 561 } | 581 } |
| 562 | 582 |
| 563 if (!GetContentClient()->browser()->AllowServiceWorker( | 583 if (!GetContentClient()->browser()->AllowServiceWorker( |
| 564 provider_host->document_url(), provider_host->topmost_frame_url(), | 584 provider_host->document_url(), provider_host->topmost_frame_url(), |
| 565 resource_context_, render_process_id_, provider_host->frame_id())) { | 585 resource_context_, render_process_id_, provider_host->frame_id())) { |
| 566 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( | 586 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( |
| 567 thread_id, request_id, WebServiceWorkerError::ErrorTypeUnknown, | 587 thread_id, request_id, WebServiceWorkerError::ErrorTypeUnknown, |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 if (!handle) { | 1427 if (!handle) { |
| 1408 bad_message::ReceivedBadMessage(this, | 1428 bad_message::ReceivedBadMessage(this, |
| 1409 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1429 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
| 1410 return; | 1430 return; |
| 1411 } | 1431 } |
| 1412 handle->version()->StopWorker( | 1432 handle->version()->StopWorker( |
| 1413 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1433 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1414 } | 1434 } |
| 1415 | 1435 |
| 1416 } // namespace content | 1436 } // namespace content |
| OLD | NEW |