OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/wake_lock/ScreenWakeLock.h" | 5 #include "modules/wake_lock/ScreenWakeLock.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
9 #include "core/frame/Screen.h" | 9 #include "core/frame/Screen.h" |
10 #include "core/page/PageVisibilityState.h" | 10 #include "core/page/PageVisibilityState.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 setKeepAwake(false); | 55 setKeepAwake(false); |
56 } | 56 } |
57 | 57 |
58 DEFINE_TRACE(ScreenWakeLock) { | 58 DEFINE_TRACE(ScreenWakeLock) { |
59 Supplement<LocalFrame>::trace(visitor); | 59 Supplement<LocalFrame>::trace(visitor); |
60 PageVisibilityObserver::trace(visitor); | 60 PageVisibilityObserver::trace(visitor); |
61 ContextLifecycleObserver::trace(visitor); | 61 ContextLifecycleObserver::trace(visitor); |
62 } | 62 } |
63 | 63 |
64 ScreenWakeLock::ScreenWakeLock(LocalFrame& frame) | 64 ScreenWakeLock::ScreenWakeLock(LocalFrame& frame) |
65 : ContextLifecycleObserver(frame.document()), | 65 : Supplement<LocalFrame>(frame), |
| 66 ContextLifecycleObserver(frame.document()), |
66 PageVisibilityObserver(frame.page()), | 67 PageVisibilityObserver(frame.page()), |
67 m_keepAwake(false) { | 68 m_keepAwake(false) { |
68 DCHECK(!m_service.is_bound()); | 69 DCHECK(!m_service.is_bound()); |
69 DCHECK(frame.interfaceProvider()); | 70 DCHECK(frame.interfaceProvider()); |
70 frame.interfaceProvider()->getInterface(mojo::MakeRequest(&m_service)); | 71 frame.interfaceProvider()->getInterface(mojo::MakeRequest(&m_service)); |
71 } | 72 } |
72 | 73 |
73 bool ScreenWakeLock::keepAwake() const { | 74 bool ScreenWakeLock::keepAwake() const { |
74 return m_keepAwake; | 75 return m_keepAwake; |
75 } | 76 } |
(...skipping 12 matching lines...) Expand all Loading... |
88 if (!m_service) | 89 if (!m_service) |
89 return; | 90 return; |
90 | 91 |
91 if (m_keepAwake && page() && page()->isPageVisible()) | 92 if (m_keepAwake && page() && page()->isPageVisible()) |
92 m_service->RequestWakeLock(); | 93 m_service->RequestWakeLock(); |
93 else | 94 else |
94 m_service->CancelWakeLock(); | 95 m_service->CancelWakeLock(); |
95 } | 96 } |
96 | 97 |
97 } // namespace blink | 98 } // namespace blink |
OLD | NEW |