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

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..362bbf908e2edb592a40fbd878157c63d6503462 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,31 @@ 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();
+ // 1. Let url be the result of parsing url with entry settings object's API base URL.
+ ExecutionContext* context = scriptState->executionContext();
+
+ // 2. If url is failure, return a promise rejected with a TypeError.
+ KURL parsedUrl = KURL(toWorkerGlobalScope(context)->location()->url(), url);
+ if (!parsedUrl.isValid()) {
+ resolver->reject(DOMException::create(SyntaxError, "'" + url + "' is not a valid URL."));
+ return promise;
+ }
+
+ // 3. If url is about:blank, return a promise rejected with a TypeError.
+ // TODO
nhiroki 2015/06/23 01:18:13 Why don't you implement this in this CL?
zino 2015/06/23 03:42:15 Done.
+
+ // 4. If the context object's associated service worker client's active worker is not the incumbent
+ // settings object's global object's service worker, return a promise rejected with a TypeError.
nhiroki 2015/06/23 01:18:13 We should check this in the browser-side.
zino 2015/06/23 03:42:14 I got it. Could you please review chromium side pa
+ // TODO
nhiroki 2015/06/23 01:18:13 nit: TODO comment should be formatted as "TODO(nam
zino 2015/06/23 03:42:15 It's my mistake. I've just removed all the comment
+
+ 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