refactor: simplify ShowSaveDialog, make consistent with ShowOpenDialog (#19924)

This commit is contained in:
Milan Burda 2019-08-26 13:12:09 +02:00 committed by Alexey Kuzmin
parent f6c523db13
commit 94c6b256de

View file

@ -64,16 +64,12 @@ class FileSelectHelper : public base::RefCounted<FileSelectHelper>,
void ShowSaveDialog(const file_dialog::DialogSettings& settings) { void ShowSaveDialog(const file_dialog::DialogSettings& settings) {
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Local<v8::Context> context = isolate->GetCurrentContext();
electron::util::Promise<mate::Dictionary> promise(isolate); electron::util::Promise<mate::Dictionary> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
auto callback = base::BindOnce(&FileSelectHelper::OnSaveDialogDone, this);
ignore_result(promise.Then(std::move(callback)));
file_dialog::ShowSaveDialog(settings, std::move(promise)); file_dialog::ShowSaveDialog(settings, std::move(promise));
ignore_result(handle->Then(
context,
v8::Local<v8::Function>::Cast(mate::ConvertToV8(
isolate,
base::BindOnce(&FileSelectHelper::OnSaveDialogDone, this)))));
} }
private: private: