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

Side by Side Diff: chrome/plugin/npobject_stub.cc

Issue 113823: Added support for constructor calls in the NPAPI (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months 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 | « chrome/plugin/npobject_stub.h ('k') | webkit/port/bindings/v8/NPV8Object.cpp » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/plugin/npobject_stub.h" 5 #include "chrome/plugin/npobject_stub.h"
6 6
7 #include "chrome/common/plugin_messages.h" 7 #include "chrome/common/plugin_messages.h"
8 #include "chrome/plugin/npobject_util.h" 8 #include "chrome/plugin/npobject_util.h"
9 #include "chrome/plugin/plugin_channel_base.h" 9 #include "chrome/plugin/plugin_channel_base.h"
10 #include "chrome/renderer/webplugin_delegate_proxy.h" 10 #include "chrome/renderer/webplugin_delegate_proxy.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 IPC_BEGIN_MESSAGE_MAP(NPObjectStub, msg) 57 IPC_BEGIN_MESSAGE_MAP(NPObjectStub, msg)
58 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Release, OnRelease); 58 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Release, OnRelease);
59 IPC_MESSAGE_HANDLER(NPObjectMsg_HasMethod, OnHasMethod); 59 IPC_MESSAGE_HANDLER(NPObjectMsg_HasMethod, OnHasMethod);
60 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Invoke, OnInvoke); 60 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Invoke, OnInvoke);
61 IPC_MESSAGE_HANDLER(NPObjectMsg_HasProperty, OnHasProperty); 61 IPC_MESSAGE_HANDLER(NPObjectMsg_HasProperty, OnHasProperty);
62 IPC_MESSAGE_HANDLER(NPObjectMsg_GetProperty, OnGetProperty); 62 IPC_MESSAGE_HANDLER(NPObjectMsg_GetProperty, OnGetProperty);
63 IPC_MESSAGE_HANDLER(NPObjectMsg_SetProperty, OnSetProperty); 63 IPC_MESSAGE_HANDLER(NPObjectMsg_SetProperty, OnSetProperty);
64 IPC_MESSAGE_HANDLER(NPObjectMsg_RemoveProperty, OnRemoveProperty); 64 IPC_MESSAGE_HANDLER(NPObjectMsg_RemoveProperty, OnRemoveProperty);
65 IPC_MESSAGE_HANDLER(NPObjectMsg_Invalidate, OnInvalidate); 65 IPC_MESSAGE_HANDLER(NPObjectMsg_Invalidate, OnInvalidate);
66 IPC_MESSAGE_HANDLER(NPObjectMsg_Enumeration, OnEnumeration); 66 IPC_MESSAGE_HANDLER(NPObjectMsg_Enumeration, OnEnumeration);
67 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Construct, OnConstruct);
67 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Evaluate, OnEvaluate); 68 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Evaluate, OnEvaluate);
68 IPC_MESSAGE_HANDLER(NPObjectMsg_SetException, OnSetException); 69 IPC_MESSAGE_HANDLER(NPObjectMsg_SetException, OnSetException);
69 IPC_MESSAGE_UNHANDLED_ERROR() 70 IPC_MESSAGE_UNHANDLED_ERROR()
70 IPC_END_MESSAGE_MAP() 71 IPC_END_MESSAGE_MAP()
71 } 72 }
72 73
73 void NPObjectStub::OnChannelError() { 74 void NPObjectStub::OnChannelError() {
74 // When the plugin process is shutting down, all the NPObjectStubs 75 // When the plugin process is shutting down, all the NPObjectStubs
75 // destructors are called. However the plugin dll might have already 76 // destructors are called. However the plugin dll might have already
76 // been released, in which case the NPN_ReleaseObject will cause a crash. 77 // been released, in which case the NPN_ReleaseObject will cause a crash.
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 261
261 for (unsigned int i = 0; i < count; ++i) { 262 for (unsigned int i = 0; i < count; ++i) {
262 NPIdentifier_Param param; 263 NPIdentifier_Param param;
263 CreateNPIdentifierParam(value_np[i], &param); 264 CreateNPIdentifierParam(value_np[i], &param);
264 value->push_back(param); 265 value->push_back(param);
265 } 266 }
266 267
267 NPN_MemFree(value_np); 268 NPN_MemFree(value_np);
268 } 269 }
269 270
271 void NPObjectStub::OnConstruct(const std::vector<NPVariant_Param>& args,
272 IPC::Message* reply_msg) {
273 scoped_refptr<PluginChannelBase> local_channel = channel_;
274 bool return_value = false;
275 NPVariant_Param result_param;
276 NPVariant result_var;
277
278 VOID_TO_NPVARIANT(result_var);
279
280 int arg_count = static_cast<int>(args.size());
281 NPVariant* args_var = new NPVariant[arg_count];
282 for (int i = 0; i < arg_count; ++i) {
283 CreateNPVariant(
284 args[i], local_channel, &(args_var[i]), modal_dialog_event_);
285 }
286
287 if (IsPluginProcess()) {
288 if (npobject_->_class->construct) {
289 return_value = npobject_->_class->construct(
290 npobject_, args_var, arg_count, &result_var);
291 } else {
292 return_value = false;
293 }
294 } else {
295 return_value = NPN_Construct(
296 0, npobject_, args_var, arg_count, &result_var);
297 }
298
299 for (int i = 0; i < arg_count; ++i)
300 NPN_ReleaseVariantValue(&(args_var[i]));
301
302 delete[] args_var;
303
304 CreateNPVariantParam(
305 result_var, local_channel, &result_param, true, modal_dialog_event_);
306 NPObjectMsg_Invoke::WriteReplyParams(reply_msg, result_param, return_value);
307 local_channel->Send(reply_msg);
308 }
309
270 void NPObjectStub::OnEvaluate(const std::string& script, 310 void NPObjectStub::OnEvaluate(const std::string& script,
271 bool popups_allowed, 311 bool popups_allowed,
272 IPC::Message* reply_msg) { 312 IPC::Message* reply_msg) {
273 if (IsPluginProcess()) { 313 if (IsPluginProcess()) {
274 NOTREACHED() << "Should only be called on NPObjects in the renderer"; 314 NOTREACHED() << "Should only be called on NPObjects in the renderer";
275 return; 315 return;
276 } 316 }
277 317
278 // Grab a reference to the underlying channel, as the NPObjectStub 318 // Grab a reference to the underlying channel, as the NPObjectStub
279 // instance can be destroyed in the context of NPN_Evaluate. This 319 // instance can be destroyed in the context of NPN_Evaluate. This
(...skipping 17 matching lines...) Expand all
297 } 337 }
298 338
299 void NPObjectStub::OnSetException(const std::string& message) { 339 void NPObjectStub::OnSetException(const std::string& message) {
300 if (IsPluginProcess()) { 340 if (IsPluginProcess()) {
301 NOTREACHED() << "Should only be called on NPObjects in the renderer"; 341 NOTREACHED() << "Should only be called on NPObjects in the renderer";
302 return; 342 return;
303 } 343 }
304 344
305 NPN_SetException(npobject_, message.c_str()); 345 NPN_SetException(npobject_, message.c_str());
306 } 346 }
OLDNEW
« no previous file with comments | « chrome/plugin/npobject_stub.h ('k') | webkit/port/bindings/v8/NPV8Object.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698