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
|
@ -21,6 +21,7 @@
|
|||
#include "base/win/registry.h"
|
||||
#include "shell/browser/native_window_views.h"
|
||||
#include "shell/browser/unresponsive_suppressor.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
|
||||
namespace file_dialog {
|
||||
|
||||
|
@ -81,19 +82,19 @@ bool CreateDialogThread(RunState* run_state) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void OnDialogOpened(electron::util::Promise<mate::Dictionary> promise,
|
||||
void OnDialogOpened(electron::util::Promise<gin::Dictionary> promise,
|
||||
bool canceled,
|
||||
std::vector<base::FilePath> paths) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(promise.isolate());
|
||||
dict.Set("canceled", canceled);
|
||||
dict.Set("filePaths", paths);
|
||||
promise.Resolve(dict);
|
||||
promise.ResolveWithGin(dict);
|
||||
}
|
||||
|
||||
void RunOpenDialogInNewThread(
|
||||
const RunState& run_state,
|
||||
const DialogSettings& settings,
|
||||
electron::util::Promise<mate::Dictionary> promise) {
|
||||
electron::util::Promise<gin::Dictionary> promise) {
|
||||
std::vector<base::FilePath> paths;
|
||||
bool result = ShowOpenDialogSync(settings, &paths);
|
||||
run_state.ui_task_runner->PostTask(
|
||||
|
@ -102,19 +103,19 @@ void RunOpenDialogInNewThread(
|
|||
run_state.ui_task_runner->DeleteSoon(FROM_HERE, run_state.dialog_thread);
|
||||
}
|
||||
|
||||
void OnSaveDialogDone(electron::util::Promise<mate::Dictionary> promise,
|
||||
void OnSaveDialogDone(electron::util::Promise<gin::Dictionary> promise,
|
||||
bool canceled,
|
||||
const base::FilePath path) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(promise.isolate());
|
||||
dict.Set("canceled", canceled);
|
||||
dict.Set("filePath", path);
|
||||
promise.Resolve(dict);
|
||||
promise.ResolveWithGin(dict);
|
||||
}
|
||||
|
||||
void RunSaveDialogInNewThread(
|
||||
const RunState& run_state,
|
||||
const DialogSettings& settings,
|
||||
electron::util::Promise<mate::Dictionary> promise) {
|
||||
electron::util::Promise<gin::Dictionary> promise) {
|
||||
base::FilePath path;
|
||||
bool result = ShowSaveDialogSync(settings, &path);
|
||||
run_state.ui_task_runner->PostTask(
|
||||
|
@ -276,13 +277,13 @@ bool ShowOpenDialogSync(const DialogSettings& settings,
|
|||
}
|
||||
|
||||
void ShowOpenDialog(const DialogSettings& settings,
|
||||
electron::util::Promise<mate::Dictionary> promise) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
|
||||
electron::util::Promise<gin::Dictionary> promise) {
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(promise.isolate());
|
||||
RunState run_state;
|
||||
if (!CreateDialogThread(&run_state)) {
|
||||
dict.Set("canceled", true);
|
||||
dict.Set("filePaths", std::vector<base::FilePath>());
|
||||
promise.Resolve(dict);
|
||||
promise.ResolveWithGin(dict);
|
||||
} else {
|
||||
run_state.dialog_thread->task_runner()->PostTask(
|
||||
FROM_HERE, base::BindOnce(&RunOpenDialogInNewThread, run_state,
|
||||
|
@ -326,13 +327,13 @@ bool ShowSaveDialogSync(const DialogSettings& settings, base::FilePath* path) {
|
|||
}
|
||||
|
||||
void ShowSaveDialog(const DialogSettings& settings,
|
||||
electron::util::Promise<mate::Dictionary> promise) {
|
||||
electron::util::Promise<gin::Dictionary> promise) {
|
||||
RunState run_state;
|
||||
if (!CreateDialogThread(&run_state)) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(promise.isolate());
|
||||
gin::Dictionary dict = gin::Dictionary::CreateEmpty(promise.isolate());
|
||||
dict.Set("canceled", true);
|
||||
dict.Set("filePath", base::FilePath());
|
||||
promise.Resolve(dict);
|
||||
promise.ResolveWithGin(dict);
|
||||
} else {
|
||||
run_state.dialog_thread->task_runner()->PostTask(
|
||||
FROM_HERE, base::BindOnce(&RunSaveDialogInNewThread, run_state,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue