feat: promisify dialog.showOpenDialog() (#16973)

* feat: promisify dialog.showOpenDialog()

* address feedback from review

* address feedback from review
This commit is contained in:
Shelley Vohr 2019-03-05 05:54:48 -08:00 committed by GitHub
parent 7936237677
commit e05985145b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 235 additions and 154 deletions

View file

@ -9,8 +9,11 @@
#include <utility>
#include <vector>
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/promise_util.h"
#include "base/callback_forward.h"
#include "base/files/file_path.h"
#include "native_mate/dictionary.h"
namespace atom {
class NativeWindow;
@ -34,20 +37,11 @@ enum FileDialogProperty {
};
#if defined(MAS_BUILD)
typedef base::Callback<void(bool result,
const std::vector<base::FilePath>& paths,
const std::vector<std::string>& bookmarkData)>
OpenDialogCallback;
typedef base::Callback<void(bool result,
const base::FilePath& path,
const std::string& bookmarkData)>
SaveDialogCallback;
#else
typedef base::Callback<void(bool result,
const std::vector<base::FilePath>& paths)>
OpenDialogCallback;
typedef base::Callback<void(bool result, const base::FilePath& path)>
SaveDialogCallback;
#endif
@ -70,11 +64,11 @@ struct DialogSettings {
~DialogSettings();
};
bool ShowOpenDialog(const DialogSettings& settings,
std::vector<base::FilePath>* paths);
bool ShowOpenDialogSync(const DialogSettings& settings,
std::vector<base::FilePath>* paths);
void ShowOpenDialog(const DialogSettings& settings,
const OpenDialogCallback& callback);
atom::util::Promise promise);
bool ShowSaveDialog(const DialogSettings& settings, base::FilePath* path);