OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "content/public/renderer/renderer_gamepad_provider.h" | 11 #include "content/public/renderer/renderer_gamepad_provider.h" |
12 #include "third_party/WebKit/public/platform/WebGamepads.h" | 12 #include "third_party/WebKit/public/platform/WebGamepads.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 class WebFrame; | 15 class WebFrame; |
16 class WebGamepadListener; | 16 class WebGamepadListener; |
17 } | 17 } |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 class WebTestDelegate; | 21 class WebTestDelegate; |
22 | 22 |
23 class GamepadController | 23 class GamepadController |
24 : public base::SupportsWeakPtr<GamepadController>, | 24 : public base::SupportsWeakPtr<GamepadController>, |
25 public RendererGamepadProvider { | 25 public RendererGamepadProvider { |
26 public: | 26 public: |
27 static base::WeakPtr<GamepadController> Create(WebTestDelegate* delegate); | 27 static base::WeakPtr<GamepadController> Create(WebTestDelegate* delegate); |
28 virtual ~GamepadController(); | 28 ~GamepadController() override; |
29 | 29 |
30 void Reset(); | 30 void Reset(); |
31 void Install(blink::WebFrame* frame); | 31 void Install(blink::WebFrame* frame); |
32 | 32 |
33 // RendererGamepadProvider implementation. | 33 // RendererGamepadProvider implementation. |
34 virtual void SampleGamepads( | 34 void SampleGamepads(blink::WebGamepads& gamepads) override; |
35 blink::WebGamepads& gamepads) override; | 35 bool OnControlMessageReceived(const IPC::Message& msg) override; |
36 virtual bool OnControlMessageReceived(const IPC::Message& msg) override; | 36 void SendStartMessage() override; |
37 virtual void SendStartMessage() override; | 37 void SendStopMessage() override; |
38 virtual void SendStopMessage() override; | |
39 | 38 |
40 private: | 39 private: |
41 friend class GamepadControllerBindings; | 40 friend class GamepadControllerBindings; |
42 GamepadController(); | 41 GamepadController(); |
43 | 42 |
44 // TODO(b.kelemen): for historical reasons Connect just initializes the | 43 // TODO(b.kelemen): for historical reasons Connect just initializes the |
45 // object. The 'gamepadconnected' event will be dispatched via | 44 // object. The 'gamepadconnected' event will be dispatched via |
46 // DispatchConnected. Tests for connected events need to first connect(), | 45 // DispatchConnected. Tests for connected events need to first connect(), |
47 // then set the gamepad data and finally call dispatchConnected(). | 46 // then set the gamepad data and finally call dispatchConnected(). |
48 // We should consider renaming Connect to Init and DispatchConnected to | 47 // We should consider renaming Connect to Init and DispatchConnected to |
(...skipping 14 matching lines...) Expand all Loading... |
63 std::map<int, bool> pending_changes_; | 62 std::map<int, bool> pending_changes_; |
64 | 63 |
65 base::WeakPtrFactory<GamepadController> weak_factory_; | 64 base::WeakPtrFactory<GamepadController> weak_factory_; |
66 | 65 |
67 DISALLOW_COPY_AND_ASSIGN(GamepadController); | 66 DISALLOW_COPY_AND_ASSIGN(GamepadController); |
68 }; | 67 }; |
69 | 68 |
70 } // namespace content | 69 } // namespace content |
71 | 70 |
72 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 71 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
OLD | NEW |