chore: remove native_mate (Part 1) (#20085)

* move Destroyable utilities out of native_mate

* do not set "destroy" in ObjectTemplateBuilder

* remove ObjectTemplateBuilder::MakeDestroyable

* do not pollute gin namespace

* add more comments

* remove hack of Arguments
This commit is contained in:
Cheng Zhao 2019-09-04 11:14:16 +09:00 committed by GitHub
parent 96b42bddb8
commit b601f3a031
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 108 additions and 42 deletions

View file

@ -140,8 +140,8 @@ v8::Local<v8::Value> BrowserView::GetWebContents() {
void BrowserView::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "BrowserView"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("setAutoResize", &BrowserView::SetAutoResize)
.SetMethod("setBounds", &BrowserView::SetBounds)
.SetMethod("getBounds", &BrowserView::GetBounds)

View file

@ -190,8 +190,8 @@ double DownloadItem::GetStartTime() const {
void DownloadItem::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "DownloadItem"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("pause", &DownloadItem::Pause)
.SetMethod("isPaused", &DownloadItem::IsPaused)
.SetMethod("resume", &DownloadItem::Resume)

View file

@ -222,8 +222,8 @@ void Menu::OnMenuWillShow() {
void Menu::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Menu"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("insertItem", &Menu::InsertItemAt)
.SetMethod("insertCheckItem", &Menu::InsertCheckItemAt)
.SetMethod("insertRadioItem", &Menu::InsertRadioItemAt)

View file

@ -225,8 +225,8 @@ bool Notification::IsSupported() {
void Notification::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Notification"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("show", &Notification::Show)
.SetMethod("close", &Notification::Close)
.SetProperty("title", &Notification::GetTitle, &Notification::SetTitle)

View file

@ -115,9 +115,8 @@ v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
void PowerMonitor::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "PowerMonitor"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
#if defined(OS_LINUX)
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)

View file

@ -682,8 +682,8 @@ mate::Handle<Session> Session::FromPartition(
void Session::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Session"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("resolveProxy", &Session::ResolveProxy)
.SetMethod("getCacheSize", &Session::GetCacheSize)
.SetMethod("clearCache", &Session::ClearCache)

View file

@ -1064,8 +1064,8 @@ mate::WrappableBase* TopLevelWindow::New(mate::Arguments* args) {
void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "TopLevelWindow"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("setContentView", &TopLevelWindow::SetContentView)
.SetMethod("close", &TopLevelWindow::Close)
.SetMethod("focus", &TopLevelWindow::Focus)

View file

@ -246,8 +246,8 @@ gfx::Rect Tray::GetBounds() {
void Tray::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Tray"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("setImage", &Tray::SetImage)
.SetMethod("setPressedImage", &Tray::SetPressedImage)
.SetMethod("setToolTip", &Tray::SetToolTip)

View file

@ -520,8 +520,8 @@ mate::WrappableBase* URLRequestNS::New(mate::Arguments* args) {
void URLRequestNS::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "URLRequest"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("write", &URLRequestNS::Write)
.SetMethod("cancel", &URLRequestNS::Cancel)
.SetMethod("setExtraHeader", &URLRequestNS::SetExtraHeader)

View file

@ -2381,8 +2381,8 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot(
void WebContents::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "WebContents"));
gin_helper::Destroyable::MakeDestroyable(isolate, prototype);
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.SetMethod("setBackgroundThrottling",
&WebContents::SetBackgroundThrottling)
.SetMethod("getProcessId", &WebContents::GetProcessID)