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/common/npobject_proxy.h" | 5 #include "content/common/npobject_proxy.h" |
6 | 6 |
| 7 #include "content/common/np_channel_base.h" |
7 #include "content/common/npobject_util.h" | 8 #include "content/common/npobject_util.h" |
8 #include "content/common/plugin_messages.h" | 9 #include "content/common/plugin_messages.h" |
9 #include "content/plugin/plugin_channel.h" | |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
11 #include "webkit/glue/webkit_glue.h" | 11 #include "webkit/glue/webkit_glue.h" |
12 #include "webkit/plugins/npapi/plugin_instance.h" | 12 #include "webkit/plugins/npapi/plugin_instance.h" |
13 | 13 |
14 using WebKit::WebBindings; | 14 using WebKit::WebBindings; |
15 | 15 |
16 struct NPObjectWrapper { | 16 struct NPObjectWrapper { |
17 NPObject object; | 17 NPObject object; |
18 NPObjectProxy* proxy; | 18 NPObjectProxy* proxy; |
19 }; | 19 }; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 NPVariant_Param param_result; | 200 NPVariant_Param param_result; |
201 NPObjectMsg_Invoke* msg = new NPObjectMsg_Invoke( | 201 NPObjectMsg_Invoke* msg = new NPObjectMsg_Invoke( |
202 proxy->route_id_, is_default, name_param, args_param, ¶m_result, | 202 proxy->route_id_, is_default, name_param, args_param, ¶m_result, |
203 &result); | 203 &result); |
204 | 204 |
205 // If we're in the plugin process and this invoke leads to a dialog box, the | 205 // If we're in the plugin process and this invoke leads to a dialog box, the |
206 // plugin will hang the window hierarchy unless we pump the window message | 206 // plugin will hang the window hierarchy unless we pump the window message |
207 // queue while waiting for a reply. We need to do this to simulate what | 207 // queue while waiting for a reply. We need to do this to simulate what |
208 // happens when everything runs in-process (while calling MessageBox window | 208 // happens when everything runs in-process (while calling MessageBox window |
209 // messages are pumped). | 209 // messages are pumped). |
210 if (IsPluginProcess()) { | 210 if (IsPluginProcess() && proxy->channel()) { |
211 PluginChannel* channel = static_cast<PluginChannel*>(proxy->channel_.get()); | 211 msg->set_pump_messages_event( |
212 if (channel) { | 212 proxy->channel()->GetModalDialogEvent(containing_window)); |
213 msg->set_pump_messages_event( | |
214 channel->GetModalDialogEvent(containing_window)); | |
215 } | |
216 } | 213 } |
217 | 214 |
218 GURL page_url = proxy->page_url_; | 215 GURL page_url = proxy->page_url_; |
219 proxy->Send(msg); | 216 proxy->Send(msg); |
220 | 217 |
221 // Send may delete proxy. | 218 // Send may delete proxy. |
222 proxy = NULL; | 219 proxy = NULL; |
223 | 220 |
224 if (!result) | 221 if (!result) |
225 return false; | 222 return false; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 args[i], channel_copy, ¶m, false, containing_window, | 420 args[i], channel_copy, ¶m, false, containing_window, |
424 proxy->page_url_); | 421 proxy->page_url_); |
425 args_param.push_back(param); | 422 args_param.push_back(param); |
426 } | 423 } |
427 | 424 |
428 NPVariant_Param param_result; | 425 NPVariant_Param param_result; |
429 NPObjectMsg_Construct* msg = new NPObjectMsg_Construct( | 426 NPObjectMsg_Construct* msg = new NPObjectMsg_Construct( |
430 proxy->route_id_, args_param, ¶m_result, &result); | 427 proxy->route_id_, args_param, ¶m_result, &result); |
431 | 428 |
432 // See comment in NPObjectProxy::NPInvokePrivate. | 429 // See comment in NPObjectProxy::NPInvokePrivate. |
433 if (IsPluginProcess()) { | 430 if (IsPluginProcess() && proxy->channel()) { |
434 PluginChannel* channel = static_cast<PluginChannel*>(proxy->channel_.get()); | 431 msg->set_pump_messages_event( |
435 if (channel) { | 432 proxy->channel()->GetModalDialogEvent(proxy->containing_window_)); |
436 msg->set_pump_messages_event( | |
437 channel->GetModalDialogEvent(proxy->containing_window_)); | |
438 } | |
439 } | 433 } |
440 | 434 |
441 GURL page_url = proxy->page_url_; | 435 GURL page_url = proxy->page_url_; |
442 proxy->Send(msg); | 436 proxy->Send(msg); |
443 | 437 |
444 // Send may delete proxy. | 438 // Send may delete proxy. |
445 proxy = NULL; | 439 proxy = NULL; |
446 | 440 |
447 if (!result) | 441 if (!result) |
448 return false; | 442 return false; |
(...skipping 27 matching lines...) Expand all Loading... |
476 std::string script_str = std::string( | 470 std::string script_str = std::string( |
477 script->UTF8Characters, script->UTF8Length); | 471 script->UTF8Characters, script->UTF8Length); |
478 | 472 |
479 NPObjectMsg_Evaluate* msg = new NPObjectMsg_Evaluate(proxy->route_id(), | 473 NPObjectMsg_Evaluate* msg = new NPObjectMsg_Evaluate(proxy->route_id(), |
480 script_str, | 474 script_str, |
481 popups_allowed, | 475 popups_allowed, |
482 &result_param, | 476 &result_param, |
483 &result); | 477 &result); |
484 | 478 |
485 // See comment in NPObjectProxy::NPInvokePrivate. | 479 // See comment in NPObjectProxy::NPInvokePrivate. |
486 if (IsPluginProcess()) { | 480 if (IsPluginProcess() && proxy->channel()) { |
487 PluginChannel* channel = static_cast<PluginChannel*>(proxy->channel_.get()); | 481 msg->set_pump_messages_event( |
488 if (channel) { | 482 proxy->channel()->GetModalDialogEvent(containing_window)); |
489 msg->set_pump_messages_event( | |
490 channel->GetModalDialogEvent(proxy->containing_window_)); | |
491 } | |
492 } | 483 } |
493 scoped_refptr<NPChannelBase> channel(proxy->channel_); | 484 scoped_refptr<NPChannelBase> channel(proxy->channel_); |
494 | 485 |
495 GURL page_url = proxy->page_url_; | 486 GURL page_url = proxy->page_url_; |
496 proxy->Send(msg); | 487 proxy->Send(msg); |
497 // Send may delete proxy. | 488 // Send may delete proxy. |
498 proxy = NULL; | 489 proxy = NULL; |
499 if (!result) | 490 if (!result) |
500 return false; | 491 return false; |
501 | 492 |
502 CreateNPVariant( | 493 CreateNPVariant( |
503 result_param, channel.get(), result_var, containing_window, page_url); | 494 result_param, channel.get(), result_var, containing_window, page_url); |
504 return true; | 495 return true; |
505 } | 496 } |
OLD | NEW |