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

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

Issue 16140011: Don't send PP_Vars/V8 values with cycles across PostMessage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « ppapi/tests/test_post_message.cc ('k') | webkit/plugins/ppapi/v8_var_converter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/message_channel.cc
diff --git a/webkit/plugins/ppapi/message_channel.cc b/webkit/plugins/ppapi/message_channel.cc
index 2984a9213d8bbee5de155a39d5056973cc289265..76e0f3e7e323352e03c0700e59cf0114e42ecc91 100644
--- a/webkit/plugins/ppapi/message_channel.cc
+++ b/webkit/plugins/ppapi/message_channel.cc
@@ -45,6 +45,12 @@ namespace ppapi {
namespace {
const char kPostMessage[] = "postMessage";
+const char kV8ToVarConversionError[] = "Failed to convert a PostMessage "
+ "argument from a JavaScript value to a PP_Var. It may have cycles or be of "
+ "an unsupported type.";
+const char kVarToV8ConversionError[] = "Failed to convert a PostMessage "
+ "argument from a PP_Var to a Javascript value. It may have cycles or be of "
+ "an unsupported type.";
// Helper function to get the MessageChannel that is associated with an
// NPObject*.
@@ -85,12 +91,16 @@ bool NPVariantToPPVar(const NPVariant* variant, PP_Var* result) {
NPVARIANT_TO_STRING(*variant).UTF8Characters,
NPVARIANT_TO_STRING(*variant).UTF8Length);
return true;
- case NPVariantType_Object:
- V8VarConverter converter;
+ case NPVariantType_Object: {
// Calling WebBindings::toV8Value creates a wrapper around NPVariant so it
// shouldn't result in a deep copy.
- return converter.FromV8Value(WebBindings::toV8Value(variant),
- v8::Context::GetCurrent(), result);
+ v8::Handle<v8::Value> v8_value = WebBindings::toV8Value(variant);
+ if (!V8VarConverter::FromV8Value(v8_value, v8::Context::GetCurrent(),
+ result)) {
+ return false;
+ }
+ return true;
+ }
}
return false;
}
@@ -182,7 +192,9 @@ bool MessageChannelInvoke(NPObject* np_obj, NPIdentifier name,
if (message_channel) {
PP_Var argument = PP_MakeUndefined();
if (!NPVariantToPPVar(&args[0], &argument)) {
- NOTREACHED();
+ PpapiGlobals::Get()->LogWithSource(
+ message_channel->instance()->pp_instance(),
+ PP_LOGLEVEL_ERROR, std::string(), kV8ToVarConversionError);
return false;
}
message_channel->PostMessageToNative(argument);
@@ -346,10 +358,10 @@ void MessageChannel::PostMessageToJavaScript(PP_Var message_data) {
container->element().document().frame()->mainWorldScriptContext();
v8::Context::Scope context_scope(context);
- v8::Local<v8::Value> v8_val;
- V8VarConverter converter;
- if (!converter.ToV8Value(message_data, context, &v8_val)) {
- NOTREACHED();
+ v8::Handle<v8::Value> v8_val;
+ if (!V8VarConverter::ToV8Value(message_data, context, &v8_val)) {
+ PpapiGlobals::Get()->LogWithSource(instance_->pp_instance(),
+ PP_LOGLEVEL_ERROR, std::string(), kVarToV8ConversionError);
return;
}
« no previous file with comments | « ppapi/tests/test_post_message.cc ('k') | webkit/plugins/ppapi/v8_var_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698