OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_VIEW_H_ | 5 #ifndef CHROME_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_VIEW_H_ |
6 #define CHROME_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_VIEW_H_ | 6 #define CHROME_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_VIEW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/task.h" | 10 #include "base/task.h" |
11 #include "chrome/views/controls/image_view.h" | 11 #include "chrome/views/controls/image_view.h" |
12 #include "chrome/views/controls/label.h" | 12 #include "chrome/views/controls/label.h" |
13 #include "chrome/views/controls/text_field.h" | 13 #include "chrome/views/controls/text_field.h" |
14 #include "chrome/views/view.h" | 14 #include "chrome/views/view.h" |
15 | 15 |
16 namespace views { | 16 namespace views { |
17 class Checkbox; | 17 class Checkbox; |
18 } | 18 } |
19 | 19 |
20 // This class displays the contents of a message box. It is intended for use | 20 // This class displays the contents of a message box. It is intended for use |
21 // within a constrained window, and has options for a message, prompt, OK | 21 // within a constrained window, and has options for a message, prompt, OK |
22 // and Cancel buttons. | 22 // and Cancel buttons. |
23 class MessageBoxView : public views::View { | 23 class MessageBoxView : public views::View { |
24 public: | 24 public: |
25 // flags | |
26 static const int kFlagHasOKButton = 0x1; | |
27 static const int kFlagHasCancelButton = 0x2; | |
28 static const int kFlagHasPromptField = 0x4; | |
29 static const int kFlagHasMessage = 0x8; | |
30 | |
31 // The following flag is used to indicate whether the message's alignment | |
32 // should be autodetected or inherited from Chrome UI. Callers should pass | |
33 // the correct flag based on the origin of the message. If the message is | |
34 // from a web page (such as the JavaScript alert message), its alignment and | |
35 // directionality are based on the first character with strong directionality | |
36 // in the message. Chrome UI strings are localized string and therefore they | |
37 // should have the same alignment and directionality as those of the Chrome | |
38 // UI. For example, in RTL locales, even though some strings might begin with | |
39 // an English character, they should still be right aligned and be displayed | |
40 // Right-To-Left. | |
41 // | |
42 // TODO(xji): If the message is from a web page, then the message | |
43 // directionality should be determined based on the directionality of the web | |
44 // page. Please refer to http://crbug.com/7166 for more information. | |
45 static const int kAutoDetectAlignment = 0x10; | |
46 | |
47 static const int kIsConfirmMessageBox = kFlagHasMessage | | |
48 kFlagHasOKButton | | |
49 kFlagHasCancelButton; | |
50 static const int kIsJavascriptAlert = kFlagHasOKButton | kFlagHasMessage; | |
51 static const int kIsJavascriptConfirm = kIsJavascriptAlert | | |
52 kFlagHasCancelButton; | |
53 static const int kIsJavascriptPrompt = kIsJavascriptConfirm | | |
54 kFlagHasPromptField; | |
55 | |
56 MessageBoxView(int dialog_flags, | 25 MessageBoxView(int dialog_flags, |
57 const std::wstring& message, | 26 const std::wstring& message, |
58 const std::wstring& default_prompt, | 27 const std::wstring& default_prompt, |
59 int message_width); | 28 int message_width); |
60 | 29 |
61 MessageBoxView(int dialog_flags, | 30 MessageBoxView(int dialog_flags, |
62 const std::wstring& message, | 31 const std::wstring& message, |
63 const std::wstring& default_prompt); | 32 const std::wstring& default_prompt); |
64 | 33 |
65 // Returns the text box. | 34 // Returns the text box. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 82 |
114 // Maximum width of the message label. | 83 // Maximum width of the message label. |
115 int message_width_; | 84 int message_width_; |
116 | 85 |
117 ScopedRunnableMethodFactory<MessageBoxView> focus_grabber_factory_; | 86 ScopedRunnableMethodFactory<MessageBoxView> focus_grabber_factory_; |
118 | 87 |
119 DISALLOW_EVIL_CONSTRUCTORS(MessageBoxView); | 88 DISALLOW_EVIL_CONSTRUCTORS(MessageBoxView); |
120 }; | 89 }; |
121 | 90 |
122 #endif // CHROME_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_VIEW_H_ | 91 #endif // CHROME_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_VIEW_H_ |
OLD | NEW |