message_box.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_
  5. #define ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_
  6. #include <string>
  7. #include <vector>
  8. #include "base/callback_forward.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. #include "ui/gfx/image/image_skia.h"
  11. namespace electron {
  12. class NativeWindow;
  13. enum class MessageBoxType {
  14. kNone = 0,
  15. kInformation,
  16. kWarning,
  17. kError,
  18. kQuestion,
  19. };
  20. struct MessageBoxSettings {
  21. electron::NativeWindow* parent_window = nullptr;
  22. MessageBoxType type = electron::MessageBoxType::kNone;
  23. std::vector<std::string> buttons;
  24. absl::optional<int> id;
  25. int default_id;
  26. int cancel_id;
  27. bool no_link = false;
  28. std::string title;
  29. std::string message;
  30. std::string detail;
  31. std::string checkbox_label;
  32. bool checkbox_checked = false;
  33. gfx::ImageSkia icon;
  34. int text_width = 0;
  35. MessageBoxSettings();
  36. MessageBoxSettings(const MessageBoxSettings&);
  37. ~MessageBoxSettings();
  38. };
  39. int ShowMessageBoxSync(const MessageBoxSettings& settings);
  40. typedef base::OnceCallback<void(int code, bool checkbox_checked)>
  41. MessageBoxCallback;
  42. void ShowMessageBox(const MessageBoxSettings& settings,
  43. MessageBoxCallback callback);
  44. void CloseMessageBox(int id);
  45. // Like ShowMessageBox with simplest settings, but safe to call at very early
  46. // stage of application.
  47. void ShowErrorBox(const std::u16string& title, const std::u16string& content);
  48. } // namespace electron
  49. #endif // ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_