Chromium Code Reviews| Index: Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp |
| diff --git a/Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp b/Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp |
| index 65e1ef5a4589559b04d208d5f0b93ef4c121e4a5..062a6ed410918ad76cabf50a2b82f925b663671b 100644 |
| --- a/Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp |
| +++ b/Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp |
| @@ -10,6 +10,8 @@ |
| #include "core/dom/DOMException.h" |
| #include "core/dom/ExceptionCode.h" |
| #include "core/page/PageVisibilityState.h" |
| +#include "core/workers/WorkerGlobalScope.h" |
| +#include "core/workers/WorkerLocation.h" |
| #include "modules/serviceworkers/ServiceWorkerError.h" |
| #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
| #include "public/platform/WebString.h" |
| @@ -63,6 +65,22 @@ ScriptPromise ServiceWorkerWindowClient::focus(ScriptState* scriptState) |
| return promise; |
| } |
| +ScriptPromise ServiceWorkerWindowClient::navigate(ScriptState* scriptState, const String& url) |
| +{ |
| + RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState); |
| + ScriptPromise promise = resolver->promise(); |
| + ExecutionContext* context = scriptState->executionContext(); |
| + |
| + KURL parsedUrl = KURL(toWorkerGlobalScope(context)->location()->url(), url); |
| + if (!parsedUrl.isValid() || parsedUrl.isAboutBlankURL()) { |
| + resolver->reject(DOMException::create(SyntaxError, "'" + url + "' is not a valid URL.")); |
| + return promise; |
| + } |
| + |
|
nhiroki
2015/06/24 06:58:29
Could you check |url| by "SecurityOrigin::canDispl
zino
2015/07/07 15:39:43
Done.
|
| + ServiceWorkerGlobalScopeClient::from(context)->navigate(uuid(), parsedUrl, new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError>(resolver)); |
| + return promise; |
| +} |
| + |
| DEFINE_TRACE(ServiceWorkerWindowClient) |
| { |
| ServiceWorkerClient::trace(visitor); |