OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 #include "ppapi/proxy/ppb_input_event_proxy.h" |
| 6 |
| 7 #include "ppapi/c/ppb_audio_config.h" |
| 8 #include "ppapi/proxy/plugin_dispatcher.h" |
| 9 #include "ppapi/proxy/plugin_resource.h" |
| 10 #include "ppapi/proxy/plugin_var_tracker.h" |
| 11 #include "ppapi/proxy/ppapi_messages.h" |
| 12 #include "ppapi/shared_impl/input_event_impl.h" |
| 13 #include "ppapi/thunk/thunk.h" |
| 14 |
| 15 using ppapi::InputEventData; |
| 16 using ppapi::InputEventImpl; |
| 17 using ppapi::thunk::PPB_InputEvent_API; |
| 18 |
| 19 namespace pp { |
| 20 namespace proxy { |
| 21 |
| 22 // The implementation is actually in InputEventImpl. |
| 23 class InputEvent : public PluginResource, public InputEventImpl { |
| 24 public: |
| 25 InputEvent(const HostResource& resource, const InputEventData& data); |
| 26 virtual ~InputEvent(); |
| 27 |
| 28 // ResourceObjectBase overrides. |
| 29 virtual PPB_InputEvent_API* AsPPB_InputEvent_API() OVERRIDE; |
| 30 |
| 31 // InputEventImpl overrides. |
| 32 virtual PP_Var StringToPPVar(const std::string& str) OVERRIDE; |
| 33 |
| 34 private: |
| 35 DISALLOW_COPY_AND_ASSIGN(InputEvent); |
| 36 }; |
| 37 |
| 38 InputEvent::InputEvent(const HostResource& resource, const InputEventData& data) |
| 39 : PluginResource(resource), |
| 40 InputEventImpl(data) { |
| 41 } |
| 42 |
| 43 InputEvent::~InputEvent() { |
| 44 } |
| 45 |
| 46 PPB_InputEvent_API* InputEvent::AsPPB_InputEvent_API() { |
| 47 return this; |
| 48 } |
| 49 |
| 50 PP_Var InputEvent::StringToPPVar(const std::string& str) { |
| 51 PP_Var ret; |
| 52 ret.type = PP_VARTYPE_STRING; |
| 53 ret.value.as_id = PluginVarTracker::GetInstance()->MakeString(str); |
| 54 return ret; |
| 55 } |
| 56 |
| 57 namespace { |
| 58 |
| 59 InterfaceProxy* CreateInputEventProxy(Dispatcher* dispatcher, |
| 60 const void* target_interface) { |
| 61 return new PPB_InputEvent_Proxy(dispatcher, target_interface); |
| 62 } |
| 63 |
| 64 } // namespace |
| 65 |
| 66 PPB_InputEvent_Proxy::PPB_InputEvent_Proxy(Dispatcher* dispatcher, |
| 67 const void* target_interface) |
| 68 : InterfaceProxy(dispatcher, target_interface) { |
| 69 } |
| 70 |
| 71 PPB_InputEvent_Proxy::~PPB_InputEvent_Proxy() { |
| 72 } |
| 73 |
| 74 // static |
| 75 const InterfaceProxy::Info* PPB_InputEvent_Proxy::GetInfo() { |
| 76 static const Info info = { |
| 77 ::ppapi::thunk::GetPPB_InputEvent_Thunk(), |
| 78 PPB_INPUT_EVENT_INTERFACE, |
| 79 INTERFACE_ID_NONE, |
| 80 false, |
| 81 &CreateInputEventProxy, |
| 82 }; |
| 83 return &info; |
| 84 } |
| 85 |
| 86 // static |
| 87 PP_Resource PPB_InputEvent_Proxy::CreateProxyResource( |
| 88 PP_Instance instance, |
| 89 const InputEventData& data) { |
| 90 linked_ptr<InputEvent> object(new InputEvent( |
| 91 HostResource::MakeInstanceOnly(instance), data)); |
| 92 return PluginResourceTracker::GetInstance()->AddResource(object); |
| 93 } |
| 94 |
| 95 bool PPB_InputEvent_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 96 // There are no IPC messages for this interface. |
| 97 NOTREACHED(); |
| 98 return false; |
| 99 } |
| 100 |
| 101 } // namespace proxy |
| 102 } // namespace pp |
OLD | NEW |