2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 17:49:37 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-03 21:03:26 +08:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 08:34:31 +01:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_
|
2013-05-03 21:03:26 +08:00
|
|
|
|
2024-01-10 23:23:35 +01:00
|
|
|
#include <optional>
|
2013-05-03 21:03:26 +08:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-02-03 12:43:42 +01:00
|
|
|
#include "base/functional/callback_forward.h"
|
2023-05-11 16:07:39 -04:00
|
|
|
#include "base/memory/raw_ptr_exclusion.h"
|
2019-06-14 08:26:25 -07:00
|
|
|
#include "ui/gfx/image/image_skia.h"
|
2015-01-05 15:08:42 -08:00
|
|
|
|
2013-05-03 21:03:26 +08:00
|
|
|
namespace electron {
|
|
|
|
|
2013-06-07 15:59:12 +08:00
|
|
|
class NativeWindow;
|
|
|
|
|
2019-05-03 20:11:41 +02:00
|
|
|
enum class MessageBoxType {
|
|
|
|
kNone = 0,
|
|
|
|
kInformation,
|
|
|
|
kWarning,
|
|
|
|
kError,
|
|
|
|
kQuestion,
|
2013-05-03 21:03:26 +08:00
|
|
|
};
|
|
|
|
|
2019-06-14 08:26:25 -07:00
|
|
|
struct MessageBoxSettings {
|
2023-05-11 16:07:39 -04:00
|
|
|
RAW_PTR_EXCLUSION electron::NativeWindow* parent_window = nullptr;
|
2019-06-14 08:26:25 -07:00
|
|
|
MessageBoxType type = electron::MessageBoxType::kNone;
|
|
|
|
std::vector<std::string> buttons;
|
2024-01-10 23:23:35 +01:00
|
|
|
std::optional<int> id;
|
2019-06-14 08:26:25 -07:00
|
|
|
int default_id;
|
|
|
|
int cancel_id;
|
2019-12-05 13:38:57 -08:00
|
|
|
bool no_link = false;
|
2019-06-14 08:26:25 -07:00
|
|
|
std::string title;
|
|
|
|
std::string message;
|
|
|
|
std::string detail;
|
|
|
|
std::string checkbox_label;
|
|
|
|
bool checkbox_checked = false;
|
|
|
|
gfx::ImageSkia icon;
|
2021-09-23 12:56:14 +02:00
|
|
|
int text_width = 0;
|
2019-06-14 08:26:25 -07:00
|
|
|
|
|
|
|
MessageBoxSettings();
|
|
|
|
MessageBoxSettings(const MessageBoxSettings&);
|
|
|
|
~MessageBoxSettings();
|
|
|
|
};
|
|
|
|
|
|
|
|
int ShowMessageBoxSync(const MessageBoxSettings& settings);
|
2013-09-22 17:11:09 +08:00
|
|
|
|
2019-03-12 11:06:59 -07:00
|
|
|
typedef base::OnceCallback<void(int code, bool checkbox_checked)>
|
|
|
|
MessageBoxCallback;
|
2013-05-03 21:03:26 +08:00
|
|
|
|
2019-06-14 08:26:25 -07:00
|
|
|
void ShowMessageBox(const MessageBoxSettings& settings,
|
2019-03-12 11:06:59 -07:00
|
|
|
MessageBoxCallback callback);
|
2013-09-22 17:11:09 +08:00
|
|
|
|
2021-07-15 07:59:27 +09:00
|
|
|
void CloseMessageBox(int id);
|
|
|
|
|
2014-11-05 16:04:39 +08:00
|
|
|
// Like ShowMessageBox with simplest settings, but safe to call at very early
|
|
|
|
// stage of application.
|
2021-03-16 12:18:45 -04:00
|
|
|
void ShowErrorBox(const std::u16string& title, const std::u16string& content);
|
2014-11-05 16:04:39 +08:00
|
|
|
|
2013-05-03 21:03:26 +08:00
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 08:34:31 +01:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_
|