Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: Source/modules/gamepad/NavigatorGamepad.cpp

Issue 345013002: Notify the browser when the page lost interest about gamepads (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed for relanding Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/gamepad/NavigatorGamepad.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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))
+ startUpdating();
+ else
+ stopUpdating();
+}
+
} // namespace WebCore
« no previous file with comments | « Source/modules/gamepad/NavigatorGamepad.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698