message_box.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 SHELL_BROWSER_UI_MESSAGE_BOX_H_
  5. #define SHELL_BROWSER_UI_MESSAGE_BOX_H_
  6. #include <string>
  7. #include <utility>
  8. #include <vector>
  9. #include "base/callback_forward.h"
  10. #include "base/strings/string16.h"
  11. #include "ui/gfx/image/image_skia.h"
  12. namespace electron {
  13. class NativeWindow;
  14. enum class MessageBoxType {
  15. kNone = 0,
  16. kInformation,
  17. kWarning,
  18. kError,
  19. kQuestion,
  20. };
  21. using DialogResult = std::pair<int, bool>;
  22. struct MessageBoxSettings {
  23. electron::NativeWindow* parent_window = nullptr;
  24. MessageBoxType type = electron::MessageBoxType::kNone;
  25. std::vector<std::string> buttons;
  26. int default_id;
  27. int cancel_id;
  28. bool no_link = false;
  29. std::string title;
  30. std::string message;
  31. std::string detail;
  32. std::string checkbox_label;
  33. bool checkbox_checked = false;
  34. gfx::ImageSkia icon;
  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. // Like ShowMessageBox with simplest settings, but safe to call at very early
  45. // stage of application.
  46. void ShowErrorBox(const base::string16& title, const base::string16& content);
  47. } // namespace electron
  48. #endif // SHELL_BROWSER_UI_MESSAGE_BOX_H_