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:
parent
6781d5e3c8
commit
3ae3233e65
96 changed files with 622 additions and 1711 deletions
|
@ -48,7 +48,7 @@
|
|||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
#include "shell/common/gin_converters/net_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "shell/browser/window_list.h"
|
||||
#include "shell/common/api/constructor.h"
|
||||
#include "shell/common/color_util.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
|
|
@ -6,21 +6,20 @@
|
|||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/optional.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "content/public/browser/tracing_controller.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/native_mate_converters/callback_converter_deprecated.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
|
||||
using content::TracingController;
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<base::trace_event::TraceConfig> {
|
||||
|
@ -31,7 +30,7 @@ struct Converter<base::trace_event::TraceConfig> {
|
|||
// has to be checked first because none of the fields
|
||||
// in the `memory_dump_config` dict below are mandatory
|
||||
// and we cannot check the config format.
|
||||
Dictionary options;
|
||||
gin_helper::Dictionary options;
|
||||
if (ConvertFromV8(isolate, val, &options)) {
|
||||
std::string category_filter, trace_options;
|
||||
if (options.Get("categoryFilter", &category_filter) &&
|
||||
|
@ -51,7 +50,7 @@ struct Converter<base::trace_event::TraceConfig> {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -79,7 +78,7 @@ void StopTracing(electron::util::Promise<base::FilePath> promise,
|
|||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> StopRecording(mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> StopRecording(gin_helper::Arguments* args) {
|
||||
electron::util::Promise<base::FilePath> promise(args->isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
|
@ -131,18 +130,18 @@ v8::Local<v8::Promise> StartTracing(
|
|||
}
|
||||
|
||||
void OnTraceBufferUsageAvailable(
|
||||
electron::util::Promise<mate::Dictionary> promise,
|
||||
electron::util::Promise<gin_helper::Dictionary> promise,
|
||||
float percent_full,
|
||||
size_t approximate_count) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
|
||||
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(promise.isolate());
|
||||
dict.Set("percentage", percent_full);
|
||||
dict.Set("value", approximate_count);
|
||||
|
||||
promise.Resolve(dict);
|
||||
promise.ResolveWithGin(dict);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> GetTraceBufferUsage(v8::Isolate* isolate) {
|
||||
electron::util::Promise<mate::Dictionary> promise(isolate);
|
||||
electron::util::Promise<gin_helper::Dictionary> promise(isolate);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
// Note: This method always succeeds.
|
||||
|
@ -155,7 +154,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("getCategories", &GetCategories);
|
||||
dict.SetMethod("startRecording", &StartTracing);
|
||||
dict.SetMethod("stopRecording", &StopRecording);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "shell/browser/atom_browser_context.h"
|
||||
#include "shell/browser/cookie_change_notifier.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "base/json/json_writer.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
@ -80,7 +80,7 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
|
|||
if (dict->GetDictionary("result", &result_body)) {
|
||||
result.Swap(result_body);
|
||||
}
|
||||
promise.Resolve(result);
|
||||
promise.ResolveWithGin(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
void* priv) {
|
||||
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("createWithSender", &CreateWithSender);
|
||||
dict.SetMethod("createEmpty", &mate::Event::Create);
|
||||
dict.SetMethod("createEmpty", &gin_helper::Event::Create);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "gin/arguments.h"
|
||||
#include "shell/browser/api/atom_api_top_level_window.h"
|
||||
#include "shell/browser/ui/atom_menu_model.h"
|
||||
#include "shell/common/api/locker.h"
|
||||
#include "shell/common/gin_helper/locker.h"
|
||||
#include "shell/common/gin_helper/trackable_object.h"
|
||||
|
||||
namespace electron {
|
||||
|
|
|
@ -56,7 +56,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
|||
int y,
|
||||
int positioning_item,
|
||||
base::Closure callback) {
|
||||
mate::Locker locker(isolate());
|
||||
gin_helper::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
|
||||
if (!native_window)
|
||||
|
|
|
@ -25,7 +25,7 @@ void MenuViews::PopupAt(TopLevelWindow* window,
|
|||
int y,
|
||||
int positioning_item,
|
||||
const base::Closure& callback) {
|
||||
mate::Locker locker(isolate());
|
||||
gin_helper::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
|
||||
auto* native_window = static_cast<NativeWindowViews*>(window->window());
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/net_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "shell/browser/api/atom_api_system_preferences.h"
|
||||
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "shell/browser/ui/cocoa/NSColor+Hex.h"
|
||||
#include "shell/common/deprecate_util.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "ui/native_theme/native_theme.h"
|
||||
|
||||
namespace gin {
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
#include "shell/browser/api/atom_api_top_level_window.h"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "native_mate/persistent_dictionary.h"
|
||||
#include "shell/browser/api/atom_api_browser_view.h"
|
||||
#include "shell/browser/api/atom_api_menu.h"
|
||||
#include "shell/browser/api/atom_api_view.h"
|
||||
|
@ -20,9 +20,10 @@
|
|||
#include "shell/common/gin_converters/gfx_converter.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
#include "shell/common/gin_converters/native_window_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/gin_helper/persistent_dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
|
||||
|
@ -809,8 +810,8 @@ void TopLevelWindow::SetVibrancy(v8::Isolate* isolate,
|
|||
}
|
||||
|
||||
void TopLevelWindow::SetTouchBar(
|
||||
const std::vector<mate::PersistentDictionary>& items) {
|
||||
window_->SetTouchBar(items);
|
||||
std::vector<gin_helper::PersistentDictionary> items) {
|
||||
window_->SetTouchBar(std::move(items));
|
||||
}
|
||||
|
||||
void TopLevelWindow::RefreshTouchBarItem(const std::string& item_id) {
|
||||
|
@ -818,8 +819,8 @@ void TopLevelWindow::RefreshTouchBarItem(const std::string& item_id) {
|
|||
}
|
||||
|
||||
void TopLevelWindow::SetEscapeTouchBarItem(
|
||||
const mate::PersistentDictionary& item) {
|
||||
window_->SetEscapeTouchBarItem(item);
|
||||
gin_helper::PersistentDictionary item) {
|
||||
window_->SetEscapeTouchBarItem(std::move(item));
|
||||
}
|
||||
|
||||
void TopLevelWindow::SelectPreviousTab() {
|
||||
|
|
|
@ -184,9 +184,9 @@ class TopLevelWindow : public gin_helper::TrackableObject<TopLevelWindow>,
|
|||
bool IsVisibleOnAllWorkspaces();
|
||||
void SetAutoHideCursor(bool auto_hide);
|
||||
virtual void SetVibrancy(v8::Isolate* isolate, v8::Local<v8::Value> value);
|
||||
void SetTouchBar(const std::vector<mate::PersistentDictionary>& items);
|
||||
void SetTouchBar(std::vector<gin_helper::PersistentDictionary> items);
|
||||
void RefreshTouchBarItem(const std::string& item_id);
|
||||
void SetEscapeTouchBarItem(const mate::PersistentDictionary& item);
|
||||
void SetEscapeTouchBarItem(gin_helper::PersistentDictionary item);
|
||||
void SelectPreviousTab();
|
||||
void SelectNextTab();
|
||||
void MergeAllWindows();
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
#include "shell/browser/web_view_guest_delegate.h"
|
||||
#include "shell/common/api/atom_api_native_image.h"
|
||||
#include "shell/common/color_util.h"
|
||||
#include "shell/common/gin_converters/blink_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/blink_converter.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/content_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
|
@ -78,7 +78,7 @@
|
|||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/image_converter.h"
|
||||
#include "shell/common/gin_converters/net_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/mouse_util.h"
|
||||
|
@ -1023,7 +1023,7 @@ void WebContents::Message(bool internal,
|
|||
blink::CloneableMessage arguments) {
|
||||
// webContents.emit('-ipc-message', new Event(), internal, channel,
|
||||
// arguments);
|
||||
EmitWithSender("-ipc-message", bindings_.dispatch_context(), base::nullopt,
|
||||
EmitWithSender("-ipc-message", bindings_.dispatch_context(), InvokeCallback(),
|
||||
internal, channel, std::move(arguments));
|
||||
}
|
||||
|
||||
|
@ -1064,7 +1064,7 @@ void WebContents::MessageHost(const std::string& channel,
|
|||
blink::CloneableMessage arguments) {
|
||||
// webContents.emit('ipc-message-host', new Event(), channel, args);
|
||||
EmitWithSender("ipc-message-host", bindings_.dispatch_context(),
|
||||
base::nullopt, channel, std::move(arguments));
|
||||
InvokeCallback(), channel, std::move(arguments));
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
|
@ -1075,7 +1075,7 @@ void WebContents::DereferenceRemoteJSObject(const std::string& context_id,
|
|||
args.Append(context_id);
|
||||
args.Append(object_id);
|
||||
args.Append(ref_count);
|
||||
EmitWithSender("-ipc-message", bindings_.dispatch_context(), base::nullopt,
|
||||
EmitWithSender("-ipc-message", bindings_.dispatch_context(), InvokeCallback(),
|
||||
/* internal */ true, "ELECTRON_BROWSER_DEREFERENCE",
|
||||
std::move(args));
|
||||
}
|
||||
|
@ -2071,10 +2071,10 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
|||
|
||||
content::RenderWidgetHost* rwh = view->GetRenderWidgetHost();
|
||||
blink::WebInputEvent::Type type =
|
||||
mate::GetWebInputEventType(isolate, input_event);
|
||||
gin::GetWebInputEventType(isolate, input_event);
|
||||
if (blink::WebInputEvent::IsMouseEventType(type)) {
|
||||
blink::WebMouseEvent mouse_event;
|
||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
||||
if (gin::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
||||
if (IsOffScreen()) {
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
GetOffScreenRenderWidgetHostView()->SendMouseEvent(mouse_event);
|
||||
|
@ -2094,7 +2094,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
|||
}
|
||||
} else if (type == blink::WebInputEvent::kMouseWheel) {
|
||||
blink::WebMouseWheelEvent mouse_wheel_event;
|
||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
|
||||
if (gin::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
|
||||
if (IsOffScreen()) {
|
||||
#if BUILDFLAG(ENABLE_OSR)
|
||||
GetOffScreenRenderWidgetHostView()->SendMouseWheelEvent(
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_converters/net_converter.h"
|
||||
#include "shell/common/gin_converters/std_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
|
||||
namespace gin {
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "shell/browser/web_contents_zoom_controller.h"
|
||||
#include "shell/browser/web_view_manager.h"
|
||||
#include "shell/common/gin_converters/content_converter.h"
|
||||
#include "shell/common/gin_converters/value_converter_gin_adapter.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
|
|
|
@ -6,26 +6,26 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
#include "native_mate/object_template_builder_deprecated.h"
|
||||
#include "shell/common/native_mate_converters/blink_converter.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "shell/common/gin_converters/blink_converter.h"
|
||||
|
||||
namespace mate {
|
||||
namespace gin_helper {
|
||||
|
||||
Event::Event(v8::Isolate* isolate) {
|
||||
Init(isolate);
|
||||
}
|
||||
gin::WrapperInfo Event::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||
|
||||
Event::Event() {}
|
||||
|
||||
Event::~Event() = default;
|
||||
|
||||
void Event::SetCallback(base::Optional<InvokeCallback> callback) {
|
||||
void Event::SetCallback(InvokeCallback callback) {
|
||||
DCHECK(!callback_);
|
||||
callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
void Event::PreventDefault(v8::Isolate* isolate) {
|
||||
GetWrapper()
|
||||
->Set(isolate->GetCurrentContext(),
|
||||
StringToV8(isolate, "defaultPrevented"), v8::True(isolate))
|
||||
v8::Local<v8::Object> self = GetWrapper(isolate).ToLocalChecked();
|
||||
self->Set(isolate->GetCurrentContext(),
|
||||
gin::StringToV8(isolate, "defaultPrevented"), v8::True(isolate))
|
||||
.Check();
|
||||
}
|
||||
|
||||
|
@ -34,27 +34,28 @@ bool Event::SendReply(v8::Isolate* isolate, v8::Local<v8::Value> result) {
|
|||
return false;
|
||||
|
||||
blink::CloneableMessage message;
|
||||
if (!ConvertFromV8(isolate, result, &message)) {
|
||||
if (!gin::ConvertFromV8(isolate, result, &message)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::move(*callback_).Run(std::move(message));
|
||||
callback_.reset();
|
||||
std::move(callback_).Run(std::move(message));
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
Handle<Event> Event::Create(v8::Isolate* isolate) {
|
||||
return mate::CreateHandle(isolate, new Event(isolate));
|
||||
}
|
||||
|
||||
// static
|
||||
void Event::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "Event"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
gin::ObjectTemplateBuilder Event::GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) {
|
||||
return gin::Wrappable<Event>::GetObjectTemplateBuilder(isolate)
|
||||
.SetMethod("preventDefault", &Event::PreventDefault)
|
||||
.SetMethod("sendReply", &Event::SendReply);
|
||||
}
|
||||
|
||||
} // namespace mate
|
||||
const char* Event::GetTypeName() {
|
||||
return "WebRequest";
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<Event> Event::Create(v8::Isolate* isolate) {
|
||||
return gin::CreateHandle(isolate, new Event());
|
||||
}
|
||||
|
||||
} // namespace gin_helper
|
||||
|
|
|
@ -5,27 +5,26 @@
|
|||
#ifndef SHELL_BROWSER_API_EVENT_H_
|
||||
#define SHELL_BROWSER_API_EVENT_H_
|
||||
|
||||
#include "base/optional.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "gin/handle.h"
|
||||
#include "gin/wrappable.h"
|
||||
|
||||
namespace IPC {
|
||||
class Message;
|
||||
}
|
||||
|
||||
namespace mate {
|
||||
namespace gin_helper {
|
||||
|
||||
class Event : public Wrappable<Event> {
|
||||
class Event : public gin::Wrappable<Event> {
|
||||
public:
|
||||
using InvokeCallback = electron::mojom::ElectronBrowser::InvokeCallback;
|
||||
static Handle<Event> Create(v8::Isolate* isolate);
|
||||
|
||||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
static gin::WrapperInfo kWrapperInfo;
|
||||
|
||||
static gin::Handle<Event> Create(v8::Isolate* isolate);
|
||||
|
||||
// Pass the callback to be invoked.
|
||||
void SetCallback(base::Optional<InvokeCallback> callback);
|
||||
void SetCallback(InvokeCallback callback);
|
||||
|
||||
// event.PreventDefault().
|
||||
void PreventDefault(v8::Isolate* isolate);
|
||||
|
@ -35,16 +34,21 @@ class Event : public Wrappable<Event> {
|
|||
bool SendReply(v8::Isolate* isolate, v8::Local<v8::Value> result);
|
||||
|
||||
protected:
|
||||
explicit Event(v8::Isolate* isolate);
|
||||
Event();
|
||||
~Event() override;
|
||||
|
||||
// gin::Wrappable:
|
||||
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) override;
|
||||
const char* GetTypeName() override;
|
||||
|
||||
private:
|
||||
// Replyer for the synchronous messages.
|
||||
base::Optional<InvokeCallback> callback_;
|
||||
InvokeCallback callback_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Event);
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin_helper
|
||||
|
||||
#endif // SHELL_BROWSER_API_EVENT_H_
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "content/public/browser/browser_thread.h"
|
||||
#include "gpu/config/gpu_info_collector.h"
|
||||
#include "shell/browser/api/gpu_info_enumerator.h"
|
||||
#include "shell/common/gin_converters/value_converter.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -46,7 +47,7 @@ void GPUInfoManager::ProcessCompleteInfo() {
|
|||
// We have received the complete information, resolve all promises that
|
||||
// were waiting for this info.
|
||||
for (auto& promise : complete_info_promise_set_) {
|
||||
promise.Resolve(*result);
|
||||
promise.ResolveWithGin(*result);
|
||||
}
|
||||
complete_info_promise_set_.clear();
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ void GPUInfoManager::FetchBasicInfo(
|
|||
util::Promise<base::DictionaryValue> promise) {
|
||||
gpu::GPUInfo gpu_info;
|
||||
CollectBasicGraphicsInfo(&gpu_info);
|
||||
promise.Resolve(*EnumerateGPUInfo(gpu_info));
|
||||
promise.ResolveWithGin(*EnumerateGPUInfo(gpu_info));
|
||||
}
|
||||
|
||||
std::unique_ptr<base::DictionaryValue> GPUInfoManager::EnumerateGPUInfo(
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "content/browser/gpu/gpu_data_manager_impl.h" // nogncheck
|
||||
#include "content/public/browser/gpu_data_manager.h"
|
||||
#include "content/public/browser/gpu_data_manager_observer.h"
|
||||
#include "shell/common/native_mate_converters/value_converter.h"
|
||||
#include "shell/common/promise_util.h"
|
||||
|
||||
namespace electron {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue