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

Unified Diff: Source/core/frame/DOMWindow.cpp

Issue 200783002: Gamepad API: add support for gamepadconnected and gamepaddisconnected events (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
Index: Source/core/frame/DOMWindow.cpp
diff --git a/Source/core/frame/DOMWindow.cpp b/Source/core/frame/DOMWindow.cpp
index f301a446854c952d9e5d615c8fa947f8bcde5072..cce5251f7b7e3b2b6ee802e0067131f0285bd7da 100644
--- a/Source/core/frame/DOMWindow.cpp
+++ b/Source/core/frame/DOMWindow.cpp
@@ -105,6 +105,9 @@
#include "wtf/text/WTFString.h"
#include <algorithm>
+// FIXME: this is a layering vilation.
Inactive 2014/03/14 19:46:08 Yes, we don't want that :)
kbalazs 2014/03/14 23:51:27 Done.
+#include "modules/gamepad/NavigatorGamepad.h"
+
using std::min;
using std::max;
@@ -1518,6 +1521,13 @@ bool DOMWindow::addEventListener(const AtomicString& eventType, PassRefPtr<Event
// Subframes return false from allowsBeforeUnloadListeners.
UseCounter::count(document(), UseCounter::SubFrameBeforeUnloadRegistered);
}
+ } else if (eventType == EventTypeNames::gamepadconnected || eventType == EventTypeNames::gamepaddisconnected) {
sof 2014/03/14 20:52:43 Just above these special cases, DOMWindow observer
kbalazs 2014/03/14 23:51:27 Wonderful, thanks. Together with FrameLoaderClient
+ // If an event listener is added for gamepad events sample the gamepads once to start monitoring gamepad state.
+ // FIXME: we need to instantiate NavigatorGamepad here so that it can listen to the events.
+ // Otherwise it would only be created when js calls getGamepads() or webkitGetGamepads() and we cannot assume that
+ // it will happen before a gamepad is connected. But this is a layering violation because NavigatorGamepad lives
+ // in modules.
+ NavigatorGamepad::getGamepads(navigator());
Inactive 2014/03/14 19:46:08 You should probably take a look at FrameLoaderClie
kbalazs 2014/03/14 23:51:27 Done.
}
return true;

Powered by Google App Engine
This is Rietveld 408576698