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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 void ScreenWakeLock::pageVisibilityChanged() { | 50 void ScreenWakeLock::pageVisibilityChanged() { |
51 notifyService(); | 51 notifyService(); |
52 } | 52 } |
53 | 53 |
54 void ScreenWakeLock::contextDestroyed(ExecutionContext*) { | 54 void ScreenWakeLock::contextDestroyed(ExecutionContext*) { |
55 setKeepAwake(false); | 55 setKeepAwake(false); |
56 } | 56 } |
57 | 57 |
58 void ScreenWakeLock::contextDestroyed(Page*) {} | |
59 | |
60 DEFINE_TRACE(ScreenWakeLock) { | 58 DEFINE_TRACE(ScreenWakeLock) { |
61 Supplement<LocalFrame>::trace(visitor); | 59 Supplement<LocalFrame>::trace(visitor); |
62 PageVisibilityObserver::trace(visitor); | 60 PageVisibilityObserver::trace(visitor); |
63 ContextLifecycleObserver::trace(visitor); | 61 ContextLifecycleObserver::trace(visitor); |
64 } | 62 } |
65 | 63 |
66 ScreenWakeLock::ScreenWakeLock(LocalFrame& frame) | 64 ScreenWakeLock::ScreenWakeLock(LocalFrame& frame) |
67 : Supplement<LocalFrame>(frame), | 65 : Supplement<LocalFrame>(frame), |
68 ContextLifecycleObserver(frame.document()), | 66 ContextLifecycleObserver(frame.document()), |
69 PageVisibilityObserver(frame.page()), | 67 PageVisibilityObserver(frame.page()), |
(...skipping 21 matching lines...) Expand all Loading... |
91 if (!m_service) | 89 if (!m_service) |
92 return; | 90 return; |
93 | 91 |
94 if (m_keepAwake && page() && page()->isPageVisible()) | 92 if (m_keepAwake && page() && page()->isPageVisible()) |
95 m_service->RequestWakeLock(); | 93 m_service->RequestWakeLock(); |
96 else | 94 else |
97 m_service->CancelWakeLock(); | 95 m_service->CancelWakeLock(); |
98 } | 96 } |
99 | 97 |
100 } // namespace blink | 98 } // namespace blink |
OLD | NEW |