2014-10-31 12:17:05 -06:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 03:49:37 -06:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-20 07:46:43 -06:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_FILE_DIALOG_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_FILE_DIALOG_H_
|
2013-05-20 07:46:43 -06:00
|
|
|
|
|
|
|
#include <string>
|
2014-08-05 22:44:02 -06:00
|
|
|
#include <utility>
|
2013-05-20 07:46:43 -06:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/files/file_path.h"
|
2023-05-11 14:07:39 -06:00
|
|
|
#include "base/memory/raw_ptr_exclusion.h"
|
2019-09-08 09:10:18 -06:00
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
2019-11-01 00:10:32 -06:00
|
|
|
#include "shell/common/gin_helper/promise.h"
|
2013-05-20 07:46:43 -06:00
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
namespace electron {
|
2013-05-20 07:46:43 -06:00
|
|
|
class NativeWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace file_dialog {
|
|
|
|
|
2014-08-05 22:44:02 -06:00
|
|
|
// <description, extensions>
|
2018-04-17 19:44:10 -06:00
|
|
|
typedef std::pair<std::string, std::vector<std::string>> Filter;
|
2014-08-05 22:44:02 -06:00
|
|
|
typedef std::vector<Filter> Filters;
|
|
|
|
|
2019-08-13 14:40:07 -06:00
|
|
|
enum OpenFileDialogProperty {
|
|
|
|
OPEN_DIALOG_OPEN_FILE = 1 << 0,
|
|
|
|
OPEN_DIALOG_OPEN_DIRECTORY = 1 << 1,
|
|
|
|
OPEN_DIALOG_MULTI_SELECTIONS = 1 << 2,
|
|
|
|
OPEN_DIALOG_CREATE_DIRECTORY = 1 << 3, // macOS
|
|
|
|
OPEN_DIALOG_SHOW_HIDDEN_FILES = 1 << 4,
|
|
|
|
OPEN_DIALOG_PROMPT_TO_CREATE = 1 << 5, // Windows
|
|
|
|
OPEN_DIALOG_NO_RESOLVE_ALIASES = 1 << 6, // macOS
|
|
|
|
OPEN_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 7, // macOS
|
2019-08-13 09:48:22 -06:00
|
|
|
FILE_DIALOG_DONT_ADD_TO_RECENT = 1 << 8, // Windows
|
2013-05-20 07:46:43 -06:00
|
|
|
};
|
|
|
|
|
2019-08-13 14:40:07 -06:00
|
|
|
enum SaveFileDialogProperty {
|
|
|
|
SAVE_DIALOG_CREATE_DIRECTORY = 1 << 0,
|
|
|
|
SAVE_DIALOG_SHOW_HIDDEN_FILES = 1 << 1,
|
|
|
|
SAVE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 2, // macOS
|
|
|
|
SAVE_DIALOG_SHOW_OVERWRITE_CONFIRMATION = 1 << 3, // Linux
|
|
|
|
SAVE_DIALOG_DONT_ADD_TO_RECENT = 1 << 4, // Windows
|
|
|
|
};
|
|
|
|
|
2017-02-07 18:32:58 -07:00
|
|
|
struct DialogSettings {
|
2023-05-11 14:07:39 -06:00
|
|
|
RAW_PTR_EXCLUSION electron::NativeWindow* parent_window = nullptr;
|
2017-02-07 18:32:58 -07:00
|
|
|
std::string title;
|
2017-02-09 12:25:05 -07:00
|
|
|
std::string message;
|
2017-02-07 18:32:58 -07:00
|
|
|
std::string button_label;
|
2017-02-09 12:25:05 -07:00
|
|
|
std::string name_field_label;
|
2017-02-07 18:32:58 -07:00
|
|
|
base::FilePath default_path;
|
|
|
|
Filters filters;
|
|
|
|
int properties = 0;
|
2017-02-09 12:25:05 -07:00
|
|
|
bool shows_tag_field = true;
|
2017-11-02 15:50:04 -06:00
|
|
|
bool force_detached = false;
|
2018-02-12 11:25:06 -07:00
|
|
|
bool security_scoped_bookmarks = false;
|
2018-04-17 17:37:22 -06:00
|
|
|
|
|
|
|
DialogSettings();
|
2018-06-25 14:30:00 -06:00
|
|
|
DialogSettings(const DialogSettings&);
|
2018-04-17 17:37:22 -06:00
|
|
|
~DialogSettings();
|
2017-02-07 18:32:58 -07:00
|
|
|
};
|
|
|
|
|
2019-03-05 06:54:48 -07:00
|
|
|
bool ShowOpenDialogSync(const DialogSettings& settings,
|
|
|
|
std::vector<base::FilePath>* paths);
|
2013-05-20 07:46:43 -06:00
|
|
|
|
2017-02-07 18:32:58 -07:00
|
|
|
void ShowOpenDialog(const DialogSettings& settings,
|
2019-11-01 00:10:32 -06:00
|
|
|
gin_helper::Promise<gin_helper::Dictionary> promise);
|
2013-09-23 05:22:36 -06:00
|
|
|
|
2019-03-05 14:48:20 -07:00
|
|
|
bool ShowSaveDialogSync(const DialogSettings& settings, base::FilePath* path);
|
2013-05-20 07:46:43 -06:00
|
|
|
|
2017-02-07 18:32:58 -07:00
|
|
|
void ShowSaveDialog(const DialogSettings& settings,
|
2019-11-01 00:10:32 -06:00
|
|
|
gin_helper::Promise<gin_helper::Dictionary> promise);
|
2013-09-23 06:08:32 -06:00
|
|
|
|
2013-05-20 07:46:43 -06:00
|
|
|
} // namespace file_dialog
|
|
|
|
|
2021-11-22 00:34:31 -07:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_FILE_DIALOG_H_
|