OLD | NEW |
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 Loading... |
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 |
OLD | NEW |