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

Side by Side 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 unified diff | Download patch
OLDNEW
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/ServiceWorkerWindowClient.h" 6 #include "modules/serviceworkers/ServiceWorkerWindowClient.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/DOMException.h" 10 #include "core/dom/DOMException.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/page/PageVisibilityState.h" 12 #include "core/page/PageVisibilityState.h"
13 #include "core/workers/WorkerGlobalScope.h"
14 #include "core/workers/WorkerLocation.h"
13 #include "modules/serviceworkers/ServiceWorkerError.h" 15 #include "modules/serviceworkers/ServiceWorkerError.h"
14 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" 16 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
15 #include "public/platform/WebString.h" 17 #include "public/platform/WebString.h"
16 #include "wtf/RefPtr.h" 18 #include "wtf/RefPtr.h"
17 19
18 namespace blink { 20 namespace blink {
19 21
20 ServiceWorkerWindowClient* ServiceWorkerWindowClient::take(ScriptPromiseResolver *, ServiceWorkerWindowClient::WebType* webClientRaw) 22 ServiceWorkerWindowClient* ServiceWorkerWindowClient::take(ScriptPromiseResolver *, ServiceWorkerWindowClient::WebType* webClientRaw)
21 { 23 {
22 return ServiceWorkerWindowClient::create(*webClientRaw); 24 return ServiceWorkerWindowClient::create(*webClientRaw);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (!scriptState->executionContext()->isWindowInteractionAllowed()) { 58 if (!scriptState->executionContext()->isWindowInteractionAllowed()) {
57 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o focus a window.")); 59 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o focus a window."));
58 return promise; 60 return promise;
59 } 61 }
60 scriptState->executionContext()->consumeWindowInteraction(); 62 scriptState->executionContext()->consumeWindowInteraction();
61 63
62 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus (uuid(), new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerErro r>(resolver)); 64 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus (uuid(), new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerErro r>(resolver));
63 return promise; 65 return promise;
64 } 66 }
65 67
68 ScriptPromise ServiceWorkerWindowClient::navigate(ScriptState* scriptState, cons t String& url)
69 {
70 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
71 ScriptPromise promise = resolver->promise();
72 ExecutionContext* context = scriptState->executionContext();
73
74 KURL parsedUrl = KURL(toWorkerGlobalScope(context)->location()->url(), url);
75 if (!parsedUrl.isValid() || parsedUrl.isAboutBlankURL()) {
76 resolver->reject(DOMException::create(SyntaxError, "'" + url + "' is not a valid URL."));
77 return promise;
78 }
79
nhiroki 2015/06/24 06:58:29 Could you check |url| by "SecurityOrigin::canDispl
zino 2015/07/07 15:39:43 Done.
80 ServiceWorkerGlobalScopeClient::from(context)->navigate(uuid(), parsedUrl, n ew CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError>(resolve r));
81 return promise;
82 }
83
66 DEFINE_TRACE(ServiceWorkerWindowClient) 84 DEFINE_TRACE(ServiceWorkerWindowClient)
67 { 85 {
68 ServiceWorkerClient::trace(visitor); 86 ServiceWorkerClient::trace(visitor);
69 } 87 }
70 88
71 } // namespace blink 89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698