| 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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/browser/service_worker/embedded_worker_registry.h" | 8 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
| 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( | 84 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( |
| 85 int32 thread_id, | 85 int32 thread_id, |
| 86 int32 request_id, | 86 int32 request_id, |
| 87 const GURL& pattern, | 87 const GURL& pattern, |
| 88 const GURL& script_url) { | 88 const GURL& script_url) { |
| 89 if (!context_ || !context_->IsEnabled()) { | 89 if (!context_ || !context_->IsEnabled()) { |
| 90 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 90 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 91 thread_id, | 91 thread_id, |
| 92 request_id, | 92 request_id, |
| 93 WebServiceWorkerError::DisabledError, | 93 WebServiceWorkerError::DisabledError, |
| 94 ASCIIToUTF16(kDisabledErrorMessage))); | 94 base::ASCIIToUTF16(kDisabledErrorMessage))); |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 | 97 |
| 98 // TODO(alecflett): This check is insufficient for release. Add a | 98 // TODO(alecflett): This check is insufficient for release. Add a |
| 99 // ServiceWorker-specific policy query in | 99 // ServiceWorker-specific policy query in |
| 100 // ChildProcessSecurityImpl. See http://crbug.com/311631. | 100 // ChildProcessSecurityImpl. See http://crbug.com/311631. |
| 101 if (pattern.GetOrigin() != script_url.GetOrigin()) { | 101 if (pattern.GetOrigin() != script_url.GetOrigin()) { |
| 102 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 102 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 103 thread_id, | 103 thread_id, |
| 104 request_id, | 104 request_id, |
| 105 WebServiceWorkerError::SecurityError, | 105 WebServiceWorkerError::SecurityError, |
| 106 ASCIIToUTF16(kDomainMismatchErrorMessage))); | 106 base::ASCIIToUTF16(kDomainMismatchErrorMessage))); |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 | 109 |
| 110 context_->RegisterServiceWorker( | 110 context_->RegisterServiceWorker( |
| 111 pattern, | 111 pattern, |
| 112 script_url, | 112 script_url, |
| 113 base::Bind(&ServiceWorkerDispatcherHost::RegistrationComplete, | 113 base::Bind(&ServiceWorkerDispatcherHost::RegistrationComplete, |
| 114 this, | 114 this, |
| 115 thread_id, | 115 thread_id, |
| 116 request_id)); | 116 request_id)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( | 119 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( |
| 120 int32 thread_id, | 120 int32 thread_id, |
| 121 int32 request_id, | 121 int32 request_id, |
| 122 const GURL& pattern) { | 122 const GURL& pattern) { |
| 123 // TODO(alecflett): This check is insufficient for release. Add a | 123 // TODO(alecflett): This check is insufficient for release. Add a |
| 124 // ServiceWorker-specific policy query in | 124 // ServiceWorker-specific policy query in |
| 125 // ChildProcessSecurityImpl. See http://crbug.com/311631. | 125 // ChildProcessSecurityImpl. See http://crbug.com/311631. |
| 126 if (!context_ || !context_->IsEnabled()) { | 126 if (!context_ || !context_->IsEnabled()) { |
| 127 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 127 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 128 thread_id, | 128 thread_id, |
| 129 request_id, | 129 request_id, |
| 130 blink::WebServiceWorkerError::DisabledError, | 130 blink::WebServiceWorkerError::DisabledError, |
| 131 ASCIIToUTF16(kDisabledErrorMessage))); | 131 base::ASCIIToUTF16(kDisabledErrorMessage))); |
| 132 return; | 132 return; |
| 133 } | 133 } |
| 134 | 134 |
| 135 context_->UnregisterServiceWorker( | 135 context_->UnregisterServiceWorker( |
| 136 pattern, | 136 pattern, |
| 137 base::Bind(&ServiceWorkerDispatcherHost::UnregistrationComplete, | 137 base::Bind(&ServiceWorkerDispatcherHost::UnregistrationComplete, |
| 138 this, | 138 this, |
| 139 thread_id, | 139 thread_id, |
| 140 request_id)); | 140 request_id)); |
| 141 } | 141 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 ServiceWorkerRegistrationStatus status) { | 194 ServiceWorkerRegistrationStatus status) { |
| 195 base::string16 error_message; | 195 base::string16 error_message; |
| 196 blink::WebServiceWorkerError::ErrorType error_type; | 196 blink::WebServiceWorkerError::ErrorType error_type; |
| 197 GetServiceWorkerRegistrationStatusResponse( | 197 GetServiceWorkerRegistrationStatusResponse( |
| 198 status, &error_type, &error_message); | 198 status, &error_type, &error_message); |
| 199 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 199 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 200 thread_id, request_id, error_type, error_message)); | 200 thread_id, request_id, error_type, error_message)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace content | 203 } // namespace content |
| OLD | NEW |