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

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

Issue 20515: Fix plugin hang that Earth team found.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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') | chrome/plugin/npobject_util.h » ('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"
11 #include "third_party/npapi/bindings/npapi.h" 11 #include "third_party/npapi/bindings/npapi.h"
12 #include "third_party/npapi/bindings/npruntime.h" 12 #include "third_party/npapi/bindings/npruntime.h"
13 13
14 NPObjectStub::NPObjectStub( 14 NPObjectStub::NPObjectStub(
15 NPObject* npobject, PluginChannelBase* channel, int route_id) 15 NPObject* npobject,
16 PluginChannelBase* channel,
17 int route_id,
18 base::WaitableEvent* modal_dialog_event)
16 : channel_(channel), 19 : channel_(channel),
17 npobject_(npobject), 20 npobject_(npobject),
18 route_id_(route_id), 21 route_id_(route_id),
19 valid_(true), 22 valid_(true),
20 web_plugin_delegate_proxy_(NULL) { 23 web_plugin_delegate_proxy_(NULL),
24 modal_dialog_event_(modal_dialog_event) {
21 channel_->AddRoute(route_id, this, true); 25 channel_->AddRoute(route_id, this, true);
22 26
23 // We retain the object just as PluginHost does if everything was in-process. 27 // We retain the object just as PluginHost does if everything was in-process.
24 NPN_RetainObject(npobject_); 28 NPN_RetainObject(npobject_);
25 } 29 }
26 30
27 NPObjectStub::~NPObjectStub() { 31 NPObjectStub::~NPObjectStub() {
28 if (web_plugin_delegate_proxy_) 32 if (web_plugin_delegate_proxy_)
29 web_plugin_delegate_proxy_->DropWindowScriptObject(); 33 web_plugin_delegate_proxy_->DropWindowScriptObject();
30 34
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 IPC::Message* reply_msg) { 107 IPC::Message* reply_msg) {
104 scoped_refptr<PluginChannelBase> local_channel = channel_; 108 scoped_refptr<PluginChannelBase> local_channel = channel_;
105 bool return_value = false; 109 bool return_value = false;
106 NPVariant_Param result_param; 110 NPVariant_Param result_param;
107 NPVariant result_var; 111 NPVariant result_var;
108 112
109 VOID_TO_NPVARIANT(result_var); 113 VOID_TO_NPVARIANT(result_var);
110 114
111 int arg_count = static_cast<int>(args.size()); 115 int arg_count = static_cast<int>(args.size());
112 NPVariant* args_var = new NPVariant[arg_count]; 116 NPVariant* args_var = new NPVariant[arg_count];
113 for (int i = 0; i < arg_count; ++i) 117 for (int i = 0; i < arg_count; ++i) {
114 CreateNPVariant(args[i], local_channel, &(args_var[i]), NULL); 118 CreateNPVariant(
119 args[i], local_channel, &(args_var[i]), modal_dialog_event_);
120 }
115 121
116 if (is_default) { 122 if (is_default) {
117 if (IsPluginProcess()) { 123 if (IsPluginProcess()) {
118 if (npobject_->_class->invokeDefault) { 124 if (npobject_->_class->invokeDefault) {
119 return_value = npobject_->_class->invokeDefault( 125 return_value = npobject_->_class->invokeDefault(
120 npobject_, args_var, arg_count, &result_var); 126 npobject_, args_var, arg_count, &result_var);
121 } else { 127 } else {
122 return_value = false; 128 return_value = false;
123 } 129 }
124 } else { 130 } else {
(...skipping 13 matching lines...) Expand all
138 return_value = NPN_Invoke( 144 return_value = NPN_Invoke(
139 0, npobject_, id, args_var, arg_count, &result_var); 145 0, npobject_, id, args_var, arg_count, &result_var);
140 } 146 }
141 } 147 }
142 148
143 for (int i = 0; i < arg_count; ++i) 149 for (int i = 0; i < arg_count; ++i)
144 NPN_ReleaseVariantValue(&(args_var[i])); 150 NPN_ReleaseVariantValue(&(args_var[i]));
145 151
146 delete[] args_var; 152 delete[] args_var;
147 153
148 CreateNPVariantParam(result_var, local_channel, &result_param, true); 154 CreateNPVariantParam(
155 result_var, local_channel, &result_param, true, modal_dialog_event_);
149 NPObjectMsg_Invoke::WriteReplyParams(reply_msg, result_param, return_value); 156 NPObjectMsg_Invoke::WriteReplyParams(reply_msg, result_param, return_value);
150 local_channel->Send(reply_msg); 157 local_channel->Send(reply_msg);
151 } 158 }
152 159
153 void NPObjectStub::OnHasProperty(const NPIdentifier_Param& name, 160 void NPObjectStub::OnHasProperty(const NPIdentifier_Param& name,
154 bool* result) { 161 bool* result) {
155 NPIdentifier id = CreateNPIdentifier(name); 162 NPIdentifier id = CreateNPIdentifier(name);
156 if (IsPluginProcess()) { 163 if (IsPluginProcess()) {
157 if (npobject_->_class->hasProperty) { 164 if (npobject_->_class->hasProperty) {
158 *result = npobject_->_class->hasProperty(npobject_, id); 165 *result = npobject_->_class->hasProperty(npobject_, id);
(...skipping 15 matching lines...) Expand all
174 if (IsPluginProcess()) { 181 if (IsPluginProcess()) {
175 if (npobject_->_class->getProperty) { 182 if (npobject_->_class->getProperty) {
176 *result = npobject_->_class->getProperty(npobject_, id, &result_var); 183 *result = npobject_->_class->getProperty(npobject_, id, &result_var);
177 } else { 184 } else {
178 *result = false; 185 *result = false;
179 } 186 }
180 } else { 187 } else {
181 *result = NPN_GetProperty(0, npobject_, id, &result_var); 188 *result = NPN_GetProperty(0, npobject_, id, &result_var);
182 } 189 }
183 190
184 CreateNPVariantParam(result_var, channel_, property, true); 191 CreateNPVariantParam(
192 result_var, channel_, property, true, modal_dialog_event_);
185 } 193 }
186 194
187 void NPObjectStub::OnSetProperty(const NPIdentifier_Param& name, 195 void NPObjectStub::OnSetProperty(const NPIdentifier_Param& name,
188 const NPVariant_Param& property, 196 const NPVariant_Param& property,
189 bool* result) { 197 bool* result) {
190 NPVariant result_var; 198 NPVariant result_var;
191 VOID_TO_NPVARIANT(result_var); 199 VOID_TO_NPVARIANT(result_var);
192 NPIdentifier id = CreateNPIdentifier(name); 200 NPIdentifier id = CreateNPIdentifier(name);
193 NPVariant property_var; 201 NPVariant property_var;
194 CreateNPVariant(property, channel_, &property_var, NULL); 202 CreateNPVariant(property, channel_, &property_var, modal_dialog_event_);
195 203
196 if (IsPluginProcess()) { 204 if (IsPluginProcess()) {
197 if (npobject_->_class->setProperty) { 205 if (npobject_->_class->setProperty) {
198 *result = npobject_->_class->setProperty(npobject_, id, &property_var); 206 *result = npobject_->_class->setProperty(npobject_, id, &property_var);
199 } else { 207 } else {
200 *result = false; 208 *result = false;
201 } 209 }
202 } else { 210 } else {
203 *result = NPN_SetProperty(0, npobject_, id, &property_var); 211 *result = NPN_SetProperty(0, npobject_, id, &property_var);
204 } 212 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 283
276 NPVariant result_var; 284 NPVariant result_var;
277 NPString script_string; 285 NPString script_string;
278 script_string.UTF8Characters = script.c_str(); 286 script_string.UTF8Characters = script.c_str();
279 script_string.UTF8Length = static_cast<unsigned int>(script.length()); 287 script_string.UTF8Length = static_cast<unsigned int>(script.length());
280 288
281 bool return_value = NPN_EvaluateHelper(0, popups_allowed, npobject_, 289 bool return_value = NPN_EvaluateHelper(0, popups_allowed, npobject_,
282 &script_string, &result_var); 290 &script_string, &result_var);
283 291
284 NPVariant_Param result_param; 292 NPVariant_Param result_param;
285 CreateNPVariantParam(result_var, local_channel, &result_param, true); 293 CreateNPVariantParam(
294 result_var, local_channel, &result_param, true, modal_dialog_event_);
286 NPObjectMsg_Evaluate::WriteReplyParams(reply_msg, result_param, return_value); 295 NPObjectMsg_Evaluate::WriteReplyParams(reply_msg, result_param, return_value);
287 local_channel->Send(reply_msg); 296 local_channel->Send(reply_msg);
288 } 297 }
289 298
290 void NPObjectStub::OnSetException(const std::string& message) { 299 void NPObjectStub::OnSetException(const std::string& message) {
291 if (IsPluginProcess()) { 300 if (IsPluginProcess()) {
292 NOTREACHED() << "Should only be called on NPObjects in the renderer"; 301 NOTREACHED() << "Should only be called on NPObjects in the renderer";
293 return; 302 return;
294 } 303 }
295 304
296 NPN_SetException(npobject_, message.c_str()); 305 NPN_SetException(npobject_, message.c_str());
297 } 306 }
298 307
OLDNEW
« no previous file with comments | « chrome/plugin/npobject_stub.h ('k') | chrome/plugin/npobject_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698