diff --git a/native_mate/native_mate/converter.h b/native_mate/native_mate/converter.h index f8a736f59c82f..d0484da9062fe 100644 --- a/native_mate/native_mate/converter.h +++ b/native_mate/native_mate/converter.h @@ -241,6 +241,34 @@ struct Converter> { } }; +template +struct Converter> { + static v8::Local ToV8(v8::Isolate* isolate, + const std::pair& val) { + v8::Local result(v8::Array::New(isolate, 2)); + auto context = isolate->GetCurrentContext(); + result->Set(context, 0, Converter::ToV8(isolate, val.first)).Check(); + result->Set(context, 1, Converter::ToV8(isolate, val.second)).Check(); + return result; + } + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + std::pair* out) { + if (!val->IsArray()) + return false; + + v8::Local array(v8::Local::Cast(val)); + if (array->Length() != 2) + return false; + + auto context = isolate->GetCurrentContext(); + return Converter::FromV8( + isolate, array->Get(context, 0).ToLocalChecked(), &out->first) && + Converter::FromV8( + isolate, array->Get(context, 1).ToLocalChecked(), &out->second); + } +}; + template struct Converter> { static v8::Local ToV8(v8::Isolate* isolate, diff --git a/shell/browser/api/atom_api_url_loader.cc b/shell/browser/api/atom_api_url_loader.cc index 173b5701c3235..e18d53b14c52b 100644 --- a/shell/browser/api/atom_api_url_loader.cc +++ b/shell/browser/api/atom_api_url_loader.cc @@ -33,21 +33,21 @@ #include "shell/common/node_includes.h" #include "shell/common/promise_util.h" -namespace gin { +namespace mate { template <> struct Converter { static v8::Local ToV8( v8::Isolate* isolate, const network::mojom::HttpRawHeaderPairPtr& pair) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.Set("key", base::ToLowerASCII(pair->key)); dict.Set("value", pair->value); return dict.GetHandle(); } }; -} // namespace gin +} // namespace mate namespace electron { diff --git a/shell/common/api/atom_api_v8_util.cc b/shell/common/api/atom_api_v8_util.cc index 6cfd18287f6d8..6cc3880fa5893 100644 --- a/shell/common/api/atom_api_v8_util.cc +++ b/shell/common/api/atom_api_v8_util.cc @@ -28,30 +28,6 @@ struct hash> { } // namespace std -namespace mate { - -template -struct Converter> { - static bool FromV8(v8::Isolate* isolate, - v8::Local val, - std::pair* out) { - if (!val->IsArray()) - return false; - - v8::Local array(v8::Local::Cast(val)); - if (array->Length() != 2) - return false; - - auto context = isolate->GetCurrentContext(); - return Converter::FromV8( - isolate, array->Get(context, 0).ToLocalChecked(), &out->first) && - Converter::FromV8( - isolate, array->Get(context, 1).ToLocalChecked(), &out->second); - } -}; - -} // namespace mate - namespace { v8::Local GetHiddenValue(v8::Isolate* isolate,