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

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

Issue 200783002: Gamepad API: add support for gamepadconnected and gamepaddisconnected events (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rework in terms of dispather&controller pattern used by motion and orientation 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/modules/gamepad/NavigatorGamepad.h
diff --git a/Source/modules/gamepad/NavigatorGamepad.h b/Source/modules/gamepad/NavigatorGamepad.h
index 456b96a6bfa2ef33a3f62ca09a598ab4b20f0e44..d46478623cfc6a2c2e35bafe230e0b7583d77060 100644
--- a/Source/modules/gamepad/NavigatorGamepad.h
+++ b/Source/modules/gamepad/NavigatorGamepad.h
@@ -26,21 +26,30 @@
#ifndef NavigatorGamepad_h
#define NavigatorGamepad_h
+#include "core/frame/DOMWindowLifecycleObserver.h"
+#include "core/frame/DOMWindowProperty.h"
+#include "core/frame/DeviceSensorEventController.h"
#include "heap/Handle.h"
#include "platform/Supplementable.h"
#include "public/platform/WebGamepads.h"
+namespace blink {
+class WebGamepad;
+class WebGamepads;
+}
+
namespace WebCore {
class GamepadList;
class Navigator;
class WebKitGamepadList;
-class NavigatorGamepad FINAL : public NoBaseWillBeGarbageCollectedFinalized<NavigatorGamepad>, public WillBeHeapSupplement<Navigator> {
+class NavigatorGamepad FINAL : public NoBaseWillBeGarbageCollectedFinalized<NavigatorGamepad>, public WillBeHeapSupplement<Navigator>, public DOMWindowProperty, public DeviceSensorEventController, public DOMWindowLifecycleObserver {
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorGamepad);
public:
- virtual ~NavigatorGamepad();
+ static NavigatorGamepad* from(Document&);
static NavigatorGamepad& from(Navigator&);
+ virtual ~NavigatorGamepad();
static WebKitGamepadList* webkitGetGamepads(Navigator&);
static GamepadList* getGamepads(Navigator&);
@@ -50,10 +59,29 @@ public:
virtual void trace(Visitor*);
+ void didConnectOrDisconnectGamepad(unsigned index, const blink::WebGamepad&, bool connected);
+
private:
- NavigatorGamepad();
+ explicit NavigatorGamepad(Document&);
+
static const char* supplementName();
+ // DOMWindowProperty
+ virtual void willDestroyGlobalObjectInFrame() OVERRIDE FINAL;
+ virtual void willDetachGlobalObjectInFrame() OVERRIDE FINAL;
+
+ // DeviceSensorEventController
+ virtual void registerWithDispatcher() OVERRIDE FINAL;
+ virtual void unregisterWithDispatcher() OVERRIDE FINAL;
+ virtual bool hasLastData() OVERRIDE FINAL;
+ virtual PassRefPtr<Event> getLastEvent() OVERRIDE FINAL;
+ virtual bool isNullEvent(Event*) OVERRIDE FINAL;
+
+ // DOMWindowLifecycleObserver
+ virtual void didAddEventListener(DOMWindow*, const AtomicString&) OVERRIDE FINAL;
+ virtual void didRemoveEventListener(DOMWindow*, const AtomicString&) OVERRIDE FINAL;
+ virtual void didRemoveAllEventListeners(DOMWindow*) OVERRIDE FINAL;
+
RefPtrWillBeMember<GamepadList> m_gamepads;
RefPtrWillBeMember<WebKitGamepadList> m_webkitGamepads;
};

Powered by Google App Engine
This is Rietveld 408576698