From bc296f37929b762850ce2c3b317f8542bdace2a1 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Wed, 27 May 2009 09:26:58 +0000 Subject: 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 --- chrome/plugin/npobject_stub.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'chrome/plugin/npobject_stub.cc') diff --git a/chrome/plugin/npobject_stub.cc b/chrome/plugin/npobject_stub.cc index 26780d2..c5f14f5 100644 --- a/chrome/plugin/npobject_stub.cc +++ b/chrome/plugin/npobject_stub.cc @@ -64,6 +64,7 @@ void NPObjectStub::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(NPObjectMsg_RemoveProperty, OnRemoveProperty); IPC_MESSAGE_HANDLER(NPObjectMsg_Invalidate, OnInvalidate); IPC_MESSAGE_HANDLER(NPObjectMsg_Enumeration, OnEnumeration); + IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Construct, OnConstruct); IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Evaluate, OnEvaluate); IPC_MESSAGE_HANDLER(NPObjectMsg_SetException, OnSetException); IPC_MESSAGE_UNHANDLED_ERROR() @@ -267,6 +268,45 @@ void NPObjectStub::OnEnumeration(std::vector* value, NPN_MemFree(value_np); } +void NPObjectStub::OnConstruct(const std::vector& args, + IPC::Message* reply_msg) { + scoped_refptr local_channel = channel_; + bool return_value = false; + NPVariant_Param result_param; + NPVariant result_var; + + VOID_TO_NPVARIANT(result_var); + + int arg_count = static_cast(args.size()); + NPVariant* args_var = new NPVariant[arg_count]; + for (int i = 0; i < arg_count; ++i) { + CreateNPVariant( + args[i], local_channel, &(args_var[i]), modal_dialog_event_); + } + + if (IsPluginProcess()) { + if (npobject_->_class->construct) { + return_value = npobject_->_class->construct( + npobject_, args_var, arg_count, &result_var); + } else { + return_value = false; + } + } else { + return_value = NPN_Construct( + 0, npobject_, args_var, arg_count, &result_var); + } + + for (int i = 0; i < arg_count; ++i) + NPN_ReleaseVariantValue(&(args_var[i])); + + delete[] args_var; + + CreateNPVariantParam( + result_var, local_channel, &result_param, true, modal_dialog_event_); + NPObjectMsg_Invoke::WriteReplyParams(reply_msg, result_param, return_value); + local_channel->Send(reply_msg); +} + void NPObjectStub::OnEvaluate(const std::string& script, bool popups_allowed, IPC::Message* reply_msg) { -- cgit v1.1