Chromium Code Reviews| Index: content/browser/service_worker/service_worker_dispatcher_host.cc |
| diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc |
| index a60f8bb3e936befb84b226ca651ac1e316f8ea87..bab772259d901a67ce9611b10f78481a010623b7 100644 |
| --- a/content/browser/service_worker/service_worker_dispatcher_host.cc |
| +++ b/content/browser/service_worker/service_worker_dispatcher_host.cc |
| @@ -4,11 +4,15 @@ |
| #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "content/browser/service_worker/service_worker_context.h" |
| #include "content/common/service_worker_messages.h" |
| #include "ipc/ipc_message_macros.h" |
| +#include "third_party/WebKit/public/platform/WebServiceWorkerError.h" |
| #include "url/gurl.h" |
| +using WebKit::WebServiceWorkerError; |
| + |
| namespace content { |
| ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( |
| @@ -56,6 +60,15 @@ void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( |
| if (scope.GetOrigin() != script_url.GetOrigin()) |
| return; |
| + if (!context_->enabled()) { |
| + Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| + thread_id, |
| + request_id, |
| + WebKit::WebServiceWorkerError::DisabledError, |
| + ASCIIToUTF16("ServiceWorker is disabled"))); |
|
Tom Sepez
2013/10/25 18:46:59
nit: maybe a kSomething constant instead of the st
alecflett
2013/10/25 20:05:02
This merely a temporary state until the flag is re
|
| + return; |
| + } |
| + |
| Send(new ServiceWorkerMsg_ServiceWorkerRegistered( |
| thread_id, request_id, NextWorkerId())); |
| } |
| @@ -66,6 +79,15 @@ void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(int32 thread_id, |
| // TODO(alecflett): add a ServiceWorker-specific policy query in |
| // ChildProcessSecurityImpl. See http://crbug.com/311631. |
| + if (!context_->enabled()) { |
| + Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| + thread_id, |
| + request_id, |
| + WebServiceWorkerError::DisabledError, |
| + ASCIIToUTF16("ServiceWorker is disabled"))); |
| + return; |
| + } |
| + |
| Send(new ServiceWorkerMsg_ServiceWorkerUnregistered( |
| thread_id, request_id)); |
| } |