chore: remove native_mate (Part 3) (#20131)
* use gin converter in atom_api_menu * please only put necessary includes in header Having include in header means they have dependency relationship, putting arbitrary includes really really really really really makes refacoring much harder. * remove some simple uses of callback_converter_deprecated.h * use gin callback converter in file_dialog code * use gin in ErrorThrower * use gin in atom_bundle_mover * fix mistake in node stream * deprecate native_mate version of event_emitter_caller * use gin in node_bindings * remove usages of native_mate event_emitter_caller.h except for EventEmitter * fix compilation on Windows * gin::Arguments behaves differently on GetNext * just use StringToV8
This commit is contained in:
parent
7be1905023
commit
2c23e44ed9
61 changed files with 515 additions and 323 deletions
|
@ -13,12 +13,9 @@
|
|||
#include "content/public/renderer/render_frame_visitor.h"
|
||||
#include "content/public/renderer/render_view.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "services/service_manager/public/cpp/interface_provider.h"
|
||||
#include "shell/common/api/api.mojom.h"
|
||||
#include "shell/common/api/event_emitter_caller.h"
|
||||
#include "shell/common/native_mate_converters/blink_converter.h"
|
||||
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
|
||||
#include "shell/common/native_mate_converters/gfx_converter.h"
|
||||
#include "shell/common/native_mate_converters/string16_converter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
|
|
@ -16,13 +16,9 @@
|
|||
#include "electron/buildflags/buildflags.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/net_module.h"
|
||||
#include "net/grit/net_resources.h"
|
||||
#include "services/service_manager/public/cpp/interface_provider.h"
|
||||
#include "shell/common/api/event_emitter_caller.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "third_party/blink/public/platform/web_isolated_world_info.h"
|
||||
#include "third_party/blink/public/web/blink.h"
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include "base/command_line.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/api/electron_bindings.h"
|
||||
#include "shell/common/api/event_emitter_caller.h"
|
||||
#include "shell/common/asar/asar_util.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/event_emitter_caller.h"
|
||||
#include "shell/common/node_bindings.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
|
@ -56,7 +56,8 @@ void AtomRendererClient::RunScriptsAtDocumentStart(
|
|||
v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
||||
node::Environment* env = GetEnvironment(render_frame);
|
||||
if (env)
|
||||
mate::EmitEvent(env->isolate(), env->process_object(), "document-start");
|
||||
gin_helper::EmitEvent(env->isolate(), env->process_object(),
|
||||
"document-start");
|
||||
}
|
||||
|
||||
void AtomRendererClient::RunScriptsAtDocumentEnd(
|
||||
|
@ -66,7 +67,8 @@ void AtomRendererClient::RunScriptsAtDocumentEnd(
|
|||
v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
||||
node::Environment* env = GetEnvironment(render_frame);
|
||||
if (env)
|
||||
mate::EmitEvent(env->isolate(), env->process_object(), "document-end");
|
||||
gin_helper::EmitEvent(env->isolate(), env->process_object(),
|
||||
"document-end");
|
||||
}
|
||||
|
||||
void AtomRendererClient::DidCreateScriptContext(
|
||||
|
@ -135,7 +137,7 @@ void AtomRendererClient::DidCreateScriptContext(
|
|||
// Add Electron extended APIs.
|
||||
electron_bindings_->BindTo(env->isolate(), env->process_object());
|
||||
AddRenderBindings(env->isolate(), env->process_object());
|
||||
mate::Dictionary process_dict(env->isolate(), env->process_object());
|
||||
gin_helper::Dictionary process_dict(env->isolate(), env->process_object());
|
||||
process_dict.SetReadOnly("isMainFrame", render_frame->IsMainFrame());
|
||||
|
||||
// Load everything.
|
||||
|
@ -160,7 +162,7 @@ void AtomRendererClient::WillReleaseScriptContext(
|
|||
if (environments_.erase(env) == 0)
|
||||
return;
|
||||
|
||||
mate::EmitEvent(env->isolate(), env->process_object(), "exit");
|
||||
gin_helper::EmitEvent(env->isolate(), env->process_object(), "exit");
|
||||
|
||||
// The main frame may be replaced.
|
||||
if (env == node_bindings_->uv_env())
|
||||
|
|
|
@ -11,16 +11,14 @@
|
|||
#include "base/environment.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "electron/shell/common/api/event_emitter_caller.h"
|
||||
#include "electron/shell/common/node_includes.h"
|
||||
#include "electron/shell/common/options_switches.h"
|
||||
#include "electron/shell/renderer/atom_render_frame_observer.h"
|
||||
#include "electron/shell/renderer/renderer_client_base.h"
|
||||
#include "mojo/public/cpp/system/platform_handle.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/atom_constants.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/heap_snapshot.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "shell/renderer/atom_render_frame_observer.h"
|
||||
#include "shell/renderer/renderer_client_base.h"
|
||||
#include "third_party/blink/public/web/blink.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
|
||||
|
@ -33,8 +31,7 @@ const char kIpcKey[] = "ipcNative";
|
|||
// Gets the private object under kIpcKey
|
||||
v8::Local<v8::Object> GetIpcObject(v8::Local<v8::Context> context) {
|
||||
auto* isolate = context->GetIsolate();
|
||||
auto binding_key =
|
||||
mate::ConvertToV8(isolate, kIpcKey)->ToString(context).ToLocalChecked();
|
||||
auto binding_key = gin::StringToV8(isolate, kIpcKey);
|
||||
auto private_binding_key = v8::Private::ForApi(isolate, binding_key);
|
||||
auto global_object = context->Global();
|
||||
auto value =
|
||||
|
@ -64,7 +61,7 @@ void InvokeIpcCallback(v8::Local<v8::Context> context,
|
|||
callback_scope.reset(new node::CallbackScope(isolate, ipcNative, {0, 0}));
|
||||
}
|
||||
|
||||
auto callback_key = mate::ConvertToV8(isolate, callback_name)
|
||||
auto callback_key = gin::ConvertToV8(isolate, callback_name)
|
||||
->ToString(context)
|
||||
.ToLocalChecked();
|
||||
auto callback_value = ipcNative->Get(context, callback_key).ToLocalChecked();
|
||||
|
@ -86,8 +83,8 @@ void EmitIPCEvent(v8::Local<v8::Context> context,
|
|||
v8::MicrotasksScope::kRunMicrotasks);
|
||||
|
||||
std::vector<v8::Local<v8::Value>> argv = {
|
||||
mate::ConvertToV8(isolate, internal), mate::ConvertToV8(isolate, channel),
|
||||
mate::ConvertToV8(isolate, args), mate::ConvertToV8(isolate, sender_id)};
|
||||
gin::ConvertToV8(isolate, internal), gin::ConvertToV8(isolate, channel),
|
||||
gin::ConvertToV8(isolate, args), gin::ConvertToV8(isolate, sender_id)};
|
||||
|
||||
InvokeIpcCallback(context, "onMessage", argv);
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include "base/lazy_instance.h"
|
||||
#include "base/threading/thread_local.h"
|
||||
#include "shell/common/api/electron_bindings.h"
|
||||
#include "shell/common/api/event_emitter_caller.h"
|
||||
#include "shell/common/asar/asar_util.h"
|
||||
#include "shell/common/gin_helper/event_emitter_caller.h"
|
||||
#include "shell/common/node_bindings.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
|
@ -69,7 +69,7 @@ void WebWorkerObserver::ContextCreated(v8::Local<v8::Context> worker_context) {
|
|||
void WebWorkerObserver::ContextWillDestroy(v8::Local<v8::Context> context) {
|
||||
node::Environment* env = node::Environment::GetCurrent(context);
|
||||
if (env)
|
||||
mate::EmitEvent(env->isolate(), env->process_object(), "exit");
|
||||
gin_helper::EmitEvent(env->isolate(), env->process_object(), "exit");
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue