Chromium Code Reviews| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 #include "webkit/plugins/ppapi/ppb_opengles_impl.h" | 108 #include "webkit/plugins/ppapi/ppb_opengles_impl.h" |
| 109 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" | 109 #include "webkit/plugins/ppapi/ppb_proxy_impl.h" |
| 110 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" | 110 #include "webkit/plugins/ppapi/ppb_scrollbar_impl.h" |
| 111 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" | 111 #include "webkit/plugins/ppapi/ppb_uma_private_impl.h" |
| 112 #include "webkit/plugins/ppapi/ppb_var_impl.h" | 112 #include "webkit/plugins/ppapi/ppb_var_impl.h" |
| 113 #include "webkit/plugins/ppapi/ppb_video_capture_impl.h" | 113 #include "webkit/plugins/ppapi/ppb_video_capture_impl.h" |
| 114 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" | 114 #include "webkit/plugins/ppapi/ppb_video_decoder_impl.h" |
| 115 #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" | 115 #include "webkit/plugins/ppapi/ppb_video_layer_impl.h" |
| 116 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" | 116 #include "webkit/plugins/ppapi/webkit_forwarding_impl.h" |
| 117 | 117 |
| 118 using ppapi::InputEventData; | |
| 118 using ppapi::PpapiGlobals; | 119 using ppapi::PpapiGlobals; |
| 119 using ppapi::TimeTicksToPPTimeTicks; | 120 using ppapi::TimeTicksToPPTimeTicks; |
| 120 using ppapi::TimeToPPTime; | 121 using ppapi::TimeToPPTime; |
| 121 using ppapi::thunk::EnterResource; | 122 using ppapi::thunk::EnterResource; |
| 122 using ppapi::thunk::PPB_Graphics2D_API; | 123 using ppapi::thunk::PPB_Graphics2D_API; |
| 124 using ppapi::thunk::PPB_InputEvent_API; | |
| 123 | 125 |
| 124 namespace webkit { | 126 namespace webkit { |
| 125 namespace ppapi { | 127 namespace ppapi { |
| 126 | 128 |
| 127 namespace { | 129 namespace { |
| 128 | 130 |
| 129 // Global tracking info for PPAPI plugins. This is lazily created before the | 131 // Global tracking info for PPAPI plugins. This is lazily created before the |
| 130 // first plugin is allocated, and leaked on shutdown. | 132 // first plugin is allocated, and leaked on shutdown. |
| 131 // | 133 // |
| 132 // Note that we don't want a Singleton here since destroying this object will | 134 // Note that we don't want a Singleton here since destroying this object will |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 218 |
| 217 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { | 219 uint32_t GetLiveObjectsForInstance(PP_Instance instance_id) { |
| 218 return HostGlobals::Get()->host_resource_tracker()->GetLiveObjectsForInstance( | 220 return HostGlobals::Get()->host_resource_tracker()->GetLiveObjectsForInstance( |
| 219 instance_id); | 221 instance_id); |
| 220 } | 222 } |
| 221 | 223 |
| 222 PP_Bool IsOutOfProcess() { | 224 PP_Bool IsOutOfProcess() { |
| 223 return PP_FALSE; | 225 return PP_FALSE; |
| 224 } | 226 } |
| 225 | 227 |
| 228 void SimulateInputEvent(PP_Instance instance, PP_Resource input_event) { | |
| 229 PluginInstance* plugin_instance = host_globals->GetInstance(instance); | |
| 230 if (!plugin_instance) { | |
| 231 NOTREACHED(); | |
| 232 return; | |
| 233 } | |
| 234 EnterResource<PPB_InputEvent_API> enter(input_event, false); | |
| 235 if (enter.failed()) { | |
| 236 NOTREACHED(); | |
| 237 return; | |
| 238 } | |
| 239 const InputEventData& input_event_data = enter.object()->GetInputEventData(); | |
| 240 plugin_instance->SimulateInputEvent(input_event_data); | |
| 241 } | |
| 242 | |
| 226 const PPB_Testing_Dev testing_interface = { | 243 const PPB_Testing_Dev testing_interface = { |
| 227 &ReadImageData, | 244 &ReadImageData, |
| 228 &RunMessageLoop, | 245 &RunMessageLoop, |
| 229 &QuitMessageLoop, | 246 &QuitMessageLoop, |
| 230 &GetLiveObjectsForInstance, | 247 &GetLiveObjectsForInstance, |
| 231 &IsOutOfProcess | 248 &IsOutOfProcess, |
| 249 &SimulateInputEvent | |
| 232 }; | 250 }; |
| 233 | 251 |
| 234 // GetInterface ---------------------------------------------------------------- | 252 // GetInterface ---------------------------------------------------------------- |
| 235 | 253 |
| 236 const void* GetInterface(const char* name) { | 254 const void* GetInterface(const char* name) { |
| 237 // All interfaces should be used on the main thread. | 255 // All interfaces should be used on the main thread. |
| 238 CHECK(IsMainThread()); | 256 CHECK(IsMainThread()); |
| 239 | 257 |
| 240 // Allow custom interface factories first stab at the GetInterface call. | 258 // Allow custom interface factories first stab at the GetInterface call. |
| 241 const void* custom_interface = | 259 const void* custom_interface = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 return PPB_Var_Impl::GetVarInterface(); | 331 return PPB_Var_Impl::GetVarInterface(); |
| 314 | 332 |
| 315 #ifdef ENABLE_FLAPPER_HACKS | 333 #ifdef ENABLE_FLAPPER_HACKS |
| 316 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) | 334 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) |
| 317 return ::ppapi::thunk::GetPPB_Flash_NetConnector_Thunk(); | 335 return ::ppapi::thunk::GetPPB_Flash_NetConnector_Thunk(); |
| 318 #endif // ENABLE_FLAPPER_HACKS | 336 #endif // ENABLE_FLAPPER_HACKS |
| 319 | 337 |
| 320 // Only support the testing interface when the command line switch is | 338 // Only support the testing interface when the command line switch is |
| 321 // specified. This allows us to prevent people from (ab)using this interface | 339 // specified. This allows us to prevent people from (ab)using this interface |
| 322 // in production code. | 340 // in production code. |
| 323 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0) { | 341 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 324 if (CommandLine::ForCurrentProcess()->HasSwitch( | 342 switches::kEnablePepperTesting)) { |
|
dmichael (off chromium)
2011/11/18 03:44:45
Ah, nice catch. I meant the line above, though :-)
bbudge
2011/11/18 19:00:06
Done.
| |
| 325 switches::kEnablePepperTesting)) | 343 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0 || |
| 344 strcmp(name, PPB_TESTING_DEV_INTERFACE_0_7) == 0) { | |
| 326 return &testing_interface; | 345 return &testing_interface; |
| 346 } | |
| 327 } | 347 } |
| 328 return NULL; | 348 return NULL; |
| 329 } | 349 } |
| 330 | 350 |
| 331 // Gets the PPAPI entry points from the given library and places them into the | 351 // Gets the PPAPI entry points from the given library and places them into the |
| 332 // given structure. Returns true on success. | 352 // given structure. Returns true on success. |
| 333 bool LoadEntryPointsFromLibrary(const base::NativeLibrary& library, | 353 bool LoadEntryPointsFromLibrary(const base::NativeLibrary& library, |
| 334 PluginModule::EntryPoints* entry_points) { | 354 PluginModule::EntryPoints* entry_points) { |
| 335 entry_points->get_interface = | 355 entry_points->get_interface = |
| 336 reinterpret_cast<PluginModule::GetInterfaceFunc>( | 356 reinterpret_cast<PluginModule::GetInterfaceFunc>( |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 int retval = entry_points.initialize_module(pp_module(), &GetInterface); | 577 int retval = entry_points.initialize_module(pp_module(), &GetInterface); |
| 558 if (retval != 0) { | 578 if (retval != 0) { |
| 559 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; | 579 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; |
| 560 return false; | 580 return false; |
| 561 } | 581 } |
| 562 return true; | 582 return true; |
| 563 } | 583 } |
| 564 | 584 |
| 565 } // namespace ppapi | 585 } // namespace ppapi |
| 566 } // namespace webkit | 586 } // namespace webkit |
| OLD | NEW |