OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_instance_proxy.h" |
| 6 |
| 7 #include "ppapi/c/pp_var.h" |
| 8 #include "ppapi/c/ppb_instance.h" |
| 9 #include "ppapi/proxy/plugin_dispatcher.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" |
| 11 #include "ppapi/proxy/serialized_var.h" |
| 12 |
| 13 namespace pp { |
| 14 namespace proxy { |
| 15 |
| 16 namespace { |
| 17 |
| 18 PP_Var GetWindowObject(PP_Instance instance) { |
| 19 Dispatcher* dispatcher = PluginDispatcher::Get(); |
| 20 ReceiveSerializedVarReturnValue result; |
| 21 dispatcher->Send(new PpapiHostMsg_PPBInstance_GetWindowObject( |
| 22 INTERFACE_ID_PPB_INSTANCE, instance, &result)); |
| 23 return result.Return(dispatcher); |
| 24 } |
| 25 |
| 26 PP_Var GetOwnerElementObject(PP_Instance instance) { |
| 27 Dispatcher* dispatcher = PluginDispatcher::Get(); |
| 28 ReceiveSerializedVarReturnValue result; |
| 29 dispatcher->Send(new PpapiHostMsg_PPBInstance_GetOwnerElementObject( |
| 30 INTERFACE_ID_PPB_INSTANCE, instance, &result)); |
| 31 return result.Return(dispatcher); |
| 32 } |
| 33 |
| 34 bool BindGraphics(PP_Instance instance, PP_Resource device) { |
| 35 bool result; |
| 36 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( |
| 37 INTERFACE_ID_PPB_INSTANCE, instance, device, &result)); |
| 38 return result; |
| 39 } |
| 40 |
| 41 bool IsFullFrame(PP_Instance instance) { |
| 42 bool result; |
| 43 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( |
| 44 INTERFACE_ID_PPB_INSTANCE, instance, &result)); |
| 45 return result; |
| 46 } |
| 47 |
| 48 PP_Var ExecuteScript(PP_Instance instance, PP_Var script, PP_Var* exception) { |
| 49 Dispatcher* dispatcher = PluginDispatcher::Get(); |
| 50 ReceiveSerializedException se(dispatcher, exception); |
| 51 if (se.IsThrown()) |
| 52 return PP_MakeUndefined(); |
| 53 |
| 54 ReceiveSerializedVarReturnValue result; |
| 55 dispatcher->Send(new PpapiHostMsg_PPBInstance_ExecuteScript( |
| 56 INTERFACE_ID_PPB_INSTANCE, instance, |
| 57 SerializedVarSendInput(dispatcher, script), &se, &result)); |
| 58 return result.Return(dispatcher); |
| 59 } |
| 60 |
| 61 const PPB_Instance instance_interface = { |
| 62 &GetWindowObject, |
| 63 &GetOwnerElementObject, |
| 64 &BindGraphics, |
| 65 &IsFullFrame, |
| 66 &ExecuteScript |
| 67 }; |
| 68 |
| 69 } // namespace |
| 70 |
| 71 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher, |
| 72 const void* target_interface) |
| 73 : InterfaceProxy(dispatcher, target_interface) { |
| 74 } |
| 75 |
| 76 PPB_Instance_Proxy::~PPB_Instance_Proxy() { |
| 77 } |
| 78 |
| 79 const void* PPB_Instance_Proxy::GetSourceInterface() const { |
| 80 return &instance_interface; |
| 81 } |
| 82 |
| 83 InterfaceID PPB_Instance_Proxy::GetInterfaceId() const { |
| 84 return INTERFACE_ID_PPB_INSTANCE; |
| 85 } |
| 86 |
| 87 void PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 88 IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy, msg) |
| 89 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject, |
| 90 OnMsgGetWindowObject) |
| 91 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject, |
| 92 OnMsgGetOwnerElementObject) |
| 93 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics, |
| 94 OnMsgBindGraphics) |
| 95 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame, |
| 96 OnMsgIsFullFrame) |
| 97 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, |
| 98 OnMsgExecuteScript) |
| 99 IPC_END_MESSAGE_MAP() |
| 100 } |
| 101 |
| 102 void PPB_Instance_Proxy::OnMsgGetWindowObject( |
| 103 PP_Instance instance, |
| 104 SerializedVarReturnValue result) { |
| 105 result.Return(dispatcher(), |
| 106 ppb_instance_target()->GetWindowObject(instance)); |
| 107 } |
| 108 |
| 109 void PPB_Instance_Proxy::OnMsgGetOwnerElementObject( |
| 110 PP_Instance instance, |
| 111 SerializedVarReturnValue result) { |
| 112 result.Return(dispatcher(), |
| 113 ppb_instance_target()->GetOwnerElementObject(instance)); |
| 114 } |
| 115 |
| 116 void PPB_Instance_Proxy::OnMsgBindGraphics(PP_Instance instance, |
| 117 PP_Resource device, |
| 118 bool* result) { |
| 119 *result = ppb_instance_target()->BindGraphics(instance, device); |
| 120 } |
| 121 |
| 122 void PPB_Instance_Proxy::OnMsgIsFullFrame(PP_Instance instance, bool* result) { |
| 123 *result = ppb_instance_target()->IsFullFrame(instance); |
| 124 } |
| 125 |
| 126 void PPB_Instance_Proxy::OnMsgExecuteScript( |
| 127 PP_Instance instance, |
| 128 SerializedVarReceiveInput script, |
| 129 SerializedVarOutParam out_exception, |
| 130 SerializedVarReturnValue result) { |
| 131 result.Return(dispatcher(), ppb_instance_target()->ExecuteScript( |
| 132 instance, |
| 133 script.Get(dispatcher()), |
| 134 out_exception.OutParam(dispatcher()))); |
| 135 } |
| 136 |
| 137 } // namespace proxy |
| 138 } // namespace pp |
OLD | NEW |