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/page/PageVisibilityState.h" | 10 #include "core/page/PageVisibilityState.h" |
11 #include "core/page/WindowFocusAllowedIndicator.h" | 11 #include "core/page/WindowFocusAllowedIndicator.h" |
12 #include "modules/serviceworkers/ServiceWorkerError.h" | 12 #include "modules/serviceworkers/ServiceWorkerError.h" |
13 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" | 13 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h" |
14 #include "public/platform/WebString.h" | 14 #include "public/platform/WebString.h" |
15 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 ServiceWorkerWindowClient* ServiceWorkerWindowClient::create(const WebServiceWor
kerClientInfo& info) | 19 ServiceWorkerWindowClient* ServiceWorkerWindowClient::create(const WebServiceWor
kerClientInfo& info) |
20 { | 20 { |
21 return new ServiceWorkerWindowClient(info); | 21 return new ServiceWorkerWindowClient(info); |
22 } | 22 } |
23 | 23 |
24 ServiceWorkerWindowClient::ServiceWorkerWindowClient(const WebServiceWorkerClien
tInfo& info) | 24 ServiceWorkerWindowClient::ServiceWorkerWindowClient(const WebServiceWorkerClien
tInfo& info) |
25 : ServiceWorkerClient(info) | 25 : ServiceWorkerClient(info) |
26 , m_visibilityState(info.visibilityState) | |
27 , m_pageVisibilityState(info.pageVisibilityState) | 26 , m_pageVisibilityState(info.pageVisibilityState) |
28 , m_isFocused(info.isFocused) | 27 , m_isFocused(info.isFocused) |
29 , m_frameType(info.frameType) | 28 , m_frameType(info.frameType) |
30 { | 29 { |
31 } | 30 } |
32 | 31 |
33 ServiceWorkerWindowClient::~ServiceWorkerWindowClient() | 32 ServiceWorkerWindowClient::~ServiceWorkerWindowClient() |
34 { | 33 { |
35 } | 34 } |
36 | 35 |
37 String ServiceWorkerWindowClient::visibilityState() const | 36 String ServiceWorkerWindowClient::visibilityState() const |
38 { | 37 { |
39 // FIXME: temporary until m_pageVisibilityState is used in Chromium. | |
40 if (m_pageVisibilityState == WebPageVisibilityStateLast) | |
41 return m_visibilityState; | |
42 return pageVisibilityStateString(static_cast<PageVisibilityState>(m_pageVisi
bilityState)); | 38 return pageVisibilityStateString(static_cast<PageVisibilityState>(m_pageVisi
bilityState)); |
43 } | 39 } |
44 | 40 |
45 String ServiceWorkerWindowClient::frameType() const | 41 String ServiceWorkerWindowClient::frameType() const |
46 { | 42 { |
47 DEFINE_STATIC_LOCAL(const String, auxiliary, ("auxiliary")); | 43 DEFINE_STATIC_LOCAL(const String, auxiliary, ("auxiliary")); |
48 DEFINE_STATIC_LOCAL(const String, nested, ("nested")); | 44 DEFINE_STATIC_LOCAL(const String, nested, ("nested")); |
49 DEFINE_STATIC_LOCAL(const String, none, ("none")); | 45 DEFINE_STATIC_LOCAL(const String, none, ("none")); |
50 DEFINE_STATIC_LOCAL(const String, topLevel, ("top-level")); | 46 DEFINE_STATIC_LOCAL(const String, topLevel, ("top-level")); |
51 | 47 |
(...skipping 26 matching lines...) Expand all Loading... |
78 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus
(id(), new CallbackPromiseAdapter<bool, ServiceWorkerError>(resolver)); | 74 ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus
(id(), new CallbackPromiseAdapter<bool, ServiceWorkerError>(resolver)); |
79 return promise; | 75 return promise; |
80 } | 76 } |
81 | 77 |
82 void ServiceWorkerWindowClient::trace(Visitor* visitor) | 78 void ServiceWorkerWindowClient::trace(Visitor* visitor) |
83 { | 79 { |
84 ServiceWorkerClient::trace(visitor); | 80 ServiceWorkerClient::trace(visitor); |
85 } | 81 } |
86 | 82 |
87 } // namespace blink | 83 } // namespace blink |
OLD | NEW |