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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 if (strcmp(name, PPB_FONT_DEV_INTERFACE) == 0) | 263 if (strcmp(name, PPB_FONT_DEV_INTERFACE) == 0) |
264 return PPB_Font_Impl::GetInterface(); | 264 return PPB_Font_Impl::GetInterface(); |
265 if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE) == 0) | 265 if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE) == 0) |
266 return PluginInstance::GetFullscreenInterface(); | 266 return PluginInstance::GetFullscreenInterface(); |
267 if (strcmp(name, PPB_GRAPHICS_2D_INTERFACE) == 0) | 267 if (strcmp(name, PPB_GRAPHICS_2D_INTERFACE) == 0) |
268 return PPB_Graphics2D_Impl::GetInterface(); | 268 return PPB_Graphics2D_Impl::GetInterface(); |
269 if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0) | 269 if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0) |
270 return PPB_ImageData_Impl::GetInterface(); | 270 return PPB_ImageData_Impl::GetInterface(); |
271 if (strcmp(name, PPB_IMAGEDATA_TRUSTED_INTERFACE) == 0) | 271 if (strcmp(name, PPB_IMAGEDATA_TRUSTED_INTERFACE) == 0) |
272 return PPB_ImageData_Impl::GetTrustedInterface(); | 272 return PPB_ImageData_Impl::GetTrustedInterface(); |
273 if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0) | |
274 return PluginInstance::GetInterface(); | |
275 if (strcmp(name, PPB_PDF_INTERFACE) == 0) | 273 if (strcmp(name, PPB_PDF_INTERFACE) == 0) |
276 return PPB_PDF_Impl::GetInterface(); | 274 return PPB_PDF_Impl::GetInterface(); |
277 if (strcmp(name, PPB_PROXY_PRIVATE_INTERFACE) == 0) | 275 if (strcmp(name, PPB_PROXY_PRIVATE_INTERFACE) == 0) |
278 return PPB_Proxy_Impl::GetInterface(); | 276 return PPB_Proxy_Impl::GetInterface(); |
279 if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE) == 0) | 277 if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE) == 0) |
280 return PPB_Scrollbar_Impl::GetInterface(); | 278 return PPB_Scrollbar_Impl::GetInterface(); |
281 if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0) | 279 if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0) |
282 return PPB_Transport_Impl::GetInterface(); | 280 return PPB_Transport_Impl::GetInterface(); |
283 if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0) | 281 if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0) |
284 return PPB_URLLoader_Impl::GetInterface(); | 282 return PPB_URLLoader_Impl::GetInterface(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 if (strcmp(name, PPB_SURFACE_3D_DEV_INTERFACE) == 0) | 315 if (strcmp(name, PPB_SURFACE_3D_DEV_INTERFACE) == 0) |
318 return PPB_Surface3D_Impl::GetInterface(); | 316 return PPB_Surface3D_Impl::GetInterface(); |
319 } | 317 } |
320 #endif // ENABLE_GPU | 318 #endif // ENABLE_GPU |
321 | 319 |
322 #ifdef ENABLE_FLAPPER_HACKS | 320 #ifdef ENABLE_FLAPPER_HACKS |
323 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) | 321 if (strcmp(name, PPB_FLASH_NETCONNECTOR_INTERFACE) == 0) |
324 return PPB_Flash_NetConnector_Impl::GetInterface(); | 322 return PPB_Flash_NetConnector_Impl::GetInterface(); |
325 #endif // ENABLE_FLAPPER_HACKS | 323 #endif // ENABLE_FLAPPER_HACKS |
326 | 324 |
325 // PluginInstance supports multiple PPB_Instance interfaces. Get the right | |
326 // one, if supports one. | |
327 const void* interface = PluginInstance::GetInterface(name); | |
328 if (interface != NULL) | |
329 return interface; | |
330 | |
327 // Only support the testing interface when the command line switch is | 331 // Only support the testing interface when the command line switch is |
328 // specified. This allows us to prevent people from (ab)using this interface | 332 // specified. This allows us to prevent people from (ab)using this interface |
329 // in production code. | 333 // in production code. |
330 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0) { | 334 if (strcmp(name, PPB_TESTING_DEV_INTERFACE) == 0) { |
331 if (CommandLine::ForCurrentProcess()->HasSwitch("enable-pepper-testing")) | 335 if (CommandLine::ForCurrentProcess()->HasSwitch("enable-pepper-testing")) |
332 return &testing_interface; | 336 return &testing_interface; |
333 } | 337 } |
334 return NULL; | 338 return NULL; |
335 } | 339 } |
336 | 340 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 const PPB_Core* PluginModule::GetCore() { | 445 const PPB_Core* PluginModule::GetCore() { |
442 return &core_interface; | 446 return &core_interface; |
443 } | 447 } |
444 | 448 |
445 // static | 449 // static |
446 PluginModule::GetInterfaceFunc PluginModule::GetLocalGetInterfaceFunc() { | 450 PluginModule::GetInterfaceFunc PluginModule::GetLocalGetInterfaceFunc() { |
447 return &GetInterface; | 451 return &GetInterface; |
448 } | 452 } |
449 | 453 |
450 PluginInstance* PluginModule::CreateInstance(PluginDelegate* delegate) { | 454 PluginInstance* PluginModule::CreateInstance(PluginDelegate* delegate) { |
455 PluginInstance* instance(NULL); | |
451 const PPP_Instance* plugin_instance_interface = | 456 const PPP_Instance* plugin_instance_interface = |
452 reinterpret_cast<const PPP_Instance*>(GetPluginInterface( | 457 reinterpret_cast<const PPP_Instance*>(GetPluginInterface( |
453 PPP_INSTANCE_INTERFACE)); | 458 PPP_INSTANCE_INTERFACE)); |
454 if (!plugin_instance_interface) { | 459 if (plugin_instance_interface != NULL) { |
460 instance = new PluginInstance(delegate, this, plugin_instance_interface, | |
brettw
2011/03/16 21:34:11
What about just passing the instance interface obj
dmichael(do not use this one)
2011/03/21 21:43:35
Good idea. But since I'm going to follow Neb's su
| |
461 PluginInstance::PLUGIN_OWNS_INTERFACE); | |
462 } else { | |
463 // If the current version failed, try versions we currently support. | |
464 const void* ppp_instance_if_0_4( | |
465 GetPluginInterface(PPP_INSTANCE_INTERFACE_0_4)); | |
466 if (ppp_instance_if_0_4 != NULL) { | |
467 PPP_Instance* ppp_instance_interface = new PPP_Instance; | |
468 std::memset(ppp_instance_interface, 0, | |
469 sizeof(*plugin_instance_interface)); | |
470 std::memcpy(ppp_instance_interface, ppp_instance_if_0_4, | |
471 sizeof(PPP_Instance_0_4)); | |
472 instance = new PluginInstance(delegate, this, ppp_instance_interface, | |
473 PluginInstance::BROWSER_OWNS_INTERFACE); | |
474 } | |
475 } | |
476 if (!instance) { | |
455 LOG(WARNING) << "Plugin doesn't support instance interface, failing."; | 477 LOG(WARNING) << "Plugin doesn't support instance interface, failing."; |
456 return NULL; | 478 return NULL; |
457 } | 479 } |
458 PluginInstance* instance = new PluginInstance(delegate, this, | |
459 plugin_instance_interface); | |
460 if (out_of_process_proxy_.get()) | 480 if (out_of_process_proxy_.get()) |
461 out_of_process_proxy_->AddInstance(instance->pp_instance()); | 481 out_of_process_proxy_->AddInstance(instance->pp_instance()); |
462 return instance; | 482 return instance; |
463 } | 483 } |
464 | 484 |
465 PluginInstance* PluginModule::GetSomeInstance() const { | 485 PluginInstance* PluginModule::GetSomeInstance() const { |
466 // This will generally crash later if there is not actually any instance to | 486 // This will generally crash later if there is not actually any instance to |
467 // return, so we force a crash now to make bugs easier to track down. | 487 // return, so we force a crash now to make bugs easier to track down. |
468 CHECK(!instances_.empty()); | 488 CHECK(!instances_.empty()); |
469 return *instances_.begin(); | 489 return *instances_.begin(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 if (retval != 0) { | 531 if (retval != 0) { |
512 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; | 532 LOG(WARNING) << "PPP_InitializeModule returned failure " << retval; |
513 return false; | 533 return false; |
514 } | 534 } |
515 return true; | 535 return true; |
516 } | 536 } |
517 | 537 |
518 } // namespace ppapi | 538 } // namespace ppapi |
519 } // namespace webkit | 539 } // namespace webkit |
520 | 540 |
OLD | NEW |