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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 672353003: Revert of [ServiceWorker] Don't allow registration of the ServiceWorker scope outside the script directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return promise; 128 return promise;
129 } 129 }
130 130
131 KURL scriptURL = executionContext->completeURL(url); 131 KURL scriptURL = executionContext->completeURL(url);
132 scriptURL.removeFragmentIdentifier(); 132 scriptURL.removeFragmentIdentifier();
133 if (!documentOrigin->canRequest(scriptURL)) { 133 if (!documentOrigin->canRequest(scriptURL)) {
134 resolver->reject(DOMException::create(SecurityError, "The origin of the script must match the current origin.")); 134 resolver->reject(DOMException::create(SecurityError, "The origin of the script must match the current origin."));
135 return promise; 135 return promise;
136 } 136 }
137 137
138 if (!patternURL.string().startsWith(scriptURL.baseAsString())) {
139 resolver->reject(DOMException::create(SecurityError, "The scope must be under the directory of the script URL."));
140 return promise;
141 }
142
143 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise Adapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver)); 138 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise Adapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver));
144 139
145 return promise; 140 return promise;
146 } 141 }
147 142
148 class BooleanValue { 143 class BooleanValue {
149 public: 144 public:
150 typedef bool WebType; 145 typedef bool WebType;
151 static bool take(ScriptPromiseResolver* resolver, WebType* boolean) 146 static bool take(ScriptPromiseResolver* resolver, WebType* boolean)
152 { 147 {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 m_ready = createReadyProperty(); 257 m_ready = createReadyProperty();
263 258
264 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 259 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
265 m_provider = client->provider(); 260 m_provider = client->provider();
266 if (m_provider) 261 if (m_provider)
267 m_provider->setClient(this); 262 m_provider->setClient(this);
268 } 263 }
269 } 264 }
270 265
271 } // namespace blink 266 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698