| 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 "content/plugin/npobject_stub.h" | 5 #include "content/plugin/npobject_stub.h" |
| 6 | 6 |
| 7 #include "content/common/content_client.h" | 7 #include "content/common/content_client.h" |
| 8 #include "content/common/plugin_messages.h" | 8 #include "content/common/plugin_messages.h" |
| 9 #include "content/plugin/npobject_util.h" | 9 #include "content/plugin/npobject_util.h" |
| 10 #include "content/plugin/plugin_channel_base.h" | 10 #include "content/plugin/plugin_channel_base.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // We retain the object just as PluginHost does if everything was in-process. | 33 // We retain the object just as PluginHost does if everything was in-process. |
| 34 WebBindings::retainObject(npobject_); | 34 WebBindings::retainObject(npobject_); |
| 35 } | 35 } |
| 36 | 36 |
| 37 NPObjectStub::~NPObjectStub() { | 37 NPObjectStub::~NPObjectStub() { |
| 38 channel_->RemoveRoute(route_id_); | 38 channel_->RemoveRoute(route_id_); |
| 39 CHECK(!npobject_); | 39 CHECK(!npobject_); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void NPObjectStub::DeleteSoon(bool release_npobject) { | 42 void NPObjectStub::DeleteSoon() { |
| 43 if (npobject_) { | 43 if (npobject_) { |
| 44 channel_->RemoveMappingForNPObjectStub(route_id_, npobject_); | 44 channel_->RemoveMappingForNPObjectStub(route_id_, npobject_); |
| 45 | 45 |
| 46 // We need to NULL npobject_ prior to calling releaseObject() to avoid | 46 // We need to NULL npobject_ prior to calling releaseObject() to avoid |
| 47 // problems with re-entrancy. See http://crbug.com/94179#c17 for more | 47 // problems with re-entrancy. See http://crbug.com/94179#c17 for more |
| 48 // details on how this can happen. | 48 // details on how this can happen. |
| 49 NPObject* npobject = npobject_; | 49 NPObject* npobject = npobject_; |
| 50 npobject_ = NULL; | 50 npobject_ = NULL; |
| 51 | 51 |
| 52 if (release_npobject) | 52 WebBindings::releaseObject(npobject); |
| 53 WebBindings::releaseObject(npobject); | |
| 54 | 53 |
| 55 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 54 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 56 } | 55 } |
| 57 } | 56 } |
| 58 | 57 |
| 59 bool NPObjectStub::Send(IPC::Message* msg) { | 58 bool NPObjectStub::Send(IPC::Message* msg) { |
| 60 return channel_->Send(msg); | 59 return channel_->Send(msg); |
| 61 } | 60 } |
| 62 | 61 |
| 63 NPObject* NPObjectStub::GetUnderlyingNPObject() { | 62 NPObject* NPObjectStub::GetUnderlyingNPObject() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 IPC_MESSAGE_HANDLER(NPObjectMsg_Enumeration, OnEnumeration); | 94 IPC_MESSAGE_HANDLER(NPObjectMsg_Enumeration, OnEnumeration); |
| 96 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Construct, OnConstruct); | 95 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Construct, OnConstruct); |
| 97 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Evaluate, OnEvaluate); | 96 IPC_MESSAGE_HANDLER_DELAY_REPLY(NPObjectMsg_Evaluate, OnEvaluate); |
| 98 IPC_MESSAGE_UNHANDLED(handled = false) | 97 IPC_MESSAGE_UNHANDLED(handled = false) |
| 99 IPC_END_MESSAGE_MAP() | 98 IPC_END_MESSAGE_MAP() |
| 100 DCHECK(handled); | 99 DCHECK(handled); |
| 101 return handled; | 100 return handled; |
| 102 } | 101 } |
| 103 | 102 |
| 104 void NPObjectStub::OnChannelError() { | 103 void NPObjectStub::OnChannelError() { |
| 105 DeleteSoon(true); | 104 DeleteSoon(); |
| 106 } | 105 } |
| 107 | 106 |
| 108 void NPObjectStub::OnRelease(IPC::Message* reply_msg) { | 107 void NPObjectStub::OnRelease(IPC::Message* reply_msg) { |
| 109 Send(reply_msg); | 108 Send(reply_msg); |
| 110 DeleteSoon(true); | 109 DeleteSoon(); |
| 111 } | 110 } |
| 112 | 111 |
| 113 void NPObjectStub::OnHasMethod(const NPIdentifier_Param& name, | 112 void NPObjectStub::OnHasMethod(const NPIdentifier_Param& name, |
| 114 bool* result) { | 113 bool* result) { |
| 115 NPIdentifier id = CreateNPIdentifier(name); | 114 NPIdentifier id = CreateNPIdentifier(name); |
| 116 // If we're in the plugin process, then the stub is holding onto an NPObject | 115 // If we're in the plugin process, then the stub is holding onto an NPObject |
| 117 // from the plugin, so all function calls on it need to go through the | 116 // from the plugin, so all function calls on it need to go through the |
| 118 // functions in NPClass. If we're in the renderer process, then we just call | 117 // functions in NPClass. If we're in the renderer process, then we just call |
| 119 // the NPN_ functions. | 118 // the NPN_ functions. |
| 120 if (IsPluginProcess()) { | 119 if (IsPluginProcess()) { |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 384 |
| 386 bool return_value = WebBindings::evaluateHelper(0, popups_allowed, npobject_, | 385 bool return_value = WebBindings::evaluateHelper(0, popups_allowed, npobject_, |
| 387 &script_string, &result_var); | 386 &script_string, &result_var); |
| 388 | 387 |
| 389 NPVariant_Param result_param; | 388 NPVariant_Param result_param; |
| 390 CreateNPVariantParam( | 389 CreateNPVariantParam( |
| 391 result_var, channel_, &result_param, true, containing_window_, page_url_); | 390 result_var, channel_, &result_param, true, containing_window_, page_url_); |
| 392 NPObjectMsg_Evaluate::WriteReplyParams(reply_msg, result_param, return_value); | 391 NPObjectMsg_Evaluate::WriteReplyParams(reply_msg, result_param, return_value); |
| 393 channel_->Send(reply_msg); | 392 channel_->Send(reply_msg); |
| 394 } | 393 } |
| OLD | NEW |