Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 26442004: Service worker registration error support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update to reflect changes from dependent bug Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/browser/service_worker/service_worker_context.h" 8 #include "content/browser/service_worker/service_worker_context.h"
8 #include "content/common/service_worker_messages.h" 9 #include "content/common/service_worker_messages.h"
9 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
11 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h"
10 #include "url/gurl.h" 12 #include "url/gurl.h"
11 13
14 using WebKit::WebServiceWorkerError;
15
12 namespace content { 16 namespace content {
13 17
14 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( 18 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost(
15 int render_process_id, 19 int render_process_id,
16 ServiceWorkerContext* context) 20 ServiceWorkerContext* context)
17 : render_process_id_(render_process_id), context_(context) {} 21 : render_process_id_(render_process_id), context_(context) {}
18 22
19 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() {} 23 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() {}
20 24
21 bool ServiceWorkerDispatcherHost::OnMessageReceived(const IPC::Message& message, 25 bool ServiceWorkerDispatcherHost::OnMessageReceived(const IPC::Message& message,
(...skipping 27 matching lines...) Expand all
49 const GURL& scope, 53 const GURL& scope,
50 const GURL& script_url) { 54 const GURL& script_url) {
51 // TODO(alecflett): add a ServiceWorker-specific policy query in 55 // TODO(alecflett): add a ServiceWorker-specific policy query in
52 // ChildProcessSecurityImpl. See http://crbug.com/311631. 56 // ChildProcessSecurityImpl. See http://crbug.com/311631.
53 57
54 // TODO(alecflett): Throw an error for origin mismatch, rather than 58 // TODO(alecflett): Throw an error for origin mismatch, rather than
55 // just returning. 59 // just returning.
56 if (scope.GetOrigin() != script_url.GetOrigin()) 60 if (scope.GetOrigin() != script_url.GetOrigin())
57 return; 61 return;
58 62
63 if (!context_->enabled()) {
64 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
65 thread_id,
66 request_id,
67 WebKit::WebServiceWorkerError::DisabledError,
68 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
69 return;
70 }
71
59 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( 72 Send(new ServiceWorkerMsg_ServiceWorkerRegistered(
60 thread_id, request_id, NextWorkerId())); 73 thread_id, request_id, NextWorkerId()));
61 } 74 }
62 75
63 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(int32 thread_id, 76 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(int32 thread_id,
64 int32 request_id, 77 int32 request_id,
65 const GURL& scope) { 78 const GURL& scope) {
66 // TODO(alecflett): add a ServiceWorker-specific policy query in 79 // TODO(alecflett): add a ServiceWorker-specific policy query in
67 // ChildProcessSecurityImpl. See http://crbug.com/311631. 80 // ChildProcessSecurityImpl. See http://crbug.com/311631.
68 81
82 if (!context_->enabled()) {
83 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
84 thread_id,
85 request_id,
86 WebServiceWorkerError::DisabledError,
87 ASCIIToUTF16("ServiceWorker is disabled")));
88 return;
89 }
90
69 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered( 91 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(
70 thread_id, request_id)); 92 thread_id, request_id));
71 } 93 }
72 94
73 } // namespace content 95 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698