OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_RENDERER_HOST_PEPPER_PEPPER_GAMEPAD_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_GAMEPAD_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_GAMEPAD_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_GAMEPAD_HOST_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "content/browser/gamepad/gamepad_consumer.h" |
10 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
11 #include "ppapi/host/resource_host.h" | 12 #include "ppapi/host/resource_host.h" |
12 | 13 |
13 namespace ppapi { | 14 namespace ppapi { |
14 namespace host { | 15 namespace host { |
15 struct ReplyMessageContext; | 16 struct ReplyMessageContext; |
16 } | 17 } |
17 } | 18 } |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 class BrowserPpapiHost; | 22 class BrowserPpapiHost; |
22 class GamepadService; | 23 class GamepadService; |
23 | 24 |
24 class CONTENT_EXPORT PepperGamepadHost : public ppapi::host::ResourceHost { | 25 class CONTENT_EXPORT PepperGamepadHost : |
| 26 public ppapi::host::ResourceHost, |
| 27 public GamepadConsumer { |
25 public: | 28 public: |
26 PepperGamepadHost(BrowserPpapiHost* host, | 29 PepperGamepadHost(BrowserPpapiHost* host, |
27 PP_Instance instance, | 30 PP_Instance instance, |
28 PP_Resource resource); | 31 PP_Resource resource); |
29 | 32 |
30 // Allows tests to specify a gamepad service to use rather than the global | 33 // Allows tests to specify a gamepad service to use rather than the global |
31 // singleton. The caller owns the gamepad_service pointer. | 34 // singleton. The caller owns the gamepad_service pointer. |
32 PepperGamepadHost(GamepadService* gamepad_service, | 35 PepperGamepadHost(GamepadService* gamepad_service, |
33 BrowserPpapiHost* host, | 36 BrowserPpapiHost* host, |
34 PP_Instance instance, | 37 PP_Instance instance, |
35 PP_Resource resource); | 38 PP_Resource resource); |
36 | 39 |
37 virtual ~PepperGamepadHost(); | 40 virtual ~PepperGamepadHost(); |
38 | 41 |
39 virtual int32_t OnResourceMessageReceived( | 42 virtual int32_t OnResourceMessageReceived( |
40 const IPC::Message& msg, | 43 const IPC::Message& msg, |
41 ppapi::host::HostMessageContext* context) OVERRIDE; | 44 ppapi::host::HostMessageContext* context) OVERRIDE; |
42 | 45 |
| 46 // GamepadConsumer implementation. |
| 47 virtual void OnGamepadConnected( |
| 48 unsigned index, |
| 49 const blink::WebGamepad& gamepad) OVERRIDE {} |
| 50 virtual void OnGamepadDisconnected( |
| 51 unsigned index, |
| 52 const blink::WebGamepad& gamepad) OVERRIDE {} |
| 53 |
43 private: | 54 private: |
44 int32_t OnRequestMemory(ppapi::host::HostMessageContext* context); | 55 int32_t OnRequestMemory(ppapi::host::HostMessageContext* context); |
45 | 56 |
46 void GotUserGesture(const ppapi::host::ReplyMessageContext& in_context); | 57 void GotUserGesture(const ppapi::host::ReplyMessageContext& in_context); |
47 | 58 |
48 BrowserPpapiHost* browser_ppapi_host_; | 59 BrowserPpapiHost* browser_ppapi_host_; |
49 | 60 |
50 GamepadService* gamepad_service_; | 61 GamepadService* gamepad_service_; |
51 | 62 |
52 bool is_started_; | 63 bool is_started_; |
53 | 64 |
54 base::WeakPtrFactory<PepperGamepadHost> weak_factory_; | 65 base::WeakPtrFactory<PepperGamepadHost> weak_factory_; |
55 | 66 |
56 DISALLOW_COPY_AND_ASSIGN(PepperGamepadHost); | 67 DISALLOW_COPY_AND_ASSIGN(PepperGamepadHost); |
57 }; | 68 }; |
58 | 69 |
59 } // namespace content | 70 } // namespace content |
60 | 71 |
61 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_GAMEPAD_HOST_H_ | 72 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_GAMEPAD_HOST_H_ |
OLD | NEW |