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

Unified Diff: Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp

Issue 1196193003: ServiceWorker: Implement navigate() method in WindowClient (blink side). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp b/Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp
index 6d463687cb700551454d8d8df8ebebc0cf40e520..c206772d2fa0596d194d11b3f4081d0d74b7364a 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"
@@ -58,6 +60,26 @@ 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.protocolIsAbout()) {
+ resolver->reject(V8ThrowException::createTypeError(scriptState->isolate(), "'" + url + "' is not a valid URL."));
+ return promise;
+ }
+ if (!context->securityOrigin()->canDisplay(parsedUrl)) {
+ resolver->reject(DOMException::create(SecurityError, "'" + parsedUrl.elidedString() + "' cannot navigate."));
+ return promise;
+ }
+
+ ServiceWorkerGlobalScopeClient::from(context)->navigate(uuid(), parsedUrl, new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError>(resolver));
+ return promise;
+}
+
DEFINE_TRACE(ServiceWorkerWindowClient)
{
ServiceWorkerClient::trace(visitor);
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerWindowClient.h ('k') | Source/modules/serviceworkers/WindowClient.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698