chore: remove native_mate (Part 12) (#20869)

* refactor: move mate::Event to gin

* refactor: move mate::Locker to gin

* refactor: convert contextBridge to gin

* refactor: convert contentTracing to gin

* refactor: remove callback converter of native_mate

* refactor: remove file_dialog_converter and native_window_converter from native_mate

* refactor: convert webFrame to gin

* refactor: move blink_converter to gin

* refactor: remove net_converter from native_mate

* refactor: remove event_emitter_caller_deprecated

* refactor: remove gurl_converter from native_mate

* refactor: remove file_path and string16_converter from native_mate

* refactor: remove image_converter from native_mate

* refactor: move value_converter to gin
This commit is contained in:
Cheng Zhao 2019-10-31 16:56:00 +09:00 committed by GitHub
parent 6781d5e3c8
commit 3ae3233e65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 622 additions and 1711 deletions

View file

@ -11,13 +11,9 @@
#include "base/process/process_handle.h"
#include "content/public/renderer/render_frame.h"
#include "electron/buildflags/buildflags.h"
#include "gin/converter.h"
#include "native_mate/dictionary.h"
#include "shell/common/api/electron_bindings.h"
#include "shell/common/application_info.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/native_mate_converters/string16_converter.h"
#include "shell/common/native_mate_converters/value_converter.h"
#include "shell/common/node_bindings.h"
#include "shell/common/node_includes.h"
#include "shell/common/node_util.h"
@ -60,10 +56,10 @@ v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) {
// adapted from node.cc
v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
v8::Local<v8::String> key,
mate::Arguments* margs) {
gin_helper::Arguments* margs) {
v8::Local<v8::Object> exports;
std::string module_key = gin::V8ToString(isolate, key);
mate::Dictionary cache(isolate, GetModuleCache(isolate));
gin_helper::Dictionary cache(isolate, GetModuleCache(isolate));
if (cache.Get(module_key.c_str(), &exports)) {
return exports;
@ -97,9 +93,8 @@ void InvokeHiddenCallback(v8::Handle<v8::Context> context,
const std::string& hidden_key,
const std::string& callback_name) {
auto* isolate = context->GetIsolate();
auto binding_key = mate::ConvertToV8(isolate, hidden_key)
->ToString(context)
.ToLocalChecked();
auto binding_key =
gin::ConvertToV8(isolate, hidden_key)->ToString(context).ToLocalChecked();
auto private_binding_key = v8::Private::ForApi(isolate, binding_key);
auto global_object = context->Global();
v8::Local<v8::Value> value;
@ -108,7 +103,7 @@ void InvokeHiddenCallback(v8::Handle<v8::Context> context,
if (value.IsEmpty() || !value->IsObject())
return;
auto binding = value->ToObject(context).ToLocalChecked();
auto callback_key = mate::ConvertToV8(isolate, callback_name)
auto callback_key = gin::ConvertToV8(isolate, callback_name)
->ToString(context)
.ToLocalChecked();
auto callback_value = binding->Get(context, callback_key).ToLocalChecked();
@ -132,11 +127,11 @@ void AtomSandboxedRendererClient::InitializeBindings(
v8::Local<v8::Context> context,
bool is_main_frame) {
auto* isolate = context->GetIsolate();
mate::Dictionary b(isolate, binding);
gin_helper::Dictionary b(isolate, binding);
b.SetMethod("get", GetBinding);
b.SetMethod("createPreloadScript", CreatePreloadScript);
mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary process = gin::Dictionary::CreateEmpty(isolate);
b.Set("process", process);
ElectronBindings::BindProcess(isolate, &process, metrics_.get());
@ -248,7 +243,7 @@ void AtomSandboxedRendererClient::SetupMainWorldOverrides(
// an argument.
auto* isolate = context->GetIsolate();
mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary process = gin::Dictionary::CreateEmpty(isolate);
process.SetMethod("_linkedBinding", GetBinding);
std::vector<v8::Local<v8::String>> isolated_bundle_params = {
@ -272,7 +267,7 @@ void AtomSandboxedRendererClient::SetupExtensionWorldOverrides(
#else
auto* isolate = context->GetIsolate();
mate::Dictionary process = mate::Dictionary::CreateEmpty(isolate);
gin_helper::Dictionary process = gin::Dictionary::CreateEmpty(isolate);
process.SetMethod("_linkedBinding", GetBinding);
std::vector<v8::Local<v8::String>> isolated_bundle_params = {