refactor: remove instances of createDeepCopy (#13703)

* add new native_mate converters for base::Value

* fix converter swapping

* remove createDeepCopy from browser/api

* replace missing ListValue converter

* convert bulk of remaining createDeepCopy instances

* convert last remaining instances of createDeepCopy

* incremental progress and helper methods for value conversion

* convert Get and add template function for GetString

* final DictionaryValue method conversions

* remove usage of base::DictionaryValue in web_contents_preferences

* use IsEnabled helper where possible

* Update atom_api_web_view_manager.cc
This commit is contained in:
Shelley Vohr 2018-08-03 14:23:07 -07:00 committed by Samuel Attard
parent cecb8fb0c4
commit 9f328abe19
14 changed files with 208 additions and 113 deletions

View file

@ -30,6 +30,26 @@ v8::Local<v8::Value> Converter<base::DictionaryValue>::ToV8(
return converter.ToV8Value(&val, isolate->GetCurrentContext());
}
bool Converter<base::Value>::FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::Value* out) {
atom::V8ValueConverter converter;
std::unique_ptr<base::Value> value(
converter.FromV8Value(val, isolate->GetCurrentContext()));
if (value) {
*out = value->Clone();
return true;
} else {
return false;
}
}
v8::Local<v8::Value> Converter<base::Value>::ToV8(v8::Isolate* isolate,
const base::Value& val) {
atom::V8ValueConverter converter;
return converter.ToV8Value(&val, isolate->GetCurrentContext());
}
bool Converter<base::ListValue>::FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::ListValue* out) {

View file

@ -10,6 +10,7 @@
namespace base {
class DictionaryValue;
class ListValue;
class Value;
} // namespace base
namespace mate {
@ -23,6 +24,15 @@ struct Converter<base::DictionaryValue> {
const base::DictionaryValue& val);
};
template <>
struct Converter<base::Value> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
base::Value* out);
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::Value& val);
};
template <>
struct Converter<base::ListValue> {
static bool FromV8(v8::Isolate* isolate,