diff --git a/atom/browser/api/atom_api_cookies.cc b/atom/browser/api/atom_api_cookies.cc index c1aef31ce259..924c66aac719 100644 --- a/atom/browser/api/atom_api_cookies.cc +++ b/atom/browser/api/atom_api_cookies.cc @@ -18,8 +18,8 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" -#include "native_mate/dictionary.h" -#include "native_mate/object_template_builder.h" +#include "gin/dictionary.h" +#include "gin/object_template_builder.h" #include "net/cookies/canonical_cookie.h" #include "net/cookies/cookie_store.h" #include "net/cookies/cookie_util.h" @@ -28,7 +28,7 @@ using content::BrowserThread; -namespace mate { +namespace gin { template <> struct Converter { @@ -45,7 +45,7 @@ template <> struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const net::CanonicalCookie& val) { - mate::Dictionary dict(isolate, v8::Object::New(isolate)); + gin::Dictionary dict(isolate, v8::Object::New(isolate)); dict.Set("name", val.Name()); dict.Set("value", val.Value()); dict.Set("domain", val.Domain()); @@ -56,7 +56,7 @@ struct Converter { dict.Set("session", !val.IsPersistent()); if (val.IsPersistent()) dict.Set("expirationDate", val.ExpiryDate().ToDoubleT()); - return dict.GetHandle(); + return ConvertToV8(isolate, dict).As(); } }; @@ -68,22 +68,22 @@ struct Converter { switch (val) { case network::mojom::CookieChangeCause::INSERTED: case network::mojom::CookieChangeCause::EXPLICIT: - return mate::StringToV8(isolate, "explicit"); + return gin::StringToV8(isolate, "explicit"); case network::mojom::CookieChangeCause::OVERWRITE: - return mate::StringToV8(isolate, "overwrite"); + return gin::StringToV8(isolate, "overwrite"); case network::mojom::CookieChangeCause::EXPIRED: - return mate::StringToV8(isolate, "expired"); + return gin::StringToV8(isolate, "expired"); case network::mojom::CookieChangeCause::EVICTED: - return mate::StringToV8(isolate, "evicted"); + return gin::StringToV8(isolate, "evicted"); case network::mojom::CookieChangeCause::EXPIRED_OVERWRITE: - return mate::StringToV8(isolate, "expired-overwrite"); + return gin::StringToV8(isolate, "expired-overwrite"); default: - return mate::StringToV8(isolate, "unknown"); + return gin::StringToV8(isolate, "unknown"); } } }; -} // namespace mate +} // namespace gin namespace atom { @@ -143,7 +143,7 @@ void FilterCookies(const base::Value& filter, result.push_back(cookie); } - promise.Resolve(result); + promise.Resolve(gin::ConvertToV8(promise.isolate(), result)); } std::string InclusionStatusToString( @@ -330,19 +330,21 @@ v8::Local Cookies::FlushStore() { } void Cookies::OnCookieChanged(const CookieDetails* details) { - Emit("changed", *(details->cookie), details->cause, details->removed); + Emit("changed", gin::ConvertToV8(isolate(), *(details->cookie)), + gin::ConvertToV8(isolate(), details->cause), + gin::ConvertToV8(isolate(), details->removed)); } // static -mate::Handle Cookies::Create(v8::Isolate* isolate, - AtomBrowserContext* browser_context) { - return mate::CreateHandle(isolate, new Cookies(isolate, browser_context)); +gin::Handle Cookies::Create(v8::Isolate* isolate, + AtomBrowserContext* browser_context) { + return gin::CreateHandle(isolate, new Cookies(isolate, browser_context)); } // static void Cookies::BuildPrototype(v8::Isolate* isolate, v8::Local prototype) { - prototype->SetClassName(mate::StringToV8(isolate, "Cookies")); + prototype->SetClassName(gin::StringToV8(isolate, "Cookies")); mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) .SetMethod("get", &Cookies::Get) .SetMethod("remove", &Cookies::Remove) diff --git a/atom/browser/api/atom_api_cookies.h b/atom/browser/api/atom_api_cookies.h index 3c3a2919b827..cfba0d7964de 100644 --- a/atom/browser/api/atom_api_cookies.h +++ b/atom/browser/api/atom_api_cookies.h @@ -12,7 +12,7 @@ #include "atom/browser/net/cookie_details.h" #include "atom/common/promise_util.h" #include "base/callback_list.h" -#include "native_mate/handle.h" +#include "gin/handle.h" #include "net/cookies/canonical_cookie.h" namespace base { @@ -36,8 +36,8 @@ class Cookies : public mate::TrackableObject { FAILED, }; - static mate::Handle Create(v8::Isolate* isolate, - AtomBrowserContext* browser_context); + static gin::Handle Create(v8::Isolate* isolate, + AtomBrowserContext* browser_context); // mate::TrackableObject: static void BuildPrototype(v8::Isolate* isolate, diff --git a/atom/browser/api/event_emitter.h b/atom/browser/api/event_emitter.h index ae70956c4b18..3888c624fa75 100644 --- a/atom/browser/api/event_emitter.h +++ b/atom/browser/api/event_emitter.h @@ -46,6 +46,9 @@ class EventEmitter : public Wrappable { v8::Local GetWrapper() const { return Wrappable::GetWrapper(); } + v8::MaybeLocal GetWrapper(v8::Isolate* isolate) const { + return Wrappable::GetWrapper(isolate); + } // this.emit(name, event, args...); template diff --git a/native_mate/native_mate/wrappable.cc b/native_mate/native_mate/wrappable.cc index d469ba92159c..eab1342ef5c6 100644 --- a/native_mate/native_mate/wrappable.cc +++ b/native_mate/native_mate/wrappable.cc @@ -28,6 +28,15 @@ v8::Local WrappableBase::GetWrapper() const { return v8::Local(); } +v8::MaybeLocal WrappableBase::GetWrapper( + v8::Isolate* isolate) const { + if (!wrapper_.IsEmpty()) + return v8::MaybeLocal( + v8::Local::New(isolate, wrapper_)); + else + return v8::MaybeLocal(); +} + void WrappableBase::InitWith(v8::Isolate* isolate, v8::Local wrapper) { CHECK(wrapper_.IsEmpty()); diff --git a/native_mate/native_mate/wrappable_base.h b/native_mate/native_mate/wrappable_base.h index 1c489cc37af3..397cfd96cbb0 100644 --- a/native_mate/native_mate/wrappable_base.h +++ b/native_mate/native_mate/wrappable_base.h @@ -30,6 +30,7 @@ class WrappableBase { // Retrieve the v8 wrapper object cooresponding to this object. v8::Local GetWrapper() const; + v8::MaybeLocal GetWrapper(v8::Isolate* isolate) const; // Returns the Isolate this object is created in. v8::Isolate* isolate() const { return isolate_; }