diff options
author | sgjesse@chromium.org <sgjesse@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 09:26:58 +0000 |
---|---|---|
committer | sgjesse@chromium.org <sgjesse@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 09:26:58 +0000 |
commit | bc296f37929b762850ce2c3b317f8542bdace2a1 (patch) | |
tree | 7ae61fc12388c1c2cc8ae20974d1e78ecb94b45f /chrome/plugin/npobject_proxy.cc | |
parent | 9c5e417def0fef57d5dc79b0348dab9b0d354d42 (diff) | |
download | chromium_src-bc296f37929b762850ce2c3b317f8542bdace2a1.zip chromium_src-bc296f37929b762850ce2c3b317f8542bdace2a1.tar.gz chromium_src-bc296f37929b762850ce2c3b317f8542bdace2a1.tar.bz2 |
Added support for constructor calls in the NPAPI.
The LiveConnect test cases at http://java.sun.com/javase/6/webnotes/6u10/plugin2/liveconnect/LiveConnectTests/ now pass for Chromium.
Parts of this change is rather mechanical, and leaves room for some refactoring afterwards.
Merged the implementation of testConstruct and the "objectPointer" property from WebKit\WebKitTools\DumpRenderTree\TestNetscapePlugIn.subproj\TestObject.cpp to the Chromium TestObject.cpp for the layout test LayoutTests\plugins\netscape-construct.html pass.
BUG=http://crbug.com/3285
BUG=http://crbug.com/10354
TEST=http://java.sun.com/javase/6/webnotes/6u10/plugin2/liveconnect/LiveConnectTests/
TEST=LayoutTests\plugins\netscape-construct.html
Review URL: http://codereview.chromium.org/113823
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16979 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/npobject_proxy.cc')
-rw-r--r-- | chrome/plugin/npobject_proxy.cc | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/chrome/plugin/npobject_proxy.cc b/chrome/plugin/npobject_proxy.cc index fa48d87..f56832a 100644 --- a/chrome/plugin/npobject_proxy.cc +++ b/chrome/plugin/npobject_proxy.cc @@ -18,7 +18,7 @@ struct NPObjectWrapper { }; NPClass NPObjectProxy::npclass_proxy_ = { - 2, + NP_CLASS_STRUCT_VERSION, NPObjectProxy::NPAllocate, NPObjectProxy::NPDeallocate, NPObjectProxy::NPPInvalidate, @@ -29,7 +29,8 @@ NPClass NPObjectProxy::npclass_proxy_ = { NPObjectProxy::NPGetProperty, NPObjectProxy::NPSetProperty, NPObjectProxy::NPRemoveProperty, - NPObjectProxy::NPNEnumerate + NPObjectProxy::NPNEnumerate, + NPObjectProxy::NPNConstruct }; NPObjectProxy* NPObjectProxy::GetProxy(NPObject* object) { @@ -339,6 +340,50 @@ bool NPObjectProxy::NPNEnumerate(NPObject *obj, return true; } +bool NPObjectProxy::NPNConstruct(NPObject *obj, + const NPVariant *args, + uint32_t arg_count, + NPVariant *np_result) { + NPObjectProxy* proxy = GetProxy(obj); + if (!proxy) { + return obj->_class->construct(obj, args, arg_count, np_result); + } + + bool result = false; + + // Note: This instance can get destroyed in the context of + // Send so addref the channel in this scope. + scoped_refptr<PluginChannelBase> channel_copy = proxy->channel_; + std::vector<NPVariant_Param> args_param; + for (unsigned int i = 0; i < arg_count; ++i) { + NPVariant_Param param; + CreateNPVariantParam( + args[i], channel_copy, ¶m, false, proxy->modal_dialog_event_); + args_param.push_back(param); + } + + NPVariant_Param param_result; + NPObjectMsg_Construct* msg = new NPObjectMsg_Construct( + proxy->route_id_, args_param, ¶m_result, &result); + + // See comment in NPObjectProxy::NPInvokePrivate. + msg->set_pump_messages_event(proxy->modal_dialog_event_); + + base::WaitableEvent* modal_dialog_event_handle = proxy->modal_dialog_event_; + + proxy->Send(msg); + + // Send may delete proxy. + proxy = NULL; + + if (!result) + return false; + + CreateNPVariant( + param_result, channel_copy, np_result, modal_dialog_event_handle); + return true; +} + bool NPObjectProxy::NPNEvaluate(NPP npp, NPObject *obj, NPString *script, |