Index: ppapi/proxy/ppb_testing_proxy.cc |
=================================================================== |
--- ppapi/proxy/ppb_testing_proxy.cc (revision 107150) |
+++ ppapi/proxy/ppb_testing_proxy.cc (working copy) |
@@ -68,12 +68,65 @@ |
return PP_TRUE; |
} |
+void GenerateKeyEvent( |
+ PP_Instance instance, |
+ PP_InputEvent_Type type, |
+ const PP_InputEvent_Key& key_event) { |
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
+ if (dispatcher) { |
+ dispatcher->Send(new PpapiHostMsg_PPBTesting_GenerateKeyEvent( |
+ API_ID_PPB_TESTING, instance, type, key_event)); |
+ } |
+} |
+ |
+void GenerateCharacterEvent( |
+ PP_Instance instance, |
+ const PP_InputEvent_Character& character_event) |
+{ |
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
+ if (dispatcher) { |
+ std::string text(character_event.text); |
+ dispatcher->Send(new PpapiHostMsg_PPBTesting_GenerateCharacterEvent( |
+ API_ID_PPB_TESTING, |
+ instance, |
+ static_cast<PP_InputEvent_Modifier>(character_event.modifier), |
+ text)); |
+ } |
+} |
+ |
+void GenerateMouseEvent( |
+ PP_Instance instance, |
+ PP_InputEvent_Type type, |
+ const PP_InputEvent_Mouse& mouse_event) |
+{ |
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
+ if (dispatcher) { |
+ dispatcher->Send(new PpapiHostMsg_PPBTesting_GenerateMouseEvent( |
+ API_ID_PPB_TESTING, instance, type, mouse_event)); |
+ } |
+} |
+ |
+void GenerateWheelEvent( |
+ PP_Instance instance, |
+ const PP_InputEvent_Wheel& wheel_event) |
+{ |
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
+ if (dispatcher) { |
+ dispatcher->Send(new PpapiHostMsg_PPBTesting_GenerateWheelEvent( |
+ API_ID_PPB_TESTING, instance, wheel_event)); |
+ } |
+} |
+ |
const PPB_Testing_Dev testing_interface = { |
&ReadImageData, |
&RunMessageLoop, |
&QuitMessageLoop, |
&GetLiveObjectsForInstance, |
- &IsOutOfProcess |
+ &IsOutOfProcess, |
+ &GenerateKeyEvent, |
+ &GenerateCharacterEvent, |
+ &GenerateMouseEvent, |
+ &GenerateWheelEvent |
}; |
InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) { |
@@ -113,6 +166,14 @@ |
OnMsgReadImageData) |
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance, |
OnMsgGetLiveObjectsForInstance) |
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GenerateKeyEvent, |
+ OnMsgGenerateKeyEvent) |
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GenerateCharacterEvent, |
+ OnMsgGenerateCharacterEvent) |
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GenerateMouseEvent, |
+ OnMsgGenerateMouseEvent) |
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GenerateWheelEvent, |
+ OnMsgGenerateWheelEvent) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
return handled; |
@@ -140,5 +201,36 @@ |
*result = ppb_testing_impl_->GetLiveObjectsForInstance(instance); |
} |
+void PPB_Testing_Proxy::OnMsgGenerateKeyEvent( |
+ PP_Instance instance, |
+ PP_InputEvent_Type type, |
+ const PP_InputEvent_Key& key_event) { |
+ ppb_testing_impl_->GenerateKeyEvent(instance, type, key_event); |
+} |
+ |
+void PPB_Testing_Proxy::OnMsgGenerateCharacterEvent( |
+ PP_Instance instance, |
+ const PP_InputEvent_Modifier modifier, |
+ const std::string& text) { |
+ PP_InputEvent_Character character_event; |
+ character_event.modifier = modifier; |
+ for (size_t i = 0; i < text.size() && i < 5; i++) |
+ character_event.text[i] = text[i]; |
+ ppb_testing_impl_->GenerateCharacterEvent(instance, character_event); |
+} |
+ |
+void PPB_Testing_Proxy::OnMsgGenerateMouseEvent( |
+ PP_Instance instance, |
+ PP_InputEvent_Type type, |
+ const PP_InputEvent_Mouse& mouse_event) { |
+ ppb_testing_impl_->GenerateMouseEvent(instance, type, mouse_event); |
+} |
+ |
+void PPB_Testing_Proxy::OnMsgGenerateWheelEvent( |
+ PP_Instance instance, |
+ const PP_InputEvent_Wheel& wheel_event) { |
+ ppb_testing_impl_->GenerateWheelEvent(instance, wheel_event); |
+} |
+ |
} // namespace proxy |
} // namespace ppapi |