Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / pepper / pepper_gamepad_host.h
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_GAMEPAD_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_GAMEPAD_HOST_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/browser/gamepad/gamepad_consumer.h"
11 #include "content/common/content_export.h"
12 #include "ppapi/host/resource_host.h"
13
14 namespace ppapi {
15 namespace host {
16 struct ReplyMessageContext;
17 }
18 }
19
20 namespace content {
21
22 class BrowserPpapiHost;
23 class GamepadService;
24
25 class CONTENT_EXPORT PepperGamepadHost :
26     public ppapi::host::ResourceHost,
27     public GamepadConsumer {
28  public:
29   PepperGamepadHost(BrowserPpapiHost* host,
30                     PP_Instance instance,
31                     PP_Resource resource);
32
33   // Allows tests to specify a gamepad service to use rather than the global
34   // singleton. The caller owns the gamepad_service pointer.
35   PepperGamepadHost(GamepadService* gamepad_service,
36                     BrowserPpapiHost* host,
37                     PP_Instance instance,
38                     PP_Resource resource);
39
40   virtual ~PepperGamepadHost();
41
42   virtual int32_t OnResourceMessageReceived(
43       const IPC::Message& msg,
44       ppapi::host::HostMessageContext* context) OVERRIDE;
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
54  private:
55   int32_t OnRequestMemory(ppapi::host::HostMessageContext* context);
56
57   void GotUserGesture(const ppapi::host::ReplyMessageContext& in_context);
58
59   BrowserPpapiHost* browser_ppapi_host_;
60
61   GamepadService* gamepad_service_;
62
63   bool is_started_;
64
65   base::WeakPtrFactory<PepperGamepadHost> weak_factory_;
66
67   DISALLOW_COPY_AND_ASSIGN(PepperGamepadHost);
68 };
69
70 }  // namespace content
71
72 #endif  // CONTENT_BROWSER_RENDERER_HOST_PEPPER_PEPPER_GAMEPAD_HOST_H_