| 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/service_worker_context_core.h" | 8 #include "content/browser/service_worker/service_worker_context_core.h" |
| 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 9 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 10 #include "content/browser/service_worker/service_worker_provider_host.h" | 10 #include "content/browser/service_worker/service_worker_provider_host.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 OnProviderDestroyed) | 76 OnProviderDestroyed) |
| 77 IPC_MESSAGE_UNHANDLED(handled = false) | 77 IPC_MESSAGE_UNHANDLED(handled = false) |
| 78 IPC_END_MESSAGE_MAP() | 78 IPC_END_MESSAGE_MAP() |
| 79 | 79 |
| 80 return handled; | 80 return handled; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( | 83 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( |
| 84 int32 thread_id, | 84 int32 thread_id, |
| 85 int32 request_id, | 85 int32 request_id, |
| 86 const GURL& scope, | 86 const GURL& pattern, |
| 87 const GURL& script_url) { | 87 const GURL& script_url) { |
| 88 if (!context_ || !context_->IsEnabled()) { | 88 if (!context_ || !context_->IsEnabled()) { |
| 89 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 89 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 90 thread_id, | 90 thread_id, |
| 91 request_id, | 91 request_id, |
| 92 blink::WebServiceWorkerError::DisabledError, | 92 blink::WebServiceWorkerError::DisabledError, |
| 93 ASCIIToUTF16(kDisabledErrorMessage))); | 93 ASCIIToUTF16(kDisabledErrorMessage))); |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // TODO(alecflett): This check is insufficient for release. Add a | 97 // TODO(alecflett): This check is insufficient for release. Add a |
| 98 // ServiceWorker-specific policy query in | 98 // ServiceWorker-specific policy query in |
| 99 // ChildProcessSecurityImpl. See http://crbug.com/311631. | 99 // ChildProcessSecurityImpl. See http://crbug.com/311631. |
| 100 if (scope.GetOrigin() != script_url.GetOrigin()) { | 100 if (pattern.GetOrigin() != script_url.GetOrigin()) { |
| 101 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 101 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 102 thread_id, | 102 thread_id, |
| 103 request_id, | 103 request_id, |
| 104 blink::WebServiceWorkerError::SecurityError, | 104 blink::WebServiceWorkerError::SecurityError, |
| 105 ASCIIToUTF16(kDomainMismatchErrorMessage))); | 105 ASCIIToUTF16(kDomainMismatchErrorMessage))); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 | 108 |
| 109 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( | 109 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( |
| 110 thread_id, request_id, NextWorkerId())); | 110 thread_id, request_id, NextWorkerId())); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(int32 thread_id, | 113 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( |
| 114 int32 request_id, | 114 int32 thread_id, |
| 115 const GURL& scope) { | 115 int32 request_id, |
| 116 const GURL& pattern) { |
| 116 // TODO(alecflett): This check is insufficient for release. Add a | 117 // TODO(alecflett): This check is insufficient for release. Add a |
| 117 // ServiceWorker-specific policy query in | 118 // ServiceWorker-specific policy query in |
| 118 // ChildProcessSecurityImpl. See http://crbug.com/311631. | 119 // ChildProcessSecurityImpl. See http://crbug.com/311631. |
| 119 if (!context_ || !context_->IsEnabled()) { | 120 if (!context_ || !context_->IsEnabled()) { |
| 120 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 121 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 121 thread_id, | 122 thread_id, |
| 122 request_id, | 123 request_id, |
| 123 blink::WebServiceWorkerError::DisabledError, | 124 blink::WebServiceWorkerError::DisabledError, |
| 124 ASCIIToUTF16(kDisabledErrorMessage))); | 125 ASCIIToUTF16(kDisabledErrorMessage))); |
| 125 return; | 126 return; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 144 if (!context_) | 145 if (!context_) |
| 145 return; | 146 return; |
| 146 if (!context_->GetProviderHost(render_process_id_, provider_id)) { | 147 if (!context_->GetProviderHost(render_process_id_, provider_id)) { |
| 147 BadMessageReceived(); | 148 BadMessageReceived(); |
| 148 return; | 149 return; |
| 149 } | 150 } |
| 150 context_->RemoveProviderHost(render_process_id_, provider_id); | 151 context_->RemoveProviderHost(render_process_id_, provider_id); |
| 151 } | 152 } |
| 152 | 153 |
| 153 } // namespace content | 154 } // namespace content |
| OLD | NEW |