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