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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerWindowClient.cpp

Issue 866983004: Allow creating new windows from a notificationclick event in SW. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 10 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/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 ASSERT_NOT_REACHED(); 70 ASSERT_NOT_REACHED();
71 return String(); 71 return String();
72 } 72 }
73 73
74 ScriptPromise ServiceWorkerWindowClient::focus(ScriptState* scriptState) 74 ScriptPromise ServiceWorkerWindowClient::focus(ScriptState* scriptState)
75 { 75 {
76 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 76 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
77 ScriptPromise promise = resolver->promise(); 77 ScriptPromise promise = resolver->promise();
78 78
79 if (!scriptState->executionContext()->isWindowFocusAllowed()) { 79 if (!scriptState->executionContext()->isWindowInteractionAllowed()) {
80 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o focus a window.")); 80 resolver->reject(DOMException::create(InvalidAccessError, "Not allowed t o focus a window."));
81 return promise; 81 return promise;
82 } 82 }
83 scriptState->executionContext()->consumeWindowFocus(); 83 scriptState->executionContext()->consumeWindowInteraction();
84 84
85 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus (id(), new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError> (resolver)); 85 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus (id(), new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError> (resolver));
86 return promise; 86 return promise;
87 } 87 }
88 88
89 void ServiceWorkerWindowClient::trace(Visitor* visitor) 89 void ServiceWorkerWindowClient::trace(Visitor* visitor)
90 { 90 {
91 ServiceWorkerClient::trace(visitor); 91 ServiceWorkerClient::trace(visitor);
92 } 92 }
93 93
94 } // namespace blink 94 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerGlobalScope.h ('k') | Source/modules/serviceworkers/WaitUntilObserver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698