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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_UI_MESSAGE_BOX_H_
|
|
|
|
#define SHELL_BROWSER_UI_MESSAGE_BOX_H_
|
2013-05-03 13:03:26 +00:00
|
|
|
|
|
|
|
#include <string>
|
2019-11-27 07:39:07 +00:00
|
|
|
#include <utility>
|
2013-05-03 13:03:26 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2013-09-22 09:11:09 +00:00
|
|
|
#include "base/callback_forward.h"
|
2019-06-14 15:26:25 +00:00
|
|
|
#include "ui/gfx/image/image_skia.h"
|
2015-01-05 23:08:42 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2013-05-03 13:03:26 +00:00
|
|
|
|
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-11-27 07:39:07 +00:00
|
|
|
using DialogResult = std::pair<int, bool>;
|
|
|
|
|
2019-06-14 15:26:25 +00:00
|
|
|
struct MessageBoxSettings {
|
2019-06-19 21:23:04 +00:00
|
|
|
electron::NativeWindow* parent_window = nullptr;
|
|
|
|
MessageBoxType type = electron::MessageBoxType::kNone;
|
2019-06-14 15:26:25 +00:00
|
|
|
std::vector<std::string> buttons;
|
|
|
|
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;
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2013-05-03 13:03:26 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_UI_MESSAGE_BOX_H_
|