Index: webkit/plugins/ppapi/plugin_module.cc |
=================================================================== |
--- webkit/plugins/ppapi/plugin_module.cc (revision 77426) |
+++ webkit/plugins/ppapi/plugin_module.cc (working copy) |
@@ -270,8 +270,6 @@ |
return PPB_ImageData_Impl::GetInterface(); |
if (strcmp(name, PPB_IMAGEDATA_TRUSTED_INTERFACE) == 0) |
return PPB_ImageData_Impl::GetTrustedInterface(); |
- if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0) |
- return PluginInstance::GetInterface(); |
if (strcmp(name, PPB_PDF_INTERFACE) == 0) |
return PPB_PDF_Impl::GetInterface(); |
if (strcmp(name, PPB_PROXY_PRIVATE_INTERFACE) == 0) |
@@ -324,6 +322,12 @@ |
return PPB_Flash_NetConnector_Impl::GetInterface(); |
#endif // ENABLE_FLAPPER_HACKS |
+ // PluginInstance supports multiple PPB_Instance interfaces. Get the right |
+ // one, if supports one. |
+ const void* interface = PluginInstance::GetInterface(name); |
+ if (interface != NULL) |
+ return interface; |
+ |
// Only support the testing interface when the command line switch is |
// specified. This allows us to prevent people from (ab)using this interface |
// in production code. |
@@ -448,15 +452,31 @@ |
} |
PluginInstance* PluginModule::CreateInstance(PluginDelegate* delegate) { |
+ PluginInstance* instance(NULL); |
const PPP_Instance* plugin_instance_interface = |
reinterpret_cast<const PPP_Instance*>(GetPluginInterface( |
PPP_INSTANCE_INTERFACE)); |
- if (!plugin_instance_interface) { |
+ if (plugin_instance_interface != NULL) { |
+ 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
|
+ PluginInstance::PLUGIN_OWNS_INTERFACE); |
+ } else { |
+ // If the current version failed, try versions we currently support. |
+ const void* ppp_instance_if_0_4( |
+ GetPluginInterface(PPP_INSTANCE_INTERFACE_0_4)); |
+ if (ppp_instance_if_0_4 != NULL) { |
+ PPP_Instance* ppp_instance_interface = new PPP_Instance; |
+ std::memset(ppp_instance_interface, 0, |
+ sizeof(*plugin_instance_interface)); |
+ std::memcpy(ppp_instance_interface, ppp_instance_if_0_4, |
+ sizeof(PPP_Instance_0_4)); |
+ instance = new PluginInstance(delegate, this, ppp_instance_interface, |
+ PluginInstance::BROWSER_OWNS_INTERFACE); |
+ } |
+ } |
+ if (!instance) { |
LOG(WARNING) << "Plugin doesn't support instance interface, failing."; |
return NULL; |
} |
- PluginInstance* instance = new PluginInstance(delegate, this, |
- plugin_instance_interface); |
if (out_of_process_proxy_.get()) |
out_of_process_proxy_->AddInstance(instance->pp_instance()); |
return instance; |