| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/proxy/ppb_testing_proxy.h" | 5 #include "ppapi/proxy/ppb_testing_proxy.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "ppapi/c/dev/ppb_testing_dev.h" | 8 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
| 10 #include "ppapi/proxy/plugin_globals.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 11 #include "ppapi/shared_impl/ppapi_globals.h" | 12 #include "ppapi/shared_impl/ppapi_globals.h" |
| 12 #include "ppapi/shared_impl/resource.h" | 13 #include "ppapi/shared_impl/resource.h" |
| 13 #include "ppapi/shared_impl/resource_tracker.h" | 14 #include "ppapi/shared_impl/resource_tracker.h" |
| 14 | 15 |
| 15 namespace ppapi { | 16 namespace ppapi { |
| 16 namespace proxy { | 17 namespace proxy { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 uint32_t result = 0; | 62 uint32_t result = 0; |
| 62 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( | 63 dispatcher->Send(new PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance( |
| 63 API_ID_PPB_TESTING, instance_id, &result)); | 64 API_ID_PPB_TESTING, instance_id, &result)); |
| 64 return result; | 65 return result; |
| 65 } | 66 } |
| 66 | 67 |
| 67 PP_Bool IsOutOfProcess() { | 68 PP_Bool IsOutOfProcess() { |
| 68 return PP_TRUE; | 69 return PP_TRUE; |
| 69 } | 70 } |
| 70 | 71 |
| 72 void SimulateInputEvent(PP_Instance instance_id, PP_Resource input_event) { |
| 73 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
| 74 if (!dispatcher) |
| 75 return; |
| 76 HostResource input_event_resource; |
| 77 input_event_resource.SetHostResource(instance_id, input_event); |
| 78 dispatcher->Send(new PpapiHostMsg_PPBTesting_SimulateInputEvent( |
| 79 API_ID_PPB_TESTING, instance_id, input_event_resource)); |
| 80 } |
| 81 |
| 71 const PPB_Testing_Dev testing_interface = { | 82 const PPB_Testing_Dev testing_interface = { |
| 72 &ReadImageData, | 83 &ReadImageData, |
| 73 &RunMessageLoop, | 84 &RunMessageLoop, |
| 74 &QuitMessageLoop, | 85 &QuitMessageLoop, |
| 75 &GetLiveObjectsForInstance, | 86 &GetLiveObjectsForInstance, |
| 76 &IsOutOfProcess | 87 &IsOutOfProcess, |
| 88 &SimulateInputEvent |
| 77 }; | 89 }; |
| 78 | 90 |
| 79 InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) { | 91 InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) { |
| 80 return new PPB_Testing_Proxy(dispatcher); | 92 return new PPB_Testing_Proxy(dispatcher); |
| 81 } | 93 } |
| 82 | 94 |
| 83 } // namespace | 95 } // namespace |
| 84 | 96 |
| 85 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher) | 97 PPB_Testing_Proxy::PPB_Testing_Proxy(Dispatcher* dispatcher) |
| 86 : InterfaceProxy(dispatcher), | 98 : InterfaceProxy(dispatcher), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 106 return &info; | 118 return &info; |
| 107 } | 119 } |
| 108 | 120 |
| 109 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) { | 121 bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 110 bool handled = true; | 122 bool handled = true; |
| 111 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg) | 123 IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg) |
| 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData, | 124 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData, |
| 113 OnMsgReadImageData) | 125 OnMsgReadImageData) |
| 114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, | 126 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, |
| 115 OnMsgGetLiveObjectsForInstance) | 127 OnMsgGetLiveObjectsForInstance) |
| 128 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent, |
| 129 OnMsgSimulateInputEvent) |
| 116 IPC_MESSAGE_UNHANDLED(handled = false) | 130 IPC_MESSAGE_UNHANDLED(handled = false) |
| 117 IPC_END_MESSAGE_MAP() | 131 IPC_END_MESSAGE_MAP() |
| 118 return handled; | 132 return handled; |
| 119 } | 133 } |
| 120 | 134 |
| 121 void PPB_Testing_Proxy::OnMsgReadImageData( | 135 void PPB_Testing_Proxy::OnMsgReadImageData( |
| 122 const HostResource& device_context_2d, | 136 const HostResource& device_context_2d, |
| 123 const HostResource& image, | 137 const HostResource& image, |
| 124 const PP_Point& top_left, | 138 const PP_Point& top_left, |
| 125 PP_Bool* result) { | 139 PP_Bool* result) { |
| 126 *result = ppb_testing_impl_->ReadImageData( | 140 *result = ppb_testing_impl_->ReadImageData( |
| 127 device_context_2d.host_resource(), image.host_resource(), &top_left); | 141 device_context_2d.host_resource(), image.host_resource(), &top_left); |
| 128 } | 142 } |
| 129 | 143 |
| 130 void PPB_Testing_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { | 144 void PPB_Testing_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { |
| 131 ppb_testing_impl_->RunMessageLoop(instance); | 145 ppb_testing_impl_->RunMessageLoop(instance); |
| 132 } | 146 } |
| 133 | 147 |
| 134 void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { | 148 void PPB_Testing_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { |
| 135 ppb_testing_impl_->QuitMessageLoop(instance); | 149 ppb_testing_impl_->QuitMessageLoop(instance); |
| 136 } | 150 } |
| 137 | 151 |
| 138 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, | 152 void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance, |
| 139 uint32_t* result) { | 153 uint32_t* result) { |
| 140 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); | 154 *result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); |
| 141 } | 155 } |
| 142 | 156 |
| 157 void PPB_Testing_Proxy::OnMsgSimulateInputEvent( |
| 158 PP_Instance instance, |
| 159 const ppapi::HostResource& input_event) { |
| 160 PP_Resource plugin_input_event = |
| 161 PluginGlobals::Get()->plugin_resource_tracker()-> |
| 162 PluginResourceForHostResource(input_event); |
| 163 ppb_testing_impl_->SimulateInputEvent(instance, plugin_input_event); |
| 164 } |
| 165 |
| 143 } // namespace proxy | 166 } // namespace proxy |
| 144 } // namespace ppapi | 167 } // namespace ppapi |
| OLD | NEW |