| 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 "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "third_party/WebKit/public/platform/WebGamepads.h" | 9 #include "third_party/WebKit/public/platform/WebGamepads.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 class WebFrame; | 12 class WebFrame; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace WebTestRunner { | |
| 16 class WebTestDelegate; | |
| 17 } | |
| 18 | |
| 19 namespace content { | 15 namespace content { |
| 20 | 16 |
| 17 class WebTestDelegate; |
| 18 |
| 21 class GamepadController : public base::SupportsWeakPtr<GamepadController> { | 19 class GamepadController : public base::SupportsWeakPtr<GamepadController> { |
| 22 public: | 20 public: |
| 23 GamepadController(); | 21 GamepadController(); |
| 24 ~GamepadController(); | 22 ~GamepadController(); |
| 25 | 23 |
| 26 void Reset(); | 24 void Reset(); |
| 27 void Install(blink::WebFrame* frame); | 25 void Install(blink::WebFrame* frame); |
| 28 void SetDelegate(WebTestRunner::WebTestDelegate* delegate); | 26 void SetDelegate(WebTestDelegate* delegate); |
| 29 | 27 |
| 30 private: | 28 private: |
| 31 friend class GamepadControllerBindings; | 29 friend class GamepadControllerBindings; |
| 32 | 30 |
| 33 // TODO(b.kelemen): for historical reasons Connect just initializes the | 31 // TODO(b.kelemen): for historical reasons Connect just initializes the |
| 34 // object. The 'gamepadconnected' event will be dispatched via | 32 // object. The 'gamepadconnected' event will be dispatched via |
| 35 // DispatchConnected. Tests for connected events need to first connect(), | 33 // DispatchConnected. Tests for connected events need to first connect(), |
| 36 // then set the gamepad data and finally call dispatchConnected(). | 34 // then set the gamepad data and finally call dispatchConnected(). |
| 37 // We should consider renaming Connect to Init and DispatchConnected to | 35 // We should consider renaming Connect to Init and DispatchConnected to |
| 38 // Connect and at the same time updating all the gamepad tests. | 36 // Connect and at the same time updating all the gamepad tests. |
| 39 void Connect(int index); | 37 void Connect(int index); |
| 40 void DispatchConnected(int index); | 38 void DispatchConnected(int index); |
| 41 | 39 |
| 42 void Disconnect(int index); | 40 void Disconnect(int index); |
| 43 void SetId(int index, const std::string& src); | 41 void SetId(int index, const std::string& src); |
| 44 void SetButtonCount(int index, int buttons); | 42 void SetButtonCount(int index, int buttons); |
| 45 void SetButtonData(int index, int button, double data); | 43 void SetButtonData(int index, int button, double data); |
| 46 void SetAxisCount(int index, int axes); | 44 void SetAxisCount(int index, int axes); |
| 47 void SetAxisData(int index, int axis, double data); | 45 void SetAxisData(int index, int axis, double data); |
| 48 | 46 |
| 49 blink::WebGamepads gamepads_; | 47 blink::WebGamepads gamepads_; |
| 50 | 48 |
| 51 WebTestRunner::WebTestDelegate* delegate_; | 49 WebTestDelegate* delegate_; |
| 52 | 50 |
| 53 base::WeakPtrFactory<GamepadController> weak_factory_; | 51 base::WeakPtrFactory<GamepadController> weak_factory_; |
| 54 | 52 |
| 55 DISALLOW_COPY_AND_ASSIGN(GamepadController); | 53 DISALLOW_COPY_AND_ASSIGN(GamepadController); |
| 56 }; | 54 }; |
| 57 | 55 |
| 58 } // namespace content | 56 } // namespace content |
| 59 | 57 |
| 60 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ | 58 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_GAMEPAD_CONTROLLER_H_ |
| OLD | NEW |