Use our fork of V8ValueConverter for all cases.
This commit is contained in:
parent
980e8ca4dc
commit
031426d54e
8 changed files with 38 additions and 56 deletions
4
atom.gyp
4
atom.gyp
|
@ -168,8 +168,8 @@
|
||||||
'common/v8/node_common.h',
|
'common/v8/node_common.h',
|
||||||
'common/v8/scoped_persistent.h',
|
'common/v8/scoped_persistent.h',
|
||||||
'common/v8/native_type_conversions.h',
|
'common/v8/native_type_conversions.h',
|
||||||
'common/v8_value_converter_impl.cc',
|
'common/v8/v8_value_converter.cc',
|
||||||
'common/v8_value_converter_impl.h',
|
'common/v8/v8_value_converter.h',
|
||||||
'renderer/api/atom_api_renderer_ipc.cc',
|
'renderer/api/atom_api_renderer_ipc.cc',
|
||||||
'renderer/api/atom_api_renderer_ipc.h',
|
'renderer/api/atom_api_renderer_ipc.h',
|
||||||
'renderer/api/atom_renderer_bindings.cc',
|
'renderer/api/atom_renderer_bindings.cc',
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "content/public/browser/render_view_host.h"
|
#include "content/public/browser/render_view_host.h"
|
||||||
|
|
||||||
using content::RenderViewHost;
|
using content::RenderViewHost;
|
||||||
using content::V8ValueConverter;
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ bool EventEmitter::Emit(const std::string& name, base::ListValue* args) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::HandleScope handle_scope(node_isolate);
|
||||||
|
|
||||||
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
|
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
|
||||||
scoped_ptr<content::V8ValueConverter> converter(new V8ValueConverterImpl);
|
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
|
||||||
|
|
||||||
v8::Handle<v8::Object> v8_event = Event::CreateV8Object();
|
v8::Handle<v8::Object> v8_event = Event::CreateV8Object();
|
||||||
Event* event = Event::Unwrap<Event>(v8_event);
|
Event* event = Event::Unwrap<Event>(v8_event);
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
|
|
||||||
#include "common/v8/node_common.h"
|
#include "common/v8/node_common.h"
|
||||||
|
|
||||||
using content::V8ValueConverter;
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
AtomBrowserBindings::AtomBrowserBindings() {
|
AtomBrowserBindings::AtomBrowserBindings() {
|
||||||
|
@ -29,7 +27,7 @@ void AtomBrowserBindings::OnRendererMessage(int process_id,
|
||||||
const base::ListValue& args) {
|
const base::ListValue& args) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::HandleScope handle_scope(node_isolate);
|
||||||
|
|
||||||
scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
|
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
|
||||||
|
|
||||||
// process.emit(channel, 'message', process_id, routing_id);
|
// process.emit(channel, 'message', process_id, routing_id);
|
||||||
std::vector<v8::Handle<v8::Value>> arguments;
|
std::vector<v8::Handle<v8::Value>> arguments;
|
||||||
|
@ -62,7 +60,7 @@ void AtomBrowserBindings::OnRendererMessageSync(
|
||||||
IPC::Message* message) {
|
IPC::Message* message) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
v8::HandleScope handle_scope(node_isolate);
|
||||||
|
|
||||||
scoped_ptr<V8ValueConverter> converter(new V8ValueConverterImpl());
|
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
|
||||||
|
|
||||||
// Create the event object.
|
// Create the event object.
|
||||||
v8::Handle<v8::Object> event = api::Event::CreateV8Object();
|
v8::Handle<v8::Object> event = api::Event::CreateV8Object();
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "browser/api/atom_api_window.h"
|
#include "browser/api/atom_api_window.h"
|
||||||
#include "common/swap_or_assign.h"
|
#include "common/swap_or_assign.h"
|
||||||
#include "common/v8/scoped_persistent.h"
|
#include "common/v8/scoped_persistent.h"
|
||||||
#include "common/v8_value_converter_impl.h"
|
#include "common/v8/v8_value_converter.h"
|
||||||
#include "content/public/renderer/v8_value_converter.h"
|
#include "content/public/renderer/v8_value_converter.h"
|
||||||
#include "ui/gfx/rect.h"
|
#include "ui/gfx/rect.h"
|
||||||
#include "url/gurl.h"
|
#include "url/gurl.h"
|
||||||
|
@ -66,8 +66,7 @@ struct FromV8Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
operator scoped_ptr<base::Value>() {
|
operator scoped_ptr<base::Value>() {
|
||||||
scoped_ptr<content::V8ValueConverter> converter(
|
scoped_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
|
||||||
new atom::V8ValueConverterImpl);
|
|
||||||
return scoped_ptr<base::Value>(
|
return scoped_ptr<base::Value>(
|
||||||
converter->FromV8Value(value_, v8::Context::GetCurrent()));
|
converter->FromV8Value(value_, v8::Context::GetCurrent()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,52 +2,47 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "common/v8_value_converter_impl.h"
|
#include "common/v8/v8_value_converter.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
#include "v8/include/v8.h"
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
V8ValueConverterImpl::V8ValueConverterImpl()
|
V8ValueConverter::V8ValueConverter()
|
||||||
: date_allowed_(false),
|
: date_allowed_(false),
|
||||||
reg_exp_allowed_(false),
|
reg_exp_allowed_(false),
|
||||||
function_allowed_(false),
|
function_allowed_(false),
|
||||||
strip_null_from_objects_(false),
|
strip_null_from_objects_(false),
|
||||||
avoid_identity_hash_for_testing_(false) {}
|
avoid_identity_hash_for_testing_(false) {}
|
||||||
|
|
||||||
void V8ValueConverterImpl::SetDateAllowed(bool val) {
|
void V8ValueConverter::SetDateAllowed(bool val) {
|
||||||
date_allowed_ = val;
|
date_allowed_ = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ValueConverterImpl::SetRegExpAllowed(bool val) {
|
void V8ValueConverter::SetRegExpAllowed(bool val) {
|
||||||
reg_exp_allowed_ = val;
|
reg_exp_allowed_ = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ValueConverterImpl::SetFunctionAllowed(bool val) {
|
void V8ValueConverter::SetFunctionAllowed(bool val) {
|
||||||
function_allowed_ = val;
|
function_allowed_ = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ValueConverterImpl::SetStripNullFromObjects(bool val) {
|
void V8ValueConverter::SetStripNullFromObjects(bool val) {
|
||||||
strip_null_from_objects_ = val;
|
strip_null_from_objects_ = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8ValueConverterImpl::SetStrategy(Strategy* strategy) {
|
v8::Handle<v8::Value> V8ValueConverter::ToV8Value(
|
||||||
// Ignore any strategy.
|
|
||||||
}
|
|
||||||
|
|
||||||
v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Value(
|
|
||||||
const base::Value* value, v8::Handle<v8::Context> context) const {
|
const base::Value* value, v8::Handle<v8::Context> context) const {
|
||||||
v8::Context::Scope context_scope(context);
|
v8::Context::Scope context_scope(context);
|
||||||
v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
||||||
return handle_scope.Close(ToV8ValueImpl(value));
|
return handle_scope.Close(ToV8ValueImpl(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
Value* V8ValueConverterImpl::FromV8Value(
|
Value* V8ValueConverter::FromV8Value(
|
||||||
v8::Handle<v8::Value> val,
|
v8::Handle<v8::Value> val,
|
||||||
v8::Handle<v8::Context> context) const {
|
v8::Handle<v8::Context> context) const {
|
||||||
v8::Context::Scope context_scope(context);
|
v8::Context::Scope context_scope(context);
|
||||||
|
@ -56,7 +51,7 @@ Value* V8ValueConverterImpl::FromV8Value(
|
||||||
return FromV8ValueImpl(val, &unique_map);
|
return FromV8ValueImpl(val, &unique_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Handle<v8::Value> V8ValueConverterImpl::ToV8ValueImpl(
|
v8::Handle<v8::Value> V8ValueConverter::ToV8ValueImpl(
|
||||||
const base::Value* value) const {
|
const base::Value* value) const {
|
||||||
CHECK(value);
|
CHECK(value);
|
||||||
switch (value->GetType()) {
|
switch (value->GetType()) {
|
||||||
|
@ -99,7 +94,7 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8ValueImpl(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Array(
|
v8::Handle<v8::Value> V8ValueConverter::ToV8Array(
|
||||||
const base::ListValue* val) const {
|
const base::ListValue* val) const {
|
||||||
v8::Handle<v8::Array> result(v8::Array::New(val->GetSize()));
|
v8::Handle<v8::Array> result(v8::Array::New(val->GetSize()));
|
||||||
|
|
||||||
|
@ -119,7 +114,7 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Array(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Object(
|
v8::Handle<v8::Value> V8ValueConverter::ToV8Object(
|
||||||
const base::DictionaryValue* val) const {
|
const base::DictionaryValue* val) const {
|
||||||
v8::Handle<v8::Object> result(v8::Object::New());
|
v8::Handle<v8::Object> result(v8::Object::New());
|
||||||
|
|
||||||
|
@ -140,7 +135,7 @@ v8::Handle<v8::Value> V8ValueConverterImpl::ToV8Object(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value* V8ValueConverterImpl::FromV8ValueImpl(v8::Handle<v8::Value> val,
|
Value* V8ValueConverter::FromV8ValueImpl(v8::Handle<v8::Value> val,
|
||||||
HashToHandleMap* unique_map) const {
|
HashToHandleMap* unique_map) const {
|
||||||
CHECK(!val.IsEmpty());
|
CHECK(!val.IsEmpty());
|
||||||
|
|
||||||
|
@ -200,7 +195,7 @@ Value* V8ValueConverterImpl::FromV8ValueImpl(v8::Handle<v8::Value> val,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value* V8ValueConverterImpl::FromV8Array(v8::Handle<v8::Array> val,
|
Value* V8ValueConverter::FromV8Array(v8::Handle<v8::Array> val,
|
||||||
HashToHandleMap* unique_map) const {
|
HashToHandleMap* unique_map) const {
|
||||||
if (!UpdateAndCheckUniqueness(unique_map, val))
|
if (!UpdateAndCheckUniqueness(unique_map, val))
|
||||||
return base::Value::CreateNullValue();
|
return base::Value::CreateNullValue();
|
||||||
|
@ -237,7 +232,7 @@ Value* V8ValueConverterImpl::FromV8Array(v8::Handle<v8::Array> val,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value* V8ValueConverterImpl::FromV8Object(
|
Value* V8ValueConverter::FromV8Object(
|
||||||
v8::Handle<v8::Object> val,
|
v8::Handle<v8::Object> val,
|
||||||
HashToHandleMap* unique_map) const {
|
HashToHandleMap* unique_map) const {
|
||||||
if (!UpdateAndCheckUniqueness(unique_map, val))
|
if (!UpdateAndCheckUniqueness(unique_map, val))
|
||||||
|
@ -314,7 +309,7 @@ Value* V8ValueConverterImpl::FromV8Object(
|
||||||
return result.release();
|
return result.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool V8ValueConverterImpl::UpdateAndCheckUniqueness(
|
bool V8ValueConverter::UpdateAndCheckUniqueness(
|
||||||
HashToHandleMap* map,
|
HashToHandleMap* map,
|
||||||
v8::Handle<v8::Object> handle) const {
|
v8::Handle<v8::Object> handle) const {
|
||||||
typedef HashToHandleMap::const_iterator Iterator;
|
typedef HashToHandleMap::const_iterator Iterator;
|
|
@ -2,14 +2,14 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef ATOM_COMMON_V8_VALUE_CONVERTER_IMPL_H_
|
#ifndef ATOM_COMMON_V8_V8_VALUE_CONVERTER_H_
|
||||||
#define ATOM_COMMON_V8_VALUE_CONVERTER_IMPL_H_
|
#define ATOM_COMMON_V8_V8_VALUE_CONVERTER_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "content/public/renderer/v8_value_converter.h"
|
#include "v8/include/v8.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
class BinaryValue;
|
class BinaryValue;
|
||||||
|
@ -20,27 +20,20 @@ class Value;
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
// The content::V8ValueConverter depends on WebKit, we get rid of the WebKit
|
class V8ValueConverter {
|
||||||
// dependency by removing support of binary data.
|
|
||||||
class V8ValueConverterImpl : public content::V8ValueConverter {
|
|
||||||
public:
|
public:
|
||||||
V8ValueConverterImpl();
|
V8ValueConverter();
|
||||||
|
|
||||||
// V8ValueConverter implementation.
|
void SetDateAllowed(bool val);
|
||||||
virtual void SetDateAllowed(bool val) OVERRIDE;
|
void SetRegExpAllowed(bool val);
|
||||||
virtual void SetRegExpAllowed(bool val) OVERRIDE;
|
void SetFunctionAllowed(bool val);
|
||||||
virtual void SetFunctionAllowed(bool val) OVERRIDE;
|
void SetStripNullFromObjects(bool val);
|
||||||
virtual void SetStripNullFromObjects(bool val) OVERRIDE;
|
v8::Handle<v8::Value> ToV8Value(const base::Value* value,
|
||||||
virtual void SetStrategy(Strategy* strategy) OVERRIDE;
|
v8::Handle<v8::Context> context) const;
|
||||||
virtual v8::Handle<v8::Value> ToV8Value(
|
base::Value* FromV8Value(v8::Handle<v8::Value> value,
|
||||||
const base::Value* value,
|
v8::Handle<v8::Context> context) const;
|
||||||
v8::Handle<v8::Context> context) const OVERRIDE;
|
|
||||||
virtual base::Value* FromV8Value(
|
|
||||||
v8::Handle<v8::Value> value,
|
|
||||||
v8::Handle<v8::Context> context) const OVERRIDE;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ScopedAvoidIdentityHashForTesting;
|
|
||||||
typedef std::multimap<int, v8::Handle<v8::Object> > HashToHandleMap;
|
typedef std::multimap<int, v8::Handle<v8::Object> > HashToHandleMap;
|
||||||
|
|
||||||
v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const;
|
v8::Handle<v8::Value> ToV8ValueImpl(const base::Value* value) const;
|
||||||
|
@ -79,9 +72,9 @@ class V8ValueConverterImpl : public content::V8ValueConverter {
|
||||||
|
|
||||||
bool avoid_identity_hash_for_testing_;
|
bool avoid_identity_hash_for_testing_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(V8ValueConverterImpl);
|
DISALLOW_COPY_AND_ASSIGN(V8ValueConverter);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
#endif // ATOM_COMMON_V8_VALUE_CONVERTER_IMPL_H_
|
#endif // ATOM_COMMON_V8_V8_VALUE_CONVERTER_H_
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
#include "common/v8/node_common.h"
|
#include "common/v8/node_common.h"
|
||||||
|
|
||||||
using content::V8ValueConverter;
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -60,7 +58,7 @@ void AtomRendererBindings::OnBrowserMessage(content::RenderView* render_view,
|
||||||
v8::Context::Scope context_scope(context);
|
v8::Context::Scope context_scope(context);
|
||||||
|
|
||||||
v8::Handle<v8::Object> process = GetProcessObject(context);
|
v8::Handle<v8::Object> process = GetProcessObject(context);
|
||||||
scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
|
scoped_ptr<V8ValueConverter> converter(new V8ValueConverter);
|
||||||
|
|
||||||
std::vector<v8::Handle<v8::Value>> arguments;
|
std::vector<v8::Handle<v8::Value>> arguments;
|
||||||
arguments.reserve(1 + args.GetSize());
|
arguments.reserve(1 + args.GetSize());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue