blob: ef8a75b1133dc4909c37e4567b10ed75223a4c90 [file] [log] [blame]
[email protected]5c61cc92012-04-23 02:00:391// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]80772ed2011-08-09 21:11:382// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]b50892c5f2012-05-13 07:34:145#ifndef CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_
6#define CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_
[email protected]80772ed2011-08-09 21:11:387
xiyuan24043672017-06-14 15:17:298#include "base/callback_forward.h"
kjellander2befbdd2016-11-02 14:09:169#include "base/compiler_specific.h"
[email protected]f92d6582013-06-10 22:02:3610#include "base/strings/string16.h"
[email protected]80772ed2011-08-09 21:11:3811#include "ui/gfx/native_widget_types.h"
12
[email protected]d33220292012-07-04 01:41:2713namespace chrome {
[email protected]80772ed2011-08-09 21:11:3814
[email protected]5da155e2012-05-26 16:31:1615enum MessageBoxResult {
afakhry7c9abe72016-08-05 17:33:1916 // User chose NO or CANCEL. If there's a checkbox, then the checkbox was
17 // unchecked.
18 MESSAGE_BOX_RESULT_NO = 0,
19
20 // User chose YES or OK. If there's a checkbox, then the checkbox was checked.
21 MESSAGE_BOX_RESULT_YES = 1,
Elly Fong-Jones165afb92017-06-29 18:43:2822
23 // Message box was displayed asynchronously and is pending a real result,
24 // which will be delivered via callback.
25 MESSAGE_BOX_RESULT_DEFERRED = 2,
[email protected]5da155e2012-05-26 16:31:1626};
27
[email protected]d1f48ef52012-05-13 19:34:2128enum MessageBoxType {
[email protected]f8ef7162013-11-22 01:56:4129 MESSAGE_BOX_TYPE_WARNING, // Shows an OK button.
30 MESSAGE_BOX_TYPE_QUESTION, // Shows YES and NO buttons.
[email protected]d1f48ef52012-05-13 19:34:2131};
32
[email protected]5da155e2012-05-26 16:31:1633// Shows a dialog box with the given |title| and |message|. If |parent| is
34// non-NULL, the box will be made modal to the |parent|, except on Mac, where it
[email protected]24ced7dc02013-04-04 08:32:3935// is always app-modal.
[email protected]5da155e2012-05-26 16:31:1636//
37// NOTE: In general, you should avoid this since it's usually poor UI.
tfarina917cff5e2015-10-31 01:16:3838// We have a variety of other surfaces such as app menu notifications and
[email protected]5da155e2012-05-26 16:31:1639// infobars; consult the UI leads for a recommendation.
estadee16f96ed2016-03-07 22:57:0540void ShowWarningMessageBox(gfx::NativeWindow parent,
41 const base::string16& title,
42 const base::string16& message);
43
xiyuan24043672017-06-14 15:17:2944// As above, but shows the dialog box asynchronously with a checkbox.
45// |callback| will be invoked after the dialog is dismissed. It is invoked with
46// true if the checkbox is checked and false otherwise.
47void ShowWarningMessageBoxWithCheckbox(
48 gfx::NativeWindow parent,
49 const base::string16& title,
50 const base::string16& message,
51 const base::string16& checkbox_text,
52 base::OnceCallback<void(bool checked)> callback);
afakhry7c9abe72016-08-05 17:33:1953
estadee16f96ed2016-03-07 22:57:0554// As above, but two buttons are displayed and the return value indicates which
55// is chosen.
56MessageBoxResult ShowQuestionMessageBox(gfx::NativeWindow parent,
57 const base::string16& title,
58 const base::string16& message);
[email protected]80772ed2011-08-09 21:11:3859
[email protected]f8ef7162013-11-22 01:56:4160// Shows a dialog box with the given |title| and |message|, and with two buttons
61// labeled with |yes_text| and |no_text|. If |parent| is non-NULL, the box will
62// be made modal to the |parent|. (Aura only.)
63//
64// NOTE: In general, you should avoid this since it's usually poor UI.
tfarina917cff5e2015-10-31 01:16:3865// We have a variety of other surfaces such as app menu notifications and
[email protected]f8ef7162013-11-22 01:56:4166// infobars; consult the UI leads for a recommendation.
67MessageBoxResult ShowMessageBoxWithButtonText(gfx::NativeWindow parent,
[email protected]dcd0249872013-12-06 23:58:4568 const base::string16& title,
69 const base::string16& message,
70 const base::string16& yes_text,
71 const base::string16& no_text);
[email protected]f8ef7162013-11-22 01:56:4172
kjellander2befbdd2016-11-02 14:09:1673// Closes the current message box, if any, accepting or declining based on
74// |accept|. Returns whether there was a message box showing.
75bool CloseMessageBoxForTest(bool accept) WARN_UNUSED_RESULT;
76
[email protected]d33220292012-07-04 01:41:2777} // namespace chrome
[email protected]80772ed2011-08-09 21:11:3878
[email protected]b50892c5f2012-05-13 07:34:1479#endif // CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_