OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_ | 5 #ifndef CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_ |
6 #define CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_ | 6 #define CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_ |
7 | 7 |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
10 | 10 |
11 namespace chrome { | 11 namespace chrome { |
12 | 12 |
13 enum MessageBoxResult { | 13 enum MessageBoxResult { |
14 MESSAGE_BOX_RESULT_NO = 0, // User chose NO or CANCEL. | 14 MESSAGE_BOX_RESULT_NO = 0, // User chose NO or CANCEL. |
15 MESSAGE_BOX_RESULT_YES = 1, // User chose YES or OK. | 15 MESSAGE_BOX_RESULT_YES = 1, // User chose YES or OK. |
16 | |
17 // User chose YES or OK and the checkbox was checked. | |
18 MESSAGE_BOX_RESULT_YES_CHECKED = 2, | |
19 | |
20 // User chose YES or OK and the checkbox was unchecked. | |
21 MESSAGE_BOX_RESULT_YES_NOT_CHECKED = 3, | |
Lei Zhang
2016/07/09 01:04:47
Can we just use MESSAGE_BOX_RESULT_YES instead?
afakhry
2016/07/11 16:47:45
Makes sense! This is definitely better indeed. Don
| |
16 }; | 22 }; |
17 | 23 |
18 enum MessageBoxType { | 24 enum MessageBoxType { |
19 MESSAGE_BOX_TYPE_WARNING, // Shows an OK button. | 25 MESSAGE_BOX_TYPE_WARNING, // Shows an OK button. |
20 MESSAGE_BOX_TYPE_QUESTION, // Shows YES and NO buttons. | 26 MESSAGE_BOX_TYPE_QUESTION, // Shows YES and NO buttons. |
21 }; | 27 }; |
22 | 28 |
23 // Shows a dialog box with the given |title| and |message|. If |parent| is | 29 // Shows a dialog box with the given |title| and |message|. If |parent| is |
24 // non-NULL, the box will be made modal to the |parent|, except on Mac, where it | 30 // non-NULL, the box will be made modal to the |parent|, except on Mac, where it |
25 // is always app-modal. | 31 // is always app-modal. |
26 // | 32 // |
27 // NOTE: In general, you should avoid this since it's usually poor UI. | 33 // NOTE: In general, you should avoid this since it's usually poor UI. |
28 // We have a variety of other surfaces such as app menu notifications and | 34 // We have a variety of other surfaces such as app menu notifications and |
29 // infobars; consult the UI leads for a recommendation. | 35 // infobars; consult the UI leads for a recommendation. |
30 void ShowWarningMessageBox(gfx::NativeWindow parent, | 36 void ShowWarningMessageBox(gfx::NativeWindow parent, |
31 const base::string16& title, | 37 const base::string16& title, |
32 const base::string16& message); | 38 const base::string16& message); |
33 | 39 |
40 // As above, but with a checkbox. Returns true if the checkbox was checked when | |
41 // the dialog was dismissed, false otherwise. | |
42 bool ShowWarningMessageBoxWithCheckbox(gfx::NativeWindow parent, | |
43 const base::string16& title, | |
44 const base::string16& message, | |
45 const base::string16& checkbox_text); | |
46 | |
34 // As above, but two buttons are displayed and the return value indicates which | 47 // As above, but two buttons are displayed and the return value indicates which |
35 // is chosen. | 48 // is chosen. |
36 MessageBoxResult ShowQuestionMessageBox(gfx::NativeWindow parent, | 49 MessageBoxResult ShowQuestionMessageBox(gfx::NativeWindow parent, |
37 const base::string16& title, | 50 const base::string16& title, |
38 const base::string16& message); | 51 const base::string16& message); |
39 | 52 |
40 // Shows a dialog box with the given |title| and |message|, and with two buttons | 53 // Shows a dialog box with the given |title| and |message|, and with two buttons |
41 // labeled with |yes_text| and |no_text|. If |parent| is non-NULL, the box will | 54 // labeled with |yes_text| and |no_text|. If |parent| is non-NULL, the box will |
42 // be made modal to the |parent|. (Aura only.) | 55 // be made modal to the |parent|. (Aura only.) |
43 // | 56 // |
44 // NOTE: In general, you should avoid this since it's usually poor UI. | 57 // NOTE: In general, you should avoid this since it's usually poor UI. |
45 // We have a variety of other surfaces such as app menu notifications and | 58 // We have a variety of other surfaces such as app menu notifications and |
46 // infobars; consult the UI leads for a recommendation. | 59 // infobars; consult the UI leads for a recommendation. |
47 MessageBoxResult ShowMessageBoxWithButtonText(gfx::NativeWindow parent, | 60 MessageBoxResult ShowMessageBoxWithButtonText(gfx::NativeWindow parent, |
48 const base::string16& title, | 61 const base::string16& title, |
49 const base::string16& message, | 62 const base::string16& message, |
50 const base::string16& yes_text, | 63 const base::string16& yes_text, |
51 const base::string16& no_text); | 64 const base::string16& no_text); |
52 | 65 |
53 } // namespace chrome | 66 } // namespace chrome |
54 | 67 |
55 #endif // CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_ | 68 #endif // CHROME_BROWSER_UI_SIMPLE_MESSAGE_BOX_H_ |
OLD | NEW |