From 35bb14330bde78b7c29609eed27c24caf7c9cd96 Mon Sep 17 00:00:00 2001 From: "ananta@chromium.org" Date: Thu, 9 Oct 2008 19:58:15 +0000 Subject: Attempt 2 at landing this patch. It broke the Mac/linux builds. Fix for now is to add the offending code in np_v8object.cpp in a ifdef OS_WIN This fixes http://code.google.com/p/chromium/issues/detail?id=2472, which is an issue with popups displayed by the flash plugin in response to a user click, getting blocked. The plugin invokes NPN_Evaluate to execute the javascript. It also invokes the NPN_PushPopupEnabledState/NPN_PopupEnabledState API's to set the popup enabled stack for the duration of the call. The fix is to add the plumbing in NPN_Evaluate to pass in a flag indicating whether popups are allowed for the duration of the call. Bug=2472 R=jam Review URL: http://codereview.chromium.org/6379 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3119 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/plugin_messages_internal.h | 3 ++- chrome/plugin/npobject_proxy.cc | 10 ++++++++++ chrome/plugin/npobject_stub.cc | 4 +++- chrome/plugin/npobject_stub.h | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) (limited to 'chrome') diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index 146cd9c..1059418 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -301,8 +301,9 @@ IPC_BEGIN_MESSAGES(NPObject, 7) std::vector /* value */, bool /* result */) - IPC_SYNC_MESSAGE_ROUTED1_2(NPObjectMsg_Evaluate, + IPC_SYNC_MESSAGE_ROUTED2_2(NPObjectMsg_Evaluate, std::string /* script */, + bool /* popups_allowed */, NPVariant_Param /* result_param */, bool /* result */) diff --git a/chrome/plugin/npobject_proxy.cc b/chrome/plugin/npobject_proxy.cc index 1b464e0..9acde3d 100644 --- a/chrome/plugin/npobject_proxy.cc +++ b/chrome/plugin/npobject_proxy.cc @@ -324,12 +324,22 @@ bool NPObjectProxy::NPNEvaluate(NPP npp, return false; } + bool popups_allowed = false; + + if (npp) { + NPAPI::PluginInstance* plugin_instance = + reinterpret_cast(npp->ndata); + if (plugin_instance) + popups_allowed = plugin_instance->popups_allowed(); + } + NPVariant_Param result_param; std::string script_str = std::string( script->UTF8Characters, script->UTF8Length); NPObjectMsg_Evaluate* msg = new NPObjectMsg_Evaluate(proxy->route_id(), script_str, + popups_allowed, &result_param, &result); diff --git a/chrome/plugin/npobject_stub.cc b/chrome/plugin/npobject_stub.cc index 80f6356..ec276b0 100644 --- a/chrome/plugin/npobject_stub.cc +++ b/chrome/plugin/npobject_stub.cc @@ -260,6 +260,7 @@ void NPObjectStub::OnEnumeration(std::vector* value, } void NPObjectStub::OnEvaluate(const std::string& script, + bool popups_allowed, IPC::Message* reply_msg) { if (IsPluginProcess()) { NOTREACHED() << "Should only be called on NPObjects in the renderer"; @@ -277,7 +278,8 @@ void NPObjectStub::OnEvaluate(const std::string& script, script_string.UTF8Characters = script.c_str(); script_string.UTF8Length = static_cast(script.length()); - bool return_value = NPN_Evaluate(0, npobject_, &script_string, &result_var); + bool return_value = NPN_EvaluateHelper(0, popups_allowed, npobject_, + &script_string, &result_var); NPVariant_Param result_param; CreateNPVariantParam(result_var, local_channel, &result_param, true); diff --git a/chrome/plugin/npobject_stub.h b/chrome/plugin/npobject_stub.h index e5f1743..a309750 100644 --- a/chrome/plugin/npobject_stub.h +++ b/chrome/plugin/npobject_stub.h @@ -63,7 +63,8 @@ class NPObjectStub : public IPC::Channel::Listener, void OnInvalidate(); void OnEnumeration(std::vector* value, bool* result); - void OnEvaluate(const std::string& script, IPC::Message* reply_msg); + void OnEvaluate(const std::string& script, bool popups_allowed, + IPC::Message* reply_msg); void OnSetException(const std::string& message); private: -- cgit v1.1