Index: webkit/plugins/ppapi/plugin_module.cc |
=================================================================== |
--- webkit/plugins/ppapi/plugin_module.cc (revision 107150) |
+++ webkit/plugins/ppapi/plugin_module.cc (working copy) |
@@ -86,9 +86,16 @@ |
#include "ppapi/shared_impl/time_conversion.h" |
#include "ppapi/thunk/enter.h" |
#include "ppapi/thunk/thunk.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
#include "webkit/plugins/plugin_switches.h" |
#include "webkit/plugins/ppapi/callbacks.h" |
#include "webkit/plugins/ppapi/common.h" |
+#include "webkit/plugins/ppapi/event_conversion.h" |
#include "webkit/plugins/ppapi/host_globals.h" |
#include "webkit/plugins/ppapi/host_resource_tracker.h" |
#include "webkit/plugins/ppapi/ppapi_interface_factory.h" |
@@ -114,12 +121,16 @@ |
#include "webkit/plugins/ppapi/ppb_video_layer_impl.h" |
#include "webkit/plugins/ppapi/webkit_forwarding_impl.h" |
+using ppapi::InputEventData; |
using ppapi::PpapiGlobals; |
using ppapi::TimeTicksToPPTimeTicks; |
using ppapi::TimeToPPTime; |
using ppapi::thunk::EnterResource; |
using ppapi::thunk::PPB_Graphics2D_API; |
+using WebKit::WebView; |
+using WebKit::WebInputEvent; |
+ |
namespace webkit { |
namespace ppapi { |
@@ -222,12 +233,91 @@ |
return PP_FALSE; |
} |
+WebView* GetViewForInstance(PP_Instance instance) { |
+ PluginInstance* plugin_instance = host_globals->GetInstance(instance); |
+ if (!plugin_instance) |
+ return NULL; |
+ return plugin_instance->container()->element().document().frame()->view(); |
+} |
+ |
+void GenerateKeyEvent( |
+ PP_Instance instance, |
+ PP_InputEvent_Type type, |
+ const PP_InputEvent_Key& key_event) { |
+ InputEventData input_event; |
+ input_event.event_type = type; |
+ input_event.event_time_stamp = GetTickTime(); |
+ input_event.event_modifiers = key_event.modifier; |
+ input_event.key_code = key_event.key_code; |
+ scoped_ptr<WebInputEvent> web_event(CreateWebInputEvent(input_event)); |
+ WebView* web_view = GetViewForInstance(instance); |
+ if (web_view && web_event.get()) |
+ web_view->handleInputEvent(*web_event); |
+} |
+ |
+void GenerateCharacterEvent( |
+ PP_Instance instance, |
+ const PP_InputEvent_Character& character_event) |
+{ |
+ InputEventData input_event; |
+ input_event.event_type = PP_INPUTEVENT_TYPE_CHAR; |
+ input_event.event_time_stamp = GetTickTime(); |
+ input_event.event_modifiers = character_event.modifier; |
+ input_event.character_text = character_event.text; |
+ scoped_ptr<WebInputEvent> web_event(CreateWebInputEvent(input_event)); |
+ WebView* web_view = GetViewForInstance(instance); |
+ if (web_view && web_event.get()) |
+ web_view->handleInputEvent(*web_event); |
+} |
+ |
+void GenerateMouseEvent( |
+ PP_Instance instance, |
+ PP_InputEvent_Type type, |
+ const PP_InputEvent_Mouse& mouse_event) |
+{ |
+ InputEventData input_event; |
+ input_event.event_type = type; |
+ input_event.event_time_stamp = GetTickTime(); |
+ input_event.event_modifiers = mouse_event.modifier; |
+ input_event.mouse_button = mouse_event.button; |
+ input_event.mouse_position = PP_MakePoint(mouse_event.x, mouse_event.y); |
+ input_event.mouse_movement = PP_Point(); |
+ input_event.mouse_click_count = mouse_event.click_count; |
+ scoped_ptr<WebInputEvent> web_event(CreateWebInputEvent(input_event)); |
+ WebView* web_view = GetViewForInstance(instance); |
+ if (web_view && web_event.get()) |
+ web_view->handleInputEvent(*web_event); |
+} |
+ |
+void GenerateWheelEvent( |
+ PP_Instance instance, |
+ const PP_InputEvent_Wheel& wheel_event) |
+{ |
+ InputEventData input_event; |
+ input_event.event_type = PP_INPUTEVENT_TYPE_WHEEL; |
+ input_event.event_time_stamp = GetTickTime(); |
+ input_event.event_modifiers = wheel_event.modifier; |
+ input_event.wheel_delta = |
+ PP_MakeFloatPoint(wheel_event.delta_x, wheel_event.delta_y); |
+ input_event.wheel_ticks = |
+ PP_MakeFloatPoint(wheel_event.wheel_ticks_x, wheel_event.wheel_ticks_y); |
+ input_event.wheel_scroll_by_page = (wheel_event.scroll_by_page == PP_TRUE); |
+ scoped_ptr<WebInputEvent> web_event(CreateWebInputEvent(input_event)); |
+ WebView* web_view = GetViewForInstance(instance); |
+ if (web_view && web_event.get()) |
+ web_view->handleInputEvent(*web_event); |
+} |
+ |
const PPB_Testing_Dev testing_interface = { |
&ReadImageData, |
&RunMessageLoop, |
&QuitMessageLoop, |
&GetLiveObjectsForInstance, |
- &IsOutOfProcess |
+ &IsOutOfProcess, |
+ &GenerateKeyEvent, |
+ &GenerateCharacterEvent, |
+ &GenerateMouseEvent, |
+ &GenerateWheelEvent, |
}; |
// GetInterface ---------------------------------------------------------------- |