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 CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JS_MODAL_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JS_MODAL_DIALOG_H_ |
6 #define CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JS_MODAL_DIALOG_H_ | 6 #define CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JS_MODAL_DIALOG_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... | |
34 bool suppress_javascript_messages_; | 34 bool suppress_javascript_messages_; |
35 }; | 35 }; |
36 | 36 |
37 // A controller + model class for JavaScript alert, confirm, prompt, and | 37 // A controller + model class for JavaScript alert, confirm, prompt, and |
38 // onbeforeunload dialog boxes. | 38 // onbeforeunload dialog boxes. |
39 class JavaScriptAppModalDialog : public AppModalDialog { | 39 class JavaScriptAppModalDialog : public AppModalDialog { |
40 public: | 40 public: |
41 JavaScriptAppModalDialog(content::JavaScriptDialogDelegate* delegate, | 41 JavaScriptAppModalDialog(content::JavaScriptDialogDelegate* delegate, |
42 ChromeJavaScriptDialogExtraData* extra_data, | 42 ChromeJavaScriptDialogExtraData* extra_data, |
43 const string16& title, | 43 const string16& title, |
44 int dialog_flags, | 44 ui::JavascriptMessageType javascript_message_type, |
45 const string16& message_text, | 45 const string16& message_text, |
46 const string16& default_prompt_text, | 46 const string16& default_prompt_text, |
47 bool display_suppress_checkbox, | 47 bool display_suppress_checkbox, |
48 bool is_before_unload_dialog, | 48 bool is_before_unload_dialog, |
49 IPC::Message* reply_msg); | 49 IPC::Message* reply_msg); |
50 virtual ~JavaScriptAppModalDialog(); | 50 virtual ~JavaScriptAppModalDialog(); |
51 | 51 |
52 // Overridden from AppModalDialog: | 52 // Overridden from AppModalDialog: |
53 virtual NativeAppModalDialog* CreateNativeDialog() OVERRIDE; | 53 virtual NativeAppModalDialog* CreateNativeDialog() OVERRIDE; |
54 virtual bool IsJavaScriptModalDialog() OVERRIDE; | 54 virtual bool IsJavaScriptModalDialog() OVERRIDE; |
55 virtual void Invalidate() OVERRIDE; | 55 virtual void Invalidate() OVERRIDE; |
56 virtual content::JavaScriptDialogDelegate* delegate() const OVERRIDE; | 56 virtual content::JavaScriptDialogDelegate* delegate() const OVERRIDE; |
57 | 57 |
58 // Callbacks from NativeDialog when the user accepts or cancels the dialog. | 58 // Callbacks from NativeDialog when the user accepts or cancels the dialog. |
59 void OnCancel(bool suppress_js_messages); | 59 void OnCancel(bool suppress_js_messages); |
60 void OnAccept(const string16& prompt_text, bool suppress_js_messages); | 60 void OnAccept(const string16& prompt_text, bool suppress_js_messages); |
61 | 61 |
62 // NOTE: This is only called under Views, and should be removed. Any critical | 62 // NOTE: This is only called under Views, and should be removed. Any critical |
63 // work should be done in OnCancel or OnAccept. See crbug.com/63732 for more. | 63 // work should be done in OnCancel or OnAccept. See crbug.com/63732 for more. |
64 void OnClose(); | 64 void OnClose(); |
65 | 65 |
66 // Used only for testing. The dialog will use the given text when notifying | 66 // Used only for testing. The dialog will use the given text when notifying |
67 // its delegate instead of whatever the UI reports. | 67 // its delegate instead of whatever the UI reports. |
68 void SetOverridePromptText(const string16& prompt_text); | 68 void SetOverridePromptText(const string16& prompt_text); |
69 | 69 |
70 // Accessors | 70 // Accessors |
71 int dialog_flags() const { return dialog_flags_; } | 71 ui::JavascriptMessageType javascript_message_type() const { |
72 return javascript_message_type_; | |
73 } | |
72 string16 message_text() const { return message_text_; } | 74 string16 message_text() const { return message_text_; } |
73 string16 default_prompt_text() const { return default_prompt_text_; } | 75 string16 default_prompt_text() const { return default_prompt_text_; } |
74 bool display_suppress_checkbox() const { return display_suppress_checkbox_; } | 76 bool display_suppress_checkbox() const { return display_suppress_checkbox_; } |
75 bool is_before_unload_dialog() const { return is_before_unload_dialog_; } | 77 bool is_before_unload_dialog() const { return is_before_unload_dialog_; } |
76 | 78 |
77 private: | 79 private: |
78 // Notifies the delegate with the result of the dialog. | 80 // Notifies the delegate with the result of the dialog. |
79 void NotifyDelegate(bool success, const string16& prompt_text, | 81 void NotifyDelegate(bool success, const string16& prompt_text, |
80 bool suppress_js_messages); | 82 bool suppress_js_messages); |
81 | 83 |
82 // The extra Chrome-only data associated with the delegate_. | 84 // The extra Chrome-only data associated with the delegate_. |
83 ChromeJavaScriptDialogExtraData* extra_data_; | 85 ChromeJavaScriptDialogExtraData* extra_data_; |
84 | 86 |
85 // Information about the message box is held in the following variables. | 87 // Information about the message box is held in the following variables. |
86 int dialog_flags_; | 88 ui::JavascriptMessageType javascript_message_type_; |
sky
2011/12/01 16:42:02
const
tfarina
2011/12/01 17:52:58
Done.
| |
87 string16 message_text_; | 89 string16 message_text_; |
88 string16 default_prompt_text_; | 90 string16 default_prompt_text_; |
89 bool display_suppress_checkbox_; | 91 bool display_suppress_checkbox_; |
90 bool is_before_unload_dialog_; | 92 bool is_before_unload_dialog_; |
91 IPC::Message* reply_msg_; | 93 IPC::Message* reply_msg_; |
92 | 94 |
93 // Used only for testing. Specifies alternative prompt text that should be | 95 // Used only for testing. Specifies alternative prompt text that should be |
94 // used when notifying the delegate, if |use_override_prompt_text_| is true. | 96 // used when notifying the delegate, if |use_override_prompt_text_| is true. |
95 string16 override_prompt_text_; | 97 string16 override_prompt_text_; |
96 bool use_override_prompt_text_; | 98 bool use_override_prompt_text_; |
97 | 99 |
98 DISALLOW_COPY_AND_ASSIGN(JavaScriptAppModalDialog); | 100 DISALLOW_COPY_AND_ASSIGN(JavaScriptAppModalDialog); |
99 }; | 101 }; |
100 | 102 |
101 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JS_MODAL_DIALOG_H_ | 103 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JS_MODAL_DIALOG_H_ |
OLD | NEW |