refactor: make shell.OpenExternal async (#17135)
This commit is contained in:
parent
0755857a0c
commit
6d96f30ed3
16 changed files with 70 additions and 140 deletions
|
@ -52,33 +52,9 @@ void OnOpenExternalFinished(atom::util::Promise promise,
|
|||
promise.RejectWithErrorMessage(error.c_str());
|
||||
}
|
||||
|
||||
bool OpenExternalSync(
|
||||
#if defined(OS_WIN)
|
||||
const base::string16& url,
|
||||
#else
|
||||
const GURL& url,
|
||||
#endif
|
||||
mate::Arguments* args) {
|
||||
platform_util::OpenExternalOptions options;
|
||||
if (args->Length() >= 2) {
|
||||
mate::Dictionary obj;
|
||||
if (args->GetNext(&obj)) {
|
||||
obj.Get("activate", &options.activate);
|
||||
obj.Get("workingDirectory", &options.working_dir);
|
||||
}
|
||||
}
|
||||
|
||||
return platform_util::OpenExternal(url, options);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> OpenExternal(
|
||||
#if defined(OS_WIN)
|
||||
const base::string16& url,
|
||||
#else
|
||||
const GURL& url,
|
||||
#endif
|
||||
mate::Arguments* args) {
|
||||
v8::Local<v8::Promise> OpenExternal(const GURL& url, mate::Arguments* args) {
|
||||
atom::util::Promise promise(args->isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
platform_util::OpenExternalOptions options;
|
||||
if (args->Length() >= 2) {
|
||||
|
@ -89,7 +65,6 @@ v8::Local<v8::Promise> OpenExternal(
|
|||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
platform_util::OpenExternal(
|
||||
url, options,
|
||||
base::BindOnce(&OnOpenExternalFinished, std::move(promise)));
|
||||
|
@ -158,7 +133,6 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
|
||||
dict.SetMethod("openItem", &platform_util::OpenItem);
|
||||
dict.SetMethod("openExternalSync", &OpenExternalSync);
|
||||
dict.SetMethod("openExternal", &OpenExternal);
|
||||
dict.SetMethod("moveItemToTrash", &platform_util::MoveItemToTrash);
|
||||
dict.SetMethod("beep", &platform_util::Beep);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue