Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: webkit/plugins/ppapi/plugin_module.cc

Issue 8413021: Add functions to generate input events to PPB_Testing_Dev. These make (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/event_conversion.cc ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 return;
234
235 EnterResource<PPB_InputEvent_API> enter(input_event, false);
236 if (enter.failed())
237 return;
238
239 const InputEventData& input_event_data = enter.object()->GetInputEventData();
240 plugin_instance->SimulateInputEvent(input_event_data);
241 }
242
228 const PPB_Testing_Dev testing_interface = { 243 const PPB_Testing_Dev testing_interface = {
229 &ReadImageData, 244 &ReadImageData,
230 &RunMessageLoop, 245 &RunMessageLoop,
231 &QuitMessageLoop, 246 &QuitMessageLoop,
232 &GetLiveObjectsForInstance, 247 &GetLiveObjectsForInstance,
233 &IsOutOfProcess 248 &IsOutOfProcess,
249 &SimulateInputEvent
234 }; 250 };
235 251
236 // GetInterface ---------------------------------------------------------------- 252 // GetInterface ----------------------------------------------------------------
237 253
238 const void* GetInterface(const char* name) { 254 const void* GetInterface(const char* name) {
239 // All interfaces should be used on the main thread. 255 // All interfaces should be used on the main thread.
240 CHECK(IsMainThread()); 256 CHECK(IsMainThread());
241 257
242 // Allow custom interface factories first stab at the GetInterface call. 258 // Allow custom interface factories first stab at the GetInterface call.
243 const void* custom_interface = 259 const void* custom_interface =
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return PPB_Var_Impl::GetVarInterface(); 333 return PPB_Var_Impl::GetVarInterface();
318 334
319 #ifdef ENABLE_FLAPPER_HACKS 335 #ifdef ENABLE_FLAPPER_HACKS
320 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) 336 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0)
321 return ::ppapi::thunk::GetPPB_Flash_NetConnector_Thunk(); 337 return ::ppapi::thunk::GetPPB_Flash_NetConnector_Thunk();
322 #endif // ENABLE_FLAPPER_HACKS 338 #endif // ENABLE_FLAPPER_HACKS
323 339
324 // Only support the testing interface when the command line switch is 340 // Only support the testing interface when the command line switch is
325 // specified. This allows us to prevent people from (ab)using this interface 341 // specified. This allows us to prevent people from (ab)using this interface
326 // in production code. 342 // in production code.
327 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0) { 343 if (CommandLine::ForCurrentProcess()->HasSwitch(
328 if (CommandLine::ForCurrentProcess()->HasSwitch( 344 switches::kEnablePepperTesting)) {
329 switches::kEnablePepperTesting)) 345 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0 ||
346 strcmp(name, PPB_TESTING_DEV_INTERFACE_0_7) == 0) {
330 return &testing_interface; 347 return &testing_interface;
348 }
331 } 349 }
332 return NULL; 350 return NULL;
333 } 351 }
334 352
335 // Gets the PPAPI entry points from the given library and places them into the 353 // Gets the PPAPI entry points from the given library and places them into the
336 // given structure. Returns true on success. 354 // given structure. Returns true on success.
337 bool LoadEntryPointsFromLibrary(const base::NativeLibrary& library, 355 bool LoadEntryPointsFromLibrary(const base::NativeLibrary& library,
338 PluginModule::EntryPoints* entry_points) { 356 PluginModule::EntryPoints* entry_points) {
339 entry_points->get_interface = 357 entry_points->get_interface =
340 reinterpret_cast<PluginModule::GetInterfaceFunc>( 358 reinterpret_cast<PluginModule::GetInterfaceFunc>(
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 int retval = entry_points.initialize_module(pp_module(), &GetInterface); 579 int retval = entry_points.initialize_module(pp_module(), &GetInterface);
562 if (retval != 0) { 580 if (retval != 0) {
563 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; 581 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval;
564 return false; 582 return false;
565 } 583 }
566 return true; 584 return true;
567 } 585 }
568 586
569 } // namespace ppapi 587 } // namespace ppapi
570 } // namespace webkit 588 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/event_conversion.cc ('k') | webkit/plugins/ppapi/ppapi_plugin_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698