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