chore: remove native_mate (Part 8) (#20598)

* refactor: convert methods of AutoUpdater to gin

* refactor: converter in map_converter.h is no more needed

* refactor: use gin in crash_reporter

* refactor: remove native_mate_converters/map_converter.h

* refactor: implement gfx_converter with gin

* refactor: convert methods of NativeImage to gin

* refactor: add gin_helper::Arguments

* fix: use gin_helper::Arguments to parse multi-type parameters
This commit is contained in:
Cheng Zhao 2019-10-18 09:31:29 +09:00 committed by GitHub
parent 58115c1cae
commit 19223952a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 361 additions and 212 deletions

View file

@ -5,15 +5,16 @@
#include "shell/browser/api/atom_api_auto_updater.h"
#include "base/time/time.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder_deprecated.h"
#include "shell/browser/browser.h"
#include "shell/browser/native_window.h"
#include "shell/browser/window_list.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/event_emitter_caller.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"
// TODO(zcbenz): Remove this after removing mate::ObjectTemplateBuilder.
// TODO(zcbenz): Remove this after removing mate::EventEmitter.
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
namespace mate {
@ -49,7 +50,7 @@ AutoUpdater::~AutoUpdater() {
void AutoUpdater::OnError(const std::string& message) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
auto error = v8::Exception::Error(gin::StringToV8(isolate(), message));
gin_helper::EmitEvent(
isolate(), GetWrapper(), "error",
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(),
@ -62,7 +63,7 @@ void AutoUpdater::OnError(const std::string& message,
const std::string& domain) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
auto error = v8::Exception::Error(gin::StringToV8(isolate(), message));
auto errorObject =
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked();
@ -70,12 +71,12 @@ void AutoUpdater::OnError(const std::string& message,
// add two new params for better error handling
errorObject
->Set(context, mate::StringToV8(isolate(), "code"),
->Set(context, gin::StringToV8(isolate(), "code"),
v8::Integer::New(isolate(), code))
.Check();
errorObject
->Set(context, mate::StringToV8(isolate(), "domain"),
mate::StringToV8(isolate(), domain))
->Set(context, gin::StringToV8(isolate(), "domain"),
gin::StringToV8(isolate(), domain))
.Check();
gin_helper::EmitEvent(isolate(), GetWrapper(), "error", errorObject, message);
@ -107,7 +108,7 @@ void AutoUpdater::OnWindowAllClosed() {
QuitAndInstall();
}
void AutoUpdater::SetFeedURL(mate::Arguments* args) {
void AutoUpdater::SetFeedURL(gin_helper::Arguments* args) {
auto_updater::AutoUpdater::SetFeedURL(args);
}
@ -126,15 +127,15 @@ void AutoUpdater::QuitAndInstall() {
}
// static
mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
return mate::CreateHandle(isolate, new AutoUpdater(isolate));
gin::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new AutoUpdater(isolate));
}
// static
void AutoUpdater::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "AutoUpdater"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
prototype->SetClassName(gin::StringToV8(isolate, "AutoUpdater"));
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
.SetMethod("getFeedURL", &auto_updater::AutoUpdater::GetFeedURL)
.SetMethod("setFeedURL", &AutoUpdater::SetFeedURL)
@ -154,7 +155,7 @@ void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
gin_helper::Dictionary dict(isolate, exports);
dict.Set("autoUpdater", AutoUpdater::Create(isolate));
dict.Set("AutoUpdater", AutoUpdater::GetConstructor(isolate)
->GetFunction(context)