Chromium Code Reviews| Index: Source/modules/gamepad/NavigatorGamepad.cpp |
| diff --git a/Source/modules/gamepad/NavigatorGamepad.cpp b/Source/modules/gamepad/NavigatorGamepad.cpp |
| index 0b39cea0a4775edb93e83c9af4196c9516b2f78a..780b1f67be0d20cdf2f55b7c13e42083176b445a 100644 |
| --- a/Source/modules/gamepad/NavigatorGamepad.cpp |
| +++ b/Source/modules/gamepad/NavigatorGamepad.cpp |
| @@ -102,6 +102,7 @@ GamepadList* NavigatorGamepad::getGamepads(Navigator& navigator) |
| WebKitGamepadList* NavigatorGamepad::webkitGamepads() |
| { |
| + m_wasPolled = true; |
| if (!m_webkitGamepads) |
| m_webkitGamepads = WebKitGamepadList::create(); |
| if (window()) { |
| @@ -113,6 +114,7 @@ WebKitGamepadList* NavigatorGamepad::webkitGamepads() |
| GamepadList* NavigatorGamepad::gamepads() |
| { |
| + m_wasPolled = true; |
| if (!m_gamepads) |
| m_gamepads = GamepadList::create(); |
| if (window()) { |
| @@ -160,6 +162,7 @@ NavigatorGamepad::NavigatorGamepad(LocalFrame* frame) |
| : DOMWindowProperty(frame) |
| , DeviceEventControllerBase(frame ? frame->page() : 0) |
| , DOMWindowLifecycleObserver(frame ? frame->domWindow() : 0) |
| + , m_wasPolled(false) |
| { |
| } |
| @@ -228,4 +231,13 @@ void NavigatorGamepad::didRemoveAllEventListeners(LocalDOMWindow*) |
| m_hasEventListener = false; |
| } |
| +void NavigatorGamepad::pageVisibilityChanged() |
| +{ |
| + // Inform the embedder whether it needs to provide gamepad data for us. |
| + if (page()->visibilityState() == PageVisibilityStateVisible && (m_hasEventListener || m_wasPolled)) |
|
abarth-chromium
2014/06/21 05:40:17
Instead of m_wasPolled, can we use m_gamepads || m
|
| + startUpdating(); |
| + else |
| + stopUpdating(); |
| +} |
| + |
| } // namespace WebCore |