Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / renderer / pepper / pepper_extensions_common_host.h
1 // Copyright (c) 2013 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 CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_
6 #define CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/bind.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "chrome/renderer/extensions/pepper_request_proxy.h"
17 #include "ppapi/host/resource_host.h"
18
19 namespace base {
20 class ListValue;
21 }
22
23 namespace content {
24 class RendererPpapiHost;
25 }
26
27 namespace ppapi {
28 namespace host {
29 struct ReplyMessageContext;
30 }
31 }
32
33 namespace extensions {
34 class Dispatcher;
35 }
36
37 class PepperExtensionsCommonHost : public ppapi::host::ResourceHost {
38  public:
39   virtual ~PepperExtensionsCommonHost();
40
41   static PepperExtensionsCommonHost* Create(content::RendererPpapiHost* host,
42                                             PP_Instance instance,
43                                             PP_Resource resource);
44
45   // ppapi::host::ResourceMessageHandler overrides.
46   virtual int32_t OnResourceMessageReceived(
47       const IPC::Message& msg,
48       ppapi::host::HostMessageContext* context) OVERRIDE;
49
50  private:
51   PepperExtensionsCommonHost(
52       content::RendererPpapiHost* host,
53       PP_Instance instance,
54       PP_Resource resource,
55       extensions::PepperRequestProxy* pepper_request_proxy);
56
57   int32_t OnPost(ppapi::host::HostMessageContext* context,
58                  const std::string& request_name,
59                  const base::ListValue& args);
60
61   int32_t OnCall(ppapi::host::HostMessageContext* context,
62                  const std::string& request_name,
63                  const base::ListValue& args);
64
65   void OnResponseReceived(ppapi::host::ReplyMessageContext reply_context,
66                           bool success,
67                           const base::ListValue& response,
68                           const std::string& error);
69
70   // Non-owning pointer.
71   content::RendererPpapiHost* renderer_ppapi_host_;
72   // Non-owning pointer.
73   extensions::PepperRequestProxy* pepper_request_proxy_;
74
75   base::WeakPtrFactory<PepperExtensionsCommonHost> weak_factory_;
76
77   DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonHost);
78 };
79
80 #endif  // CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_