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

Unified Diff: webkit/plugins/ppapi/ppb_var_deprecated_impl.cc

Issue 10693130: Fix user gesture for scripting calls from Pepper plugins. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_var_deprecated_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_var_deprecated_impl.cc b/webkit/plugins/ppapi/ppb_var_deprecated_impl.cc
index 59c7c8210d0af7cc924a928571516bc5fad49a57..7ba1c09461e9e1e60855f3a0fc3f91102d64c5ea 100644
--- a/webkit/plugins/ppapi/ppb_var_deprecated_impl.cc
+++ b/webkit/plugins/ppapi/ppb_var_deprecated_impl.cc
@@ -11,6 +11,7 @@
#include "ppapi/c/pp_var.h"
#include "ppapi/shared_impl/ppb_var_shared.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebScopedUserGesture.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/host_globals.h"
#include "webkit/plugins/ppapi/npapi_glue.h"
@@ -269,15 +270,11 @@ void DeletePropertyDeprecated(PP_Var var,
accessor.SetException(kUnableToRemovePropertyException);
}
-PP_Var CallDeprecated(PP_Var var,
- PP_Var method_name,
- uint32_t argc,
- PP_Var* argv,
- PP_Var* exception) {
- ObjectAccessorTryCatch accessor(var, exception);
- if (accessor.has_exception())
- return PP_MakeUndefined();
-
+PP_Var InternalCallDeprecated(ObjectAccessorTryCatch* accessor,
+ PP_Var method_name,
+ uint32_t argc,
+ PP_Var* argv,
+ PP_Var* exception) {
NPIdentifier identifier;
if (method_name.type == PP_VARTYPE_UNDEFINED) {
identifier = NULL;
@@ -285,11 +282,11 @@ PP_Var CallDeprecated(PP_Var var,
// Specifically allow only string functions to be called.
identifier = PPVarToNPIdentifier(method_name);
if (!identifier) {
- accessor.SetException(kInvalidPropertyException);
+ accessor->SetException(kInvalidPropertyException);
return PP_MakeUndefined();
}
} else {
- accessor.SetException(kInvalidPropertyException);
+ accessor->SetException(kInvalidPropertyException);
return PP_MakeUndefined();
}
@@ -299,7 +296,7 @@ PP_Var CallDeprecated(PP_Var var,
for (uint32_t i = 0; i < argc; ++i) {
if (!PPVarToNPVariantNoCopy(argv[i], &args[i])) {
// This argument was invalid, throw an exception & give up.
- accessor.SetException(kInvalidValueException);
+ accessor->SetException(kInvalidValueException);
return PP_MakeUndefined();
}
}
@@ -309,24 +306,41 @@ PP_Var CallDeprecated(PP_Var var,
NPVariant result;
if (identifier) {
- ok = WebBindings::invoke(NULL, accessor.object()->np_object(),
+ ok = WebBindings::invoke(NULL, accessor->object()->np_object(),
identifier, args.get(), argc, &result);
} else {
- ok = WebBindings::invokeDefault(NULL, accessor.object()->np_object(),
+ ok = WebBindings::invokeDefault(NULL, accessor->object()->np_object(),
args.get(), argc, &result);
}
if (!ok) {
// An exception may have been raised.
- accessor.SetException(kUnableToCallMethodException);
+ accessor->SetException(kUnableToCallMethodException);
return PP_MakeUndefined();
}
- PP_Var ret = NPVariantToPPVar(accessor.GetPluginInstance(), &result);
+ PP_Var ret = NPVariantToPPVar(accessor->GetPluginInstance(), &result);
WebBindings::releaseVariantValue(&result);
return ret;
}
+PP_Var CallDeprecated(PP_Var var,
+ PP_Var method_name,
+ uint32_t argc,
+ PP_Var* argv,
+ PP_Var* exception) {
+ ObjectAccessorTryCatch accessor(var, exception);
+ if (accessor.has_exception())
+ return PP_MakeUndefined();
+ PluginInstance* plugin = accessor.GetPluginInstance();
+ if (plugin && plugin->IsProcessingUserGesture()) {
+ WebKit::WebScopedUserGesture user_gesture;
+ return InternalCallDeprecated(&accessor, method_name, argc, argv,
+ exception);
+ }
+ return InternalCallDeprecated(&accessor, method_name, argc, argv, exception);
+}
+
PP_Var Construct(PP_Var var,
uint32_t argc,
PP_Var* argv,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698