Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 17 matching lines...) Expand all Loading... | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 31 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ScriptPromise.h" | 33 #include "bindings/core/v8/ScriptPromise.h" |
| 34 #include "bindings/core/v8/ScriptPromiseResolver.h" | 34 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 35 #include "bindings/core/v8/ScriptState.h" | 35 #include "bindings/core/v8/ScriptState.h" |
| 36 #include "bindings/core/v8/SerializedScriptValue.h" | 36 #include "bindings/core/v8/SerializedScriptValue.h" |
| 37 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 37 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 38 #include "bindings/core/v8/V8ThrowException.h" | |
| 38 #include "core/dom/DOMException.h" | 39 #include "core/dom/DOMException.h" |
| 39 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
| 40 #include "core/dom/ExceptionCode.h" | 41 #include "core/dom/ExceptionCode.h" |
| 41 #include "core/dom/ExecutionContext.h" | 42 #include "core/dom/ExecutionContext.h" |
| 42 #include "core/dom/MessagePort.h" | 43 #include "core/dom/MessagePort.h" |
| 43 #include "core/frame/LocalDOMWindow.h" | 44 #include "core/frame/LocalDOMWindow.h" |
| 44 #include "modules/EventTargetModules.h" | 45 #include "modules/EventTargetModules.h" |
| 45 #include "modules/serviceworkers/ServiceWorker.h" | 46 #include "modules/serviceworkers/ServiceWorker.h" |
| 46 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" | 47 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
| 47 #include "modules/serviceworkers/ServiceWorkerError.h" | 48 #include "modules/serviceworkers/ServiceWorkerError.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 if (!documentOrigin->canRequest(patternURL)) { | 240 if (!documentOrigin->canRequest(patternURL)) { |
| 240 RefPtr<SecurityOrigin> patternOrigin = SecurityOrigin::create(patternURL ); | 241 RefPtr<SecurityOrigin> patternOrigin = SecurityOrigin::create(patternURL ); |
| 241 resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The origin of the provided scope ('" + patternOrigin->toString () + "') does not match the current origin ('" + documentOrigin->toString() + "' ).")); | 242 resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The origin of the provided scope ('" + patternOrigin->toString () + "') does not match the current origin ('" + documentOrigin->toString() + "' ).")); |
| 242 return promise; | 243 return promise; |
| 243 } | 244 } |
| 244 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(patternURL .protocol())) { | 245 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(patternURL .protocol())) { |
| 245 resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The URL protocol of the scope ('" + patternURL.string() + "') is not supported.")); | 246 resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The URL protocol of the scope ('" + patternURL.string() + "') is not supported.")); |
| 246 return promise; | 247 return promise; |
| 247 } | 248 } |
| 248 | 249 |
| 250 WebString webErrorMessage; | |
| 251 if (!m_provider->validateScopeAndScriptURL(patternURL, scriptURL, &webErrorM essage)) { | |
|
falken
2015/08/05 06:54:23
Ah it's kind of weird that validateScopeAndScript
nhiroki
2015/08/05 07:15:09
Ah, good point. Moving validateSASURL into Platfor
nhiroki
2015/08/05 07:31:58
I had an offline chat w/ jeremy and falken. We dec
| |
| 252 resolver->reject(V8ThrowException::createTypeError(scriptState->isolate( ), WebString::fromUTF8("Failed to register a ServiceWorker: " + webErrorMessage. utf8()))); | |
| 253 return promise; | |
| 254 } | |
| 255 | |
| 249 m_provider->registerServiceWorker(patternURL, scriptURL, new RegistrationCal lback(resolver)); | 256 m_provider->registerServiceWorker(patternURL, scriptURL, new RegistrationCal lback(resolver)); |
| 250 | 257 |
| 251 return promise; | 258 return promise; |
| 252 } | 259 } |
| 253 | 260 |
| 254 ScriptPromise ServiceWorkerContainer::getRegistration(ScriptState* scriptState, const String& documentURL) | 261 ScriptPromise ServiceWorkerContainer::getRegistration(ScriptState* scriptState, const String& documentURL) |
| 255 { | 262 { |
| 256 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); | 263 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); |
| 257 ScriptPromise promise = resolver->promise(); | 264 ScriptPromise promise = resolver->promise(); |
| 258 | 265 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 return; | 397 return; |
| 391 | 398 |
| 392 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { | 399 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { |
| 393 m_provider = client->provider(); | 400 m_provider = client->provider(); |
| 394 if (m_provider) | 401 if (m_provider) |
| 395 m_provider->setClient(this); | 402 m_provider->setClient(this); |
| 396 } | 403 } |
| 397 } | 404 } |
| 398 | 405 |
| 399 } // namespace blink | 406 } // namespace blink |
| OLD | NEW |