feat: add signal option to dialog.showMessageBox (#26102)

* mac: add dialog.closeMessageBox API

* win: Implement dialog.closeMessageBox

* mac: Return cancelId with closeMessageBox

* gtk: Implement dialog.closeMessageBox

* win: Fix 32bit build

* win: Reduce the scope of lock

* fix: Build error after rebase

* feat: Use AbortSignal to close message box

* chore: silently handle duplicate ID

* win: Add more notes about the threads

* chore: apply reviews

* fix: base::NoDestructor should be warpped in function

* chore: fix style on windows
This commit is contained in:
Cheng Zhao 2021-07-15 07:59:27 +09:00 committed by GitHub
parent 4b780f9770
commit 05ba6359d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 276 additions and 24 deletions

View file

@ -6,10 +6,10 @@
#define SHELL_BROWSER_UI_MESSAGE_BOX_H_
#include <string>
#include <utility>
#include <vector>
#include "base/callback_forward.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/image/image_skia.h"
namespace electron {
@ -24,12 +24,11 @@ enum class MessageBoxType {
kQuestion,
};
using DialogResult = std::pair<int, bool>;
struct MessageBoxSettings {
electron::NativeWindow* parent_window = nullptr;
MessageBoxType type = electron::MessageBoxType::kNone;
std::vector<std::string> buttons;
absl::optional<int> id;
int default_id;
int cancel_id;
bool no_link = false;
@ -53,6 +52,8 @@ typedef base::OnceCallback<void(int code, bool checkbox_checked)>
void ShowMessageBox(const MessageBoxSettings& settings,
MessageBoxCallback callback);
void CloseMessageBox(int id);
// Like ShowMessageBox with simplest settings, but safe to call at very early
// stage of application.
void ShowErrorBox(const std::u16string& title, const std::u16string& content);