electron/shell/browser/ui/file_dialog.h

83 lines
2.4 KiB
C
Raw Normal View History

// Copyright (c) 2013 GitHub, Inc.
2014-04-25 09:49:37 +00:00
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_UI_FILE_DIALOG_H_
#define ELECTRON_SHELL_BROWSER_UI_FILE_DIALOG_H_
#include <string>
#include <utility>
#include <vector>
#include "base/files/file_path.h"
#include "base/memory/raw_ptr_exclusion.h"
namespace electron {
class NativeWindow;
}
chore: more iwyu (#43063) * chore: iwyu shell/browser/electron_pdf_document_helper_client.h * chore: iwyu shell/browser/hid/electron_hid_delegate.h * chore: iwyu content/public/browser/web_contents.h * chore: iwyu shell/browser/usb/electron_usb_delegate.h * chore: iwyu shell/browser/browser_observer.h * chore: iwyu shell/browser/bluetooth/electron_bluetooth_delegate.h * chore: iwyu shell/browser/serial/electron_serial_delegate.h * chore: iwyu shell/browser/api/frame_subscriber.h * chore: iwyu mojo/public/cpp/bindings/ * chore: iwyu components/ * chore: iwyu extensions/ * chore: iwyu shell/common/gin_helper/ * chore: iwyu v8/ * chore: iwyu base/containers/linked_list.h * chore: iwyu shell/browser/native_window.h * chore: iwyu shell/browser/api/electron_api_base_window.h * chore: iwyu shell/common/node_includes.h * chore: iwyu gin/handle.h * chore: iwyu base/functional/callback.h * chore: iwyu ui/gfx/ * chore: iwyu content/public/browser/render_frame_host.h * fix: mac * fix: mac * fix: win * chore: iwyu base/files/file_path.h * chore: iwyu base/unguessable_token.h * chore: iwyu ui/display/screen.h * chore: iwyu chrome/browser/predictors/preconnect_manager.h * chore: iwyu base/observer_list_types.h * chore: iwyu content/public/browser/web_contents.h * chore: iwyu chrome/browser/devtools/devtools_eye_dropper.h * chore: iwyu shell/browser/ui/inspectable_web_contents.h * chore: iwyu content/public/browser/keyboard_event_processing_result.h * chore: iwyu net/cookies/canonical_cookie.h * chore: iwyu net/base/address_list.h * chore: iwyu net/cert/x509_certificate.h * chore: iwyu net/cookies/cookie_change_dispatcher.h * chore: iwyu net/dns/public/host_resolver_results.h * fix: mac * Revert "chore: iwyu net/cert/x509_certificate.h" This reverts commit 002896f71146e90f1e29e090a1d6eede48cee11e.
2024-07-29 17:42:57 +00:00
namespace gin_helper {
class Dictionary;
template <typename T>
class Promise;
} // namespace gin_helper
namespace file_dialog {
// <description, extensions>
2018-04-18 01:44:10 +00:00
typedef std::pair<std::string, std::vector<std::string>> Filter;
typedef std::vector<Filter> Filters;
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
FILE_DIALOG_DONT_ADD_TO_RECENT = 1 << 8, // Windows
};
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-08 01:32:58 +00:00
struct DialogSettings {
RAW_PTR_EXCLUSION electron::NativeWindow* parent_window = nullptr;
2017-02-08 01:32:58 +00:00
std::string title;
std::string message;
2017-02-08 01:32:58 +00:00
std::string button_label;
std::string name_field_label;
2017-02-08 01:32:58 +00:00
base::FilePath default_path;
Filters filters;
int properties = 0;
bool shows_tag_field = true;
bool force_detached = false;
bool security_scoped_bookmarks = false;
DialogSettings();
DialogSettings(const DialogSettings&);
~DialogSettings();
2017-02-08 01:32:58 +00:00
};
bool ShowOpenDialogSync(const DialogSettings& settings,
std::vector<base::FilePath>* paths);
2017-02-08 01:32:58 +00:00
void ShowOpenDialog(const DialogSettings& settings,
gin_helper::Promise<gin_helper::Dictionary> promise);
2013-09-23 11:22:36 +00:00
bool ShowSaveDialogSync(const DialogSettings& settings, base::FilePath* path);
2017-02-08 01:32:58 +00:00
void ShowSaveDialog(const DialogSettings& settings,
gin_helper::Promise<gin_helper::Dictionary> promise);
2013-09-23 12:08:32 +00:00
} // namespace file_dialog
#endif // ELECTRON_SHELL_BROWSER_UI_FILE_DIALOG_H_