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