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