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.
5 #ifndef CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_
6 #define CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_
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"
24 class RendererPpapiHost;
29 struct ReplyMessageContext;
33 namespace extensions {
37 class PepperExtensionsCommonHost : public ppapi::host::ResourceHost {
39 virtual ~PepperExtensionsCommonHost();
41 static PepperExtensionsCommonHost* Create(content::RendererPpapiHost* host,
43 PP_Resource resource);
45 // ppapi::host::ResourceMessageHandler overrides.
46 virtual int32_t OnResourceMessageReceived(
47 const IPC::Message& msg,
48 ppapi::host::HostMessageContext* context) OVERRIDE;
51 PepperExtensionsCommonHost(
52 content::RendererPpapiHost* host,
55 extensions::PepperRequestProxy* pepper_request_proxy);
57 int32_t OnPost(ppapi::host::HostMessageContext* context,
58 const std::string& request_name,
59 const base::ListValue& args);
61 int32_t OnCall(ppapi::host::HostMessageContext* context,
62 const std::string& request_name,
63 const base::ListValue& args);
65 void OnResponseReceived(ppapi::host::ReplyMessageContext reply_context,
67 const base::ListValue& response,
68 const std::string& error);
70 // Non-owning pointer.
71 content::RendererPpapiHost* renderer_ppapi_host_;
72 // Non-owning pointer.
73 extensions::PepperRequestProxy* pepper_request_proxy_;
75 base::WeakPtrFactory<PepperExtensionsCommonHost> weak_factory_;
77 DISALLOW_COPY_AND_ASSIGN(PepperExtensionsCommonHost);
80 #endif // CHROME_RENDERER_PEPPER_PEPPER_EXTENSIONS_COMMON_HOST_H_