chore: remove native_mate (Part 11) (#20719)
* refactor: convert Menu and globalShortcut to gin * refactor: convert api::Cookies to gin * refactor: convert View and WebContentsView to gin * refactor: convert WebContents related classes to gin * refactor: convert powerMonitor to gin * refactor: prepare for header change * refactor: remove last uses of mate::EventEmitter * refactor: remove mate::EventEmitter * refactor: move trackable_object to gin_helper * fix: custom converter should not use Handle * fix: no more need to check if icon is empty It was a bug that the Handle<NativeImage> can be non-empty when the image file does not exist. The bug was caused by the converter code writing out the image even when the convertion fails. The bug was work-arounded by adding an additional check, but since the original bug had been fixed, the additional check is no longer needed. * fix: should always set frameId even when callback is null * fix: do not mix gin/mate handles for NativeImage
This commit is contained in:
parent
0e0d4fe990
commit
0fe6767d6b
80 changed files with 823 additions and 1087 deletions
|
@ -11,15 +11,14 @@
|
|||
#include "components/net_log/chrome_net_log.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "electron/electron_version.h"
|
||||
#include "native_mate/converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "shell/browser/atom_browser_context.h"
|
||||
#include "shell/browser/net/system_network_context_manager.h"
|
||||
#include "shell/common/native_mate_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<net::NetLogCaptureMode> {
|
||||
|
@ -41,7 +40,7 @@ struct Converter<net::NetLogCaptureMode> {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
} // namespace gin
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -84,7 +83,7 @@ NetLog::NetLog(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
|||
NetLog::~NetLog() = default;
|
||||
|
||||
v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
||||
mate::Arguments* args) {
|
||||
gin_helper::Arguments* args) {
|
||||
if (log_path.empty()) {
|
||||
args->ThrowError("The first parameter must be a valid string");
|
||||
return v8::Local<v8::Promise>();
|
||||
|
@ -93,20 +92,20 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
|||
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::kDefault;
|
||||
uint64_t max_file_size = network::mojom::NetLogExporter::kUnlimitedFileSize;
|
||||
|
||||
mate::Dictionary dict;
|
||||
gin_helper::Dictionary dict;
|
||||
if (args->GetNext(&dict)) {
|
||||
v8::Local<v8::Value> capture_mode_v8;
|
||||
if (dict.Get("captureMode", &capture_mode_v8)) {
|
||||
if (!mate::ConvertFromV8(args->isolate(), capture_mode_v8,
|
||||
&capture_mode)) {
|
||||
if (!gin::ConvertFromV8(args->isolate(), capture_mode_v8,
|
||||
&capture_mode)) {
|
||||
args->ThrowError("Invalid value for captureMode");
|
||||
return v8::Local<v8::Promise>();
|
||||
}
|
||||
}
|
||||
v8::Local<v8::Value> max_file_size_v8;
|
||||
if (dict.Get("maxFileSize", &max_file_size_v8)) {
|
||||
if (!mate::ConvertFromV8(args->isolate(), max_file_size_v8,
|
||||
&max_file_size)) {
|
||||
if (!gin::ConvertFromV8(args->isolate(), max_file_size_v8,
|
||||
&max_file_size)) {
|
||||
args->ThrowError("Invalid value for maxFileSize");
|
||||
return v8::Local<v8::Promise>();
|
||||
}
|
||||
|
@ -187,7 +186,7 @@ bool NetLog::IsCurrentlyLogging() const {
|
|||
return !!net_log_exporter_;
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> NetLog::StopLogging(mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> NetLog::StopLogging(gin_helper::Arguments* args) {
|
||||
util::Promise<void*> promise(isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
|
@ -211,16 +210,16 @@ v8::Local<v8::Promise> NetLog::StopLogging(mate::Arguments* args) {
|
|||
}
|
||||
|
||||
// static
|
||||
mate::Handle<NetLog> NetLog::Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
return mate::CreateHandle(isolate, new NetLog(isolate, browser_context));
|
||||
gin::Handle<NetLog> NetLog::Create(v8::Isolate* isolate,
|
||||
AtomBrowserContext* browser_context) {
|
||||
return gin::CreateHandle(isolate, new NetLog(isolate, browser_context));
|
||||
}
|
||||
|
||||
// static
|
||||
void NetLog::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "NetLog"));
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
prototype->SetClassName(gin::StringToV8(isolate, "NetLog"));
|
||||
gin_helper::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetProperty("currentlyLogging", &NetLog::IsCurrentlyLogging)
|
||||
.SetMethod("startLogging", &NetLog::StartLogging)
|
||||
.SetMethod("stopLogging", &NetLog::StopLogging);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue