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

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, 6 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 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);

Powered by Google App Engine
This is Rietveld 408576698