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" |
11 #include "core/page/PageVisibilityState.h" | 11 #include "core/page/PageVisibilityState.h" |
12 #include "core/page/WindowFocusAllowedIndicator.h" | 12 #include "core/page/WindowFocusAllowedIndicator.h" |
13 #include "modules/serviceworkers/ServiceWorkerError.h" | 13 #include "modules/serviceworkers/ServiceWorkerError.h" |
14 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 14 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
15 #include "public/platform/WebString.h" | 15 #include "public/platform/WebString.h" |
16 #include "wtf/RefPtr.h" | 16 #include "wtf/RefPtr.h" |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
| 20 ServiceWorkerWindowClient* ServiceWorkerWindowClient::take(ScriptPromiseResolver
*, ServiceWorkerWindowClient::WebType* webClientRaw) |
| 21 { |
| 22 return ServiceWorkerWindowClient::create(*webClientRaw); |
| 23 } |
| 24 |
| 25 void ServiceWorkerWindowClient::dispose(ServiceWorkerWindowClient::WebType* webC
lientRaw) |
| 26 { |
| 27 delete webClientRaw; |
| 28 } |
| 29 |
20 ServiceWorkerWindowClient* ServiceWorkerWindowClient::create(const WebServiceWor
kerClientInfo& info) | 30 ServiceWorkerWindowClient* ServiceWorkerWindowClient::create(const WebServiceWor
kerClientInfo& info) |
21 { | 31 { |
22 return new ServiceWorkerWindowClient(info); | 32 return new ServiceWorkerWindowClient(info); |
23 } | 33 } |
24 | 34 |
25 ServiceWorkerWindowClient::ServiceWorkerWindowClient(const WebServiceWorkerClien
tInfo& info) | 35 ServiceWorkerWindowClient::ServiceWorkerWindowClient(const WebServiceWorkerClien
tInfo& info) |
26 : ServiceWorkerClient(info) | 36 : ServiceWorkerClient(info) |
27 , m_pageVisibilityState(info.pageVisibilityState) | 37 , m_pageVisibilityState(info.pageVisibilityState) |
28 , m_isFocused(info.isFocused) | 38 , m_isFocused(info.isFocused) |
29 , m_frameType(info.frameType) | 39 , m_frameType(info.frameType) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 { | 75 { |
66 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 76 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
67 ScriptPromise promise = resolver->promise(); | 77 ScriptPromise promise = resolver->promise(); |
68 | 78 |
69 if (!scriptState->executionContext()->isWindowFocusAllowed()) { | 79 if (!scriptState->executionContext()->isWindowFocusAllowed()) { |
70 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.")); |
71 return promise; | 81 return promise; |
72 } | 82 } |
73 scriptState->executionContext()->consumeWindowFocus(); | 83 scriptState->executionContext()->consumeWindowFocus(); |
74 | 84 |
75 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus
(id(), new CallbackPromiseAdapter<bool, ServiceWorkerError>(resolver)); | 85 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus
(id(), new CallbackPromiseAdapter<ServiceWorkerWindowClient, ServiceWorkerError>
(resolver)); |
76 return promise; | 86 return promise; |
77 } | 87 } |
78 | 88 |
79 void ServiceWorkerWindowClient::trace(Visitor* visitor) | 89 void ServiceWorkerWindowClient::trace(Visitor* visitor) |
80 { | 90 { |
81 ServiceWorkerClient::trace(visitor); | 91 ServiceWorkerClient::trace(visitor); |
82 } | 92 } |
83 | 93 |
84 } // namespace blink | 94 } // namespace blink |
OLD | NEW |