summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/plugin_messages_internal.h3
-rw-r--r--chrome/plugin/npobject_proxy.cc10
-rw-r--r--chrome/plugin/npobject_stub.cc4
-rw-r--r--chrome/plugin/npobject_stub.h3
-rw-r--r--third_party/npapi/bindings/npruntime.h17
-rw-r--r--webkit/port/bindings/v8/np_v8object.cpp25
6 files changed, 58 insertions, 4 deletions
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<NPIdentifier_Param> /* 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<NPAPI::PluginInstance*>(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<NPIdentifier_Param>* 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<unsigned int>(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<NPIdentifier_Param>* 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:
diff --git a/third_party/npapi/bindings/npruntime.h b/third_party/npapi/bindings/npruntime.h
index f1160b7..74840ba 100644
--- a/third_party/npapi/bindings/npruntime.h
+++ b/third_party/npapi/bindings/npruntime.h
@@ -352,6 +352,23 @@ bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, uint32_t *count);
+// Helper function for evaluating a script in the scope of the NPObject passed in.
+// Parameters
+// npp
+// The plugin's opaque instance handle (Can be NULL)
+// popups_allowed
+// Indicates if popups created in the context of the script being executed are
+// blocked or not.
+// npobj
+// The NPObject.
+// npscript
+// The script being executed.
+// result
+// On return contains the value returned by the script.
+// Returns true on success.
+bool NPN_EvaluateHelper(NPP npp, bool popups_allowed, NPObject* npobj,
+ NPString* npscript, NPVariant *result);
+
// BEGIN GOOGLE MODIFICATIONS
void* NPP_GetJavaClass(void);
diff --git a/webkit/port/bindings/v8/np_v8object.cpp b/webkit/port/bindings/v8/np_v8object.cpp
index 4387180..7e6b8b3 100644
--- a/webkit/port/bindings/v8/np_v8object.cpp
+++ b/webkit/port/bindings/v8/np_v8object.cpp
@@ -42,6 +42,10 @@
#include "v8_proxy.h"
#include "DOMWindow.h"
+#ifdef OS_WIN
+#include "webkit/glue/plugins/plugin_instance.h"
+#endif // OS_WIN
+
using WebCore::V8ClassIndex;
using WebCore::V8Proxy;
@@ -242,6 +246,22 @@ bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args,
bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *npscript,
NPVariant *result) {
+ bool popups_allowed = false;
+
+#ifdef OS_WIN
+ if (npp) {
+ NPAPI::PluginInstance* plugin_instance =
+ reinterpret_cast<NPAPI::PluginInstance*>(npp->ndata);
+ if (plugin_instance)
+ popups_allowed = plugin_instance->popups_allowed();
+ }
+#endif // OS_WIN
+
+ return NPN_EvaluateHelper(npp, popups_allowed, npobj, npscript, result);
+}
+
+bool NPN_EvaluateHelper(NPP npp, bool popups_allowed, NPObject* npobj,
+ NPString* npscript, NPVariant *result) {
VOID_TO_NPVARIANT(*result);
if (npobj == NULL)
return false;
@@ -257,7 +277,10 @@ bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *npscript,
v8::Context::Scope scope(context);
- WebCore::String filename("npscript");
+ WebCore::String filename;
+ if (!popups_allowed)
+ filename = "npscript";
+
// Convert UTF-8 stream to WebCore::String.
WebCore::String script = WebCore::String::fromUTF8(
npscript->UTF8Characters, npscript->UTF8Length);