message_box.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef REMOTING_HOST_CHROMEOS_MESSAGE_BOX_H_
  5. #define REMOTING_HOST_CHROMEOS_MESSAGE_BOX_H_
  6. #include <string>
  7. #include "base/callback_helpers.h"
  8. #include "base/threading/thread_checker.h"
  9. #include "ui/base/ui_base_types.h"
  10. namespace gfx {
  11. class ImageSkia;
  12. } // namespace gfx
  13. namespace remoting {
  14. // Overview:
  15. // Shows a system modal message box with OK and cancel buttons. This class
  16. // is not thread-safe, it must be called on the UI thread of the browser
  17. // process. Destroy the instance to hide the message box.
  18. class MessageBox {
  19. public:
  20. enum Result { OK, CANCEL };
  21. // ResultCallback will be invoked with Result::Cancel if the user closes the
  22. // MessageBox without clicking on any buttons.
  23. typedef base::OnceCallback<void(Result)> ResultCallback;
  24. MessageBox(const std::u16string& title_label,
  25. const std::u16string& message_label,
  26. const std::u16string& ok_label,
  27. const std::u16string& cancel_label,
  28. ResultCallback result_callback);
  29. MessageBox(const MessageBox&) = delete;
  30. MessageBox& operator=(const MessageBox&) = delete;
  31. ~MessageBox();
  32. void Show();
  33. private:
  34. class Core;
  35. Core* core_;
  36. base::ThreadChecker thread_checker_;
  37. };
  38. } // namespace remoting
  39. #endif // REMOTING_HOST_CHROMEOS_MESSAGE_BOX_H_