| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 if (ServiceWorkerUtils::ContainsDisallowedCharacter(pattern, script_url, | 325 if (ServiceWorkerUtils::ContainsDisallowedCharacter(pattern, script_url, |
| 326 &error_message)) { | 326 &error_message)) { |
| 327 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 327 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 328 thread_id, request_id, WebServiceWorkerError::ErrorTypeSecurity, | 328 thread_id, request_id, WebServiceWorkerError::ErrorTypeSecurity, |
| 329 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + | 329 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + |
| 330 base::UTF8ToUTF16(error_message))); | 330 base::UTF8ToUTF16(error_message))); |
| 331 return; | 331 return; |
| 332 } | 332 } |
| 333 | 333 |
| 334 if (!GetContentClient()->browser()->AllowServiceWorker( | 334 if (!GetContentClient()->browser()->AllowServiceWorker( |
| 335 pattern, provider_host->topmost_frame_url(), resource_context_)) { | 335 pattern, provider_host->topmost_frame_url(), resource_context_, |
| 336 render_process_id_, provider_host->frame_id())) { |
| 336 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 337 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 337 thread_id, request_id, WebServiceWorkerError::ErrorTypeUnknown, | 338 thread_id, request_id, WebServiceWorkerError::ErrorTypeUnknown, |
| 338 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + | 339 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + |
| 339 base::ASCIIToUTF16(kUserDeniedPermissionMessage))); | 340 base::ASCIIToUTF16(kUserDeniedPermissionMessage))); |
| 340 return; | 341 return; |
| 341 } | 342 } |
| 342 | 343 |
| 343 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", | 344 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", |
| 344 "ServiceWorkerDispatcherHost::RegisterServiceWorker", | 345 "ServiceWorkerDispatcherHost::RegisterServiceWorker", |
| 345 request_id, | 346 request_id, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 base::ASCIIToUTF16(kNoDocumentURLErrorMessage))); | 401 base::ASCIIToUTF16(kNoDocumentURLErrorMessage))); |
| 401 return; | 402 return; |
| 402 } | 403 } |
| 403 | 404 |
| 404 if (!CanUnregisterServiceWorker(provider_host->document_url(), pattern)) { | 405 if (!CanUnregisterServiceWorker(provider_host->document_url(), pattern)) { |
| 405 BadMessageReceived(); | 406 BadMessageReceived(); |
| 406 return; | 407 return; |
| 407 } | 408 } |
| 408 | 409 |
| 409 if (!GetContentClient()->browser()->AllowServiceWorker( | 410 if (!GetContentClient()->browser()->AllowServiceWorker( |
| 410 pattern, provider_host->topmost_frame_url(), resource_context_)) { | 411 pattern, provider_host->topmost_frame_url(), resource_context_, |
| 412 render_process_id_, provider_host->frame_id())) { |
| 411 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( | 413 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( |
| 412 thread_id, | 414 thread_id, |
| 413 request_id, | 415 request_id, |
| 414 WebServiceWorkerError::ErrorTypeUnknown, | 416 WebServiceWorkerError::ErrorTypeUnknown, |
| 415 base::ASCIIToUTF16(kUserDeniedPermissionMessage))); | 417 base::ASCIIToUTF16(kUserDeniedPermissionMessage))); |
| 416 return; | 418 return; |
| 417 } | 419 } |
| 418 | 420 |
| 419 TRACE_EVENT_ASYNC_BEGIN1( | 421 TRACE_EVENT_ASYNC_BEGIN1( |
| 420 "ServiceWorker", | 422 "ServiceWorker", |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 base::ASCIIToUTF16(kNoDocumentURLErrorMessage))); | 472 base::ASCIIToUTF16(kNoDocumentURLErrorMessage))); |
| 471 return; | 473 return; |
| 472 } | 474 } |
| 473 | 475 |
| 474 if (!CanGetRegistration(provider_host->document_url(), document_url)) { | 476 if (!CanGetRegistration(provider_host->document_url(), document_url)) { |
| 475 BadMessageReceived(); | 477 BadMessageReceived(); |
| 476 return; | 478 return; |
| 477 } | 479 } |
| 478 | 480 |
| 479 if (!GetContentClient()->browser()->AllowServiceWorker( | 481 if (!GetContentClient()->browser()->AllowServiceWorker( |
| 480 provider_host->document_url(), | 482 provider_host->document_url(), provider_host->topmost_frame_url(), |
| 481 provider_host->topmost_frame_url(), | 483 resource_context_, render_process_id_, provider_host->frame_id())) { |
| 482 resource_context_)) { | |
| 483 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( | 484 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( |
| 484 thread_id, request_id, WebServiceWorkerError::ErrorTypeUnknown, | 485 thread_id, request_id, WebServiceWorkerError::ErrorTypeUnknown, |
| 485 base::ASCIIToUTF16(kServiceWorkerGetRegistrationErrorPrefix) + | 486 base::ASCIIToUTF16(kServiceWorkerGetRegistrationErrorPrefix) + |
| 486 base::ASCIIToUTF16(kUserDeniedPermissionMessage))); | 487 base::ASCIIToUTF16(kUserDeniedPermissionMessage))); |
| 487 return; | 488 return; |
| 488 } | 489 } |
| 489 | 490 |
| 490 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 491 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 491 if (GetContext()->storage()->IsDisabled()) { | 492 if (GetContext()->storage()->IsDisabled()) { |
| 492 SendGetRegistrationError(thread_id, request_id, SERVICE_WORKER_ERROR_ABORT); | 493 SendGetRegistrationError(thread_id, request_id, SERVICE_WORKER_ERROR_ABORT); |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); | 1033 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); |
| 1033 if (!handle) { | 1034 if (!handle) { |
| 1034 BadMessageReceived(); | 1035 BadMessageReceived(); |
| 1035 return; | 1036 return; |
| 1036 } | 1037 } |
| 1037 handle->version()->StopWorker( | 1038 handle->version()->StopWorker( |
| 1038 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1039 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1039 } | 1040 } |
| 1040 | 1041 |
| 1041 } // namespace content | 1042 } // namespace content |
| OLD | NEW |