OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_BASE_MESSAGE_BOX_FLAGS_H_ | 5 #ifndef UI_BASE_MESSAGE_BOX_FLAGS_H_ |
6 #define UI_BASE_MESSAGE_BOX_FLAGS_H_ | 6 #define UI_BASE_MESSAGE_BOX_FLAGS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | |
10 | |
11 namespace ui { | 9 namespace ui { |
12 | 10 |
13 // This class contains flags used to communicate the type of message box | 11 // Flags used to communicate the type of message box to show. E.g., the renderer |
14 // to show. E.g., the renderer can request the browser to show a | 12 // can request the browser to show a javascript alert or a javascript confirm |
15 // javascript alert or a javascript confirm message. | 13 // message. |
16 class MessageBoxFlags { | 14 enum MessageBoxFlags { |
17 public: | 15 MESSAGE_BOX_HAS_OK_BUTTON = 1 << 0, |
18 static const int kFlagHasOKButton = 0x1; | 16 MESSAGE_BOX_HAS_CANCEL_BUTTON = 1 << 1, |
19 static const int kFlagHasCancelButton = 0x2; | 17 MESSAGE_BOX_HAS_PROMPT_FIELD = 1 << 2, |
20 static const int kFlagHasPromptField = 0x4; | 18 MESSAGE_BOX_HAS_MESSAGE = 1 << 3, |
21 static const int kFlagHasMessage = 0x8; | |
22 | 19 |
23 // The following flag is used to indicate whether the message's alignment | 20 // The following flag is used to indicate whether the message's alignment |
24 // should be autodetected or inherited from Chrome UI. Callers should pass | 21 // should be autodetected or inherited from Chrome UI. Callers should pass |
25 // the correct flag based on the origin of the message. If the message is | 22 // the correct flag based on the origin of the message. If the message is |
26 // from a web page (such as the JavaScript alert message), its alignment and | 23 // from a web page (such as the JavaScript alert message), its alignment and |
27 // directionality are based on the first character with strong directionality | 24 // directionality are based on the first character with strong directionality |
28 // in the message. Chrome UI strings are localized string and therefore they | 25 // in the message. Chrome UI strings are localized string and therefore they |
29 // should have the same alignment and directionality as those of the Chrome | 26 // should have the same alignment and directionality as those of the Chrome |
30 // UI. For example, in RTL locales, even though some strings might begin with | 27 // UI. For example, in RTL locales, even though some strings might begin with |
31 // an English character, they should still be right aligned and be displayed | 28 // an English character, they should still be right aligned and be displayed |
32 // Right-To-Left. | 29 // Right-To-Left. |
33 // | 30 // |
34 // TODO(xji): If the message is from a web page, then the message | 31 // TODO(xji): If the message is from a web page, then the message |
35 // directionality should be determined based on the directionality of the web | 32 // directionality should be determined based on the directionality of the web |
36 // page. Please refer to http://crbug.com/7166 for more information. | 33 // page. Please refer to http://crbug.com/7166 for more information. |
37 static const int kAutoDetectAlignment = 0x10; | 34 MESSAGE_BOX_AUTO_DETECT_ALIGNMENT = 1 << 4, |
38 | 35 |
39 static const int kIsConfirmMessageBox = kFlagHasMessage | | 36 MESSAGE_BOX_IS_CONFIRM_DIALOG = MESSAGE_BOX_HAS_MESSAGE | |
sky
2011/11/12 00:11:55
The first 5 are appropriate for an enum, but the r
tfarina
2011/11/12 11:01:55
I really want to get rid of this class, really! I'
| |
40 kFlagHasOKButton | | 37 MESSAGE_BOX_HAS_OK_BUTTON | |
41 kFlagHasCancelButton; | 38 MESSAGE_BOX_HAS_CANCEL_BUTTON, |
42 static const int kIsJavascriptAlert = kFlagHasOKButton | kFlagHasMessage; | |
43 static const int kIsJavascriptConfirm = kIsJavascriptAlert | | |
44 kFlagHasCancelButton; | |
45 static const int kIsJavascriptPrompt = kIsJavascriptConfirm | | |
46 kFlagHasPromptField; | |
47 | 39 |
48 private: | 40 MESSAGE_BOX_IS_JAVASCRIPT_ALERT_DIALOG = MESSAGE_BOX_HAS_OK_BUTTON | |
49 DISALLOW_IMPLICIT_CONSTRUCTORS(MessageBoxFlags); | 41 MESSAGE_BOX_HAS_MESSAGE, |
42 | |
43 MESSAGE_BOX_IS_JAVASCRIPT_CONFIRM_DIALOG = | |
44 MESSAGE_BOX_IS_JAVASCRIPT_ALERT_DIALOG | MESSAGE_BOX_HAS_CANCEL_BUTTON, | |
45 | |
46 MESSAGE_BOX_IS_JAVASCRIPT_PROMPT_DIALOG = | |
47 MESSAGE_BOX_IS_JAVASCRIPT_CONFIRM_DIALOG | MESSAGE_BOX_HAS_PROMPT_FIELD | |
50 }; | 48 }; |
51 | 49 |
52 } // namespace ui | 50 } // namespace ui |
53 | 51 |
54 #endif // UI_BASE_MESSAGE_BOX_FLAGS_H_ | 52 #endif // UI_BASE_MESSAGE_BOX_FLAGS_H_ |
OLD | NEW |