#include "content/renderer/pepper/pepper_try_catch.h"
#include "content/renderer/pepper/plugin_module.h"
#include "content/renderer/pepper/plugin_object.h"
-#include "content/renderer/pepper/v8_var_converter.h"
#include "gin/arguments.h"
#include "gin/converter.h"
#include "gin/function_template.h"
v8::Context::Scope context_scope(context);
v8::Handle<v8::Value> v8_val;
- if (!V8VarConverter(instance_->pp_instance())
- .ToV8Value(message_data, context, &v8_val)) {
+ if (!var_converter_.ToV8Value(message_data, context, &v8_val)) {
PpapiGlobals::Get()->LogWithSource(instance_->pp_instance(),
PP_LOGLEVEL_ERROR,
std::string(),
js_message_queue_state_(WAITING_TO_START),
blocking_message_depth_(0),
plugin_message_queue_state_(WAITING_TO_START),
+ var_converter_(instance->pp_instance(),
+ V8VarConverter::kDisallowObjectVars),
weak_ptr_factory_(this) {
}
if (!instance_)
return v8::Local<v8::Value>();
- PepperTryCatchV8 try_catch(instance_, V8VarConverter::kDisallowObjectVars,
- isolate);
+ PepperTryCatchV8 try_catch(instance_, &var_converter_, isolate);
if (identifier == kPostMessage) {
return gin::CreateFunctionTemplate(isolate,
base::Bind(&MessageChannel::PostMessageToNative,
v8::Local<v8::Value> value) {
if (!instance_)
return false;
- PepperTryCatchV8 try_catch(instance_, V8VarConverter::kDisallowObjectVars,
- isolate);
+ PepperTryCatchV8 try_catch(instance_, &var_converter_, isolate);
if (identifier == kPostMessage ||
identifier == kPostMessageAndAwaitResponse) {
try_catch.ThrowException("Cannot set properties with the name postMessage"
void MessageChannel::PostBlockingMessageToNative(gin::Arguments* args) {
if (!instance_)
return;
- PepperTryCatchV8 try_catch(instance_, V8VarConverter::kDisallowObjectVars,
- args->isolate());
+ PepperTryCatchV8 try_catch(instance_, &var_converter_, args->isolate());
if (args->Length() != 1) {
try_catch.ThrowException(
"postMessageAndAwaitResponse requires one argument");
void MessageChannel::EnqueuePluginMessage(v8::Handle<v8::Value> v8_value) {
plugin_message_queue_.push_back(VarConversionResult());
- // Convert NPVariantType_Object in to an appropriate PP_Var like Dictionary,
- // Array, etc. Note NPVariantToVar would convert to an "Object" PP_Var,
- // which we don't support for Messaging.
+ // Convert the v8 value in to an appropriate PP_Var like Dictionary,
+ // Array, etc. (We explicitly don't want an "Object" PP_Var, which we don't
+ // support for Messaging.)
// TODO(raymes): Possibly change this to use TryCatch to do the conversion and
// throw an exception if necessary.
- V8VarConverter v8_var_converter(instance_->pp_instance());
V8VarConverter::VarResult conversion_result =
- v8_var_converter.FromV8Value(
+ var_converter_.FromV8Value(
v8_value,
v8::Isolate::GetCurrent()->GetCurrentContext(),
base::Bind(&MessageChannel::FromV8ValueComplete,