| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/serviceworkers/ServiceWorkerClients.h" | 6 #include "modules/serviceworkers/ServiceWorkerClients.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 121 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
| 122 ScriptPromise promise = resolver->promise(); | 122 ScriptPromise promise = resolver->promise(); |
| 123 ExecutionContext* context = scriptState->executionContext(); | 123 ExecutionContext* context = scriptState->executionContext(); |
| 124 | 124 |
| 125 KURL parsedUrl = KURL(toWorkerGlobalScope(context)->location()->url(), url); | 125 KURL parsedUrl = KURL(toWorkerGlobalScope(context)->location()->url(), url); |
| 126 if (!parsedUrl.isValid()) { | 126 if (!parsedUrl.isValid()) { |
| 127 resolver->reject(DOMException::create(SyntaxError, "'" + url + "' is not
a valid URL.")); | 127 resolver->reject(DOMException::create(SyntaxError, "'" + url + "' is not
a valid URL.")); |
| 128 return promise; | 128 return promise; |
| 129 } | 129 } |
| 130 | 130 |
| 131 if (!context->securityOrigin()->canRequest(parsedUrl)) { | 131 if (!context->securityOrigin()->canDisplay(parsedUrl)) { |
| 132 resolver->reject(DOMException::create(SecurityError, "'" + parsedUrl.eli
dedString() + "' is not same-origin with the Worker.")); | 132 resolver->reject(DOMException::create(SecurityError, "'" + parsedUrl.eli
dedString() + "' cannot be opened.")); |
| 133 return promise; | 133 return promise; |
| 134 } | 134 } |
| 135 | 135 |
| 136 if (!context->isWindowInteractionAllowed()) { | 136 if (!context->isWindowInteractionAllowed()) { |
| 137 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t
o open a window.")); | 137 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t
o open a window.")); |
| 138 return promise; | 138 return promise; |
| 139 } | 139 } |
| 140 context->consumeWindowInteraction(); | 140 context->consumeWindowInteraction(); |
| 141 | 141 |
| 142 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Cal
lbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError>(resolver)); | 142 ServiceWorkerGlobalScopeClient::from(context)->openWindow(parsedUrl, new Cal
lbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError>(resolver)); |
| 143 return promise; | 143 return promise; |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace blink | 146 } // namespace blink |
| OLD | NEW |