| 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 "webkit/plugins/ppapi/plugin_module.h" | 5 #include "webkit/plugins/ppapi/plugin_module.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "ppapi/c/trusted/ppb_buffer_trusted.h" | 79 #include "ppapi/c/trusted/ppb_buffer_trusted.h" |
| 80 #include "ppapi/c/trusted/ppb_file_chooser_trusted.h" | 80 #include "ppapi/c/trusted/ppb_file_chooser_trusted.h" |
| 81 #include "ppapi/c/trusted/ppb_file_io_trusted.h" | 81 #include "ppapi/c/trusted/ppb_file_io_trusted.h" |
| 82 #include "ppapi/c/trusted/ppb_graphics_3d_trusted.h" | 82 #include "ppapi/c/trusted/ppb_graphics_3d_trusted.h" |
| 83 #include "ppapi/c/trusted/ppb_image_data_trusted.h" | 83 #include "ppapi/c/trusted/ppb_image_data_trusted.h" |
| 84 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" | 84 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" |
| 85 #include "ppapi/shared_impl/input_event_impl.h" | 85 #include "ppapi/shared_impl/input_event_impl.h" |
| 86 #include "ppapi/shared_impl/time_conversion.h" | 86 #include "ppapi/shared_impl/time_conversion.h" |
| 87 #include "ppapi/thunk/enter.h" | 87 #include "ppapi/thunk/enter.h" |
| 88 #include "ppapi/thunk/thunk.h" | 88 #include "ppapi/thunk/thunk.h" |
| 89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 89 #include "webkit/plugins/plugin_switches.h" | 95 #include "webkit/plugins/plugin_switches.h" |
| 90 #include "webkit/plugins/ppapi/callbacks.h" | 96 #include "webkit/plugins/ppapi/callbacks.h" |
| 91 #include "webkit/plugins/ppapi/common.h" | 97 #include "webkit/plugins/ppapi/common.h" |
| 98 #include "webkit/plugins/ppapi/event_conversion.h" |
| 92 #include "webkit/plugins/ppapi/host_globals.h" | 99 #include "webkit/plugins/ppapi/host_globals.h" |
| 93 #include "webkit/plugins/ppapi/host_resource_tracker.h" | 100 #include "webkit/plugins/ppapi/host_resource_tracker.h" |
| 94 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" | 101 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" |
| 95 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 102 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 96 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" | 103 #include "webkit/plugins/ppapi/ppb_directory_reader_impl.h" |
| 97 #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" | 104 #include "webkit/plugins/ppapi/ppb_flash_clipboard_impl.h" |
| 98 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h" | 105 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h" |
| 99 #include "webkit/plugins/ppapi/ppb_flash_impl.h" | 106 #include "webkit/plugins/ppapi/ppb_flash_impl.h" |
| 100 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" | 107 #include "webkit/plugins/ppapi/ppb_flash_menu_impl.h" |
| 101 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" | 108 #include "webkit/plugins/ppapi/ppb_flash_net_connector_impl.h" |
| 102 #include "webkit/plugins/ppapi/ppb_font_impl.h" | 109 #include "webkit/plugins/ppapi/ppb_font_impl.h" |
| 103 #include "webkit/plugins/ppapi/ppb_gpu_blacklist_private_impl.h" | 110 #include "webkit/plugins/ppapi/ppb_gpu_blacklist_private_impl.h" |
| 104 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" | 111 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" |
| 105 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" | 112 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
| 106 #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h" | 113 #include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h" |
| 107 #include "webkit/plugins/ppapi/ppb_opengles_impl.h" | 114 #include "webkit/plugins/ppapi/ppb_opengles_impl.h" |
| 108 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" | 115 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" |
| 109 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" | 116 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" |
| 110 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" | 117 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" |
| 111 #include "webkit/plugins/ppapi/ppb_var_impl.h" | 118 #include "webkit/plugins/ppapi/ppb_var_impl.h" |
| 112 #include "webkit/plugins/ppapi/ppb_video_capture_impl.h" | 119 #include "webkit/plugins/ppapi/ppb_video_capture_impl.h" |
| 113 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" | 120 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" |
| 114 #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" | 121 #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" |
| 115 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" | 122 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" |
| 116 | 123 |
| 124 using ppapi::InputEventData; |
| 117 using ppapi::PpapiGlobals; | 125 using ppapi::PpapiGlobals; |
| 118 using ppapi::TimeTicksToPPTimeTicks; | 126 using ppapi::TimeTicksToPPTimeTicks; |
| 119 using ppapi::TimeToPPTime; | 127 using ppapi::TimeToPPTime; |
| 120 using ppapi::thunk::EnterResource; | 128 using ppapi::thunk::EnterResource; |
| 121 using ppapi::thunk::PPB_Graphics2D_API; | 129 using ppapi::thunk::PPB_Graphics2D_API; |
| 122 | 130 |
| 131 using WebKit::WebView; |
| 132 using WebKit::WebInputEvent; |
| 133 |
| 123 namespace webkit { | 134 namespace webkit { |
| 124 namespace ppapi { | 135 namespace ppapi { |
| 125 | 136 |
| 126 namespace { | 137 namespace { |
| 127 | 138 |
| 128 // Global tracking info for PPAPI plugins. This is lazily created before the | 139 // Global tracking info for PPAPI plugins. This is lazily created before the |
| 129 // first plugin is allocated, and leaked on shutdown. | 140 // first plugin is allocated, and leaked on shutdown. |
| 130 // | 141 // |
| 131 // Note that we don't want a Singleton here since destroying this object will | 142 // Note that we don't want a Singleton here since destroying this object will |
| 132 // try to free some stuff that requires WebKit, and Singletons are destroyed | 143 // try to free some stuff that requires WebKit, and Singletons are destroyed |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 226 |
| 216 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { | 227 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { |
| 217 return HostGlobals::Get()->host_resource_tracker()->GetLiveObjectsForInstance( | 228 return HostGlobals::Get()->host_resource_tracker()->GetLiveObjectsForInstance( |
| 218 instance_id); | 229 instance_id); |
| 219 } | 230 } |
| 220 | 231 |
| 221 PP_Bool IsOutOfProcess() { | 232 PP_Bool IsOutOfProcess() { |
| 222 return PP_FALSE; | 233 return PP_FALSE; |
| 223 } | 234 } |
| 224 | 235 |
| 236 WebView* GetViewForInstance(PP_Instance instance) { |
| 237 PluginInstance* plugin_instance = host_globals->GetInstance(instance); |
| 238 if (!plugin_instance) |
| 239 return NULL; |
| 240 return plugin_instance->container()->element().document().frame()->view(); |
| 241 } |
| 242 |
| 243 void GenerateKeyEvent( |
| 244 PP_Instance instance, |
| 245 PP_InputEvent_Type type, |
| 246 const PP_InputEvent_Key& key_event) { |
| 247 InputEventData input_event; |
| 248 input_event.event_type = type; |
| 249 input_event.event_time_stamp = GetTickTime(); |
| 250 input_event.event_modifiers = key_event.modifier; |
| 251 input_event.key_code = key_event.key_code; |
| 252 scoped_ptr<WebInputEvent> web_event(CreateWebInputEvent(input_event)); |
| 253 WebView* web_view = GetViewForInstance(instance); |
| 254 if (web_view && web_event.get()) |
| 255 web_view->handleInputEvent(*web_event); |
| 256 } |
| 257 |
| 258 void GenerateCharacterEvent( |
| 259 PP_Instance instance, |
| 260 const PP_InputEvent_Character& character_event) |
| 261 { |
| 262 InputEventData input_event; |
| 263 input_event.event_type = PP_INPUTEVENT_TYPE_CHAR; |
| 264 input_event.event_time_stamp = GetTickTime(); |
| 265 input_event.event_modifiers = character_event.modifier; |
| 266 input_event.character_text = character_event.text; |
| 267 scoped_ptr<WebInputEvent> web_event(CreateWebInputEvent(input_event)); |
| 268 WebView* web_view = GetViewForInstance(instance); |
| 269 if (web_view && web_event.get()) |
| 270 web_view->handleInputEvent(*web_event); |
| 271 } |
| 272 |
| 273 void GenerateMouseEvent( |
| 274 PP_Instance instance, |
| 275 PP_InputEvent_Type type, |
| 276 const PP_InputEvent_Mouse& mouse_event) |
| 277 { |
| 278 InputEventData input_event; |
| 279 input_event.event_type = type; |
| 280 input_event.event_time_stamp = GetTickTime(); |
| 281 input_event.event_modifiers = mouse_event.modifier; |
| 282 input_event.mouse_button = mouse_event.button; |
| 283 input_event.mouse_position = PP_MakePoint(mouse_event.x, mouse_event.y); |
| 284 input_event.mouse_movement = PP_Point(); |
| 285 input_event.mouse_click_count = mouse_event.click_count; |
| 286 scoped_ptr<WebInputEvent> web_event(CreateWebInputEvent(input_event)); |
| 287 WebView* web_view = GetViewForInstance(instance); |
| 288 if (web_view && web_event.get()) |
| 289 web_view->handleInputEvent(*web_event); |
| 290 } |
| 291 |
| 292 void GenerateWheelEvent( |
| 293 PP_Instance instance, |
| 294 const PP_InputEvent_Wheel& wheel_event) |
| 295 { |
| 296 InputEventData input_event; |
| 297 input_event.event_type = PP_INPUTEVENT_TYPE_WHEEL; |
| 298 input_event.event_time_stamp = GetTickTime(); |
| 299 input_event.event_modifiers = wheel_event.modifier; |
| 300 input_event.wheel_delta = |
| 301 PP_MakeFloatPoint(wheel_event.delta_x, wheel_event.delta_y); |
| 302 input_event.wheel_ticks = |
| 303 PP_MakeFloatPoint(wheel_event.wheel_ticks_x, wheel_event.wheel_ticks_y); |
| 304 input_event.wheel_scroll_by_page = (wheel_event.scroll_by_page == PP_TRUE); |
| 305 scoped_ptr<WebInputEvent> web_event(CreateWebInputEvent(input_event)); |
| 306 WebView* web_view = GetViewForInstance(instance); |
| 307 if (web_view && web_event.get()) |
| 308 web_view->handleInputEvent(*web_event); |
| 309 } |
| 310 |
| 225 const PPB_Testing_Dev testing_interface = { | 311 const PPB_Testing_Dev testing_interface = { |
| 226 &ReadImageData, | 312 &ReadImageData, |
| 227 &RunMessageLoop, | 313 &RunMessageLoop, |
| 228 &QuitMessageLoop, | 314 &QuitMessageLoop, |
| 229 &GetLiveObjectsForInstance, | 315 &GetLiveObjectsForInstance, |
| 230 &IsOutOfProcess | 316 &IsOutOfProcess, |
| 317 &GenerateKeyEvent, |
| 318 &GenerateCharacterEvent, |
| 319 &GenerateMouseEvent, |
| 320 &GenerateWheelEvent, |
| 231 }; | 321 }; |
| 232 | 322 |
| 233 // GetInterface ---------------------------------------------------------------- | 323 // GetInterface ---------------------------------------------------------------- |
| 234 | 324 |
| 235 const void* GetInterface(const char* name) { | 325 const void* GetInterface(const char* name) { |
| 236 // All interfaces should be used on the main thread. | 326 // All interfaces should be used on the main thread. |
| 237 CHECK(IsMainThread()); | 327 CHECK(IsMainThread()); |
| 238 | 328 |
| 239 // Allow custom interface factories first stab at the GetInterface call. | 329 // Allow custom interface factories first stab at the GetInterface call. |
| 240 const void* custom_interface = | 330 const void* custom_interface = |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 int retval = entry_points.initialize_module(pp_module(), &GetInterface); | 646 int retval = entry_points.initialize_module(pp_module(), &GetInterface); |
| 557 if (retval != 0) { | 647 if (retval != 0) { |
| 558 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; | 648 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; |
| 559 return false; | 649 return false; |
| 560 } | 650 } |
| 561 return true; | 651 return true; |
| 562 } | 652 } |
| 563 | 653 |
| 564 } // namespace ppapi | 654 } // namespace ppapi |
| 565 } // namespace webkit | 655 } // namespace webkit |
| OLD | NEW |