| 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::MessageBoxType message_box_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::MessageBoxType message_box_type() const { return message_box_type_; } |
| 72 string16 message_text() const { return message_text_; } | 72 string16 message_text() const { return message_text_; } |
| 73 string16 default_prompt_text() const { return default_prompt_text_; } | 73 string16 default_prompt_text() const { return default_prompt_text_; } |
| 74 bool display_suppress_checkbox() const { return display_suppress_checkbox_; } | 74 bool display_suppress_checkbox() const { return display_suppress_checkbox_; } |
| 75 bool is_before_unload_dialog() const { return is_before_unload_dialog_; } | 75 bool is_before_unload_dialog() const { return is_before_unload_dialog_; } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 // Notifies the delegate with the result of the dialog. | 78 // Notifies the delegate with the result of the dialog. |
| 79 void NotifyDelegate(bool success, const string16& prompt_text, | 79 void NotifyDelegate(bool success, const string16& prompt_text, |
| 80 bool suppress_js_messages); | 80 bool suppress_js_messages); |
| 81 | 81 |
| 82 // The extra Chrome-only data associated with the delegate_. | 82 // The extra Chrome-only data associated with the delegate_. |
| 83 ChromeJavaScriptDialogExtraData* extra_data_; | 83 ChromeJavaScriptDialogExtraData* extra_data_; |
| 84 | 84 |
| 85 // Information about the message box is held in the following variables. | 85 // Information about the message box is held in the following variables. |
| 86 int dialog_flags_; | 86 ui::MessageBoxType message_box_type_; |
| 87 string16 message_text_; | 87 string16 message_text_; |
| 88 string16 default_prompt_text_; | 88 string16 default_prompt_text_; |
| 89 bool display_suppress_checkbox_; | 89 bool display_suppress_checkbox_; |
| 90 bool is_before_unload_dialog_; | 90 bool is_before_unload_dialog_; |
| 91 IPC::Message* reply_msg_; | 91 IPC::Message* reply_msg_; |
| 92 | 92 |
| 93 // Used only for testing. Specifies alternative prompt text that should be | 93 // Used only for testing. Specifies alternative prompt text that should be |
| 94 // used when notifying the delegate, if |use_override_prompt_text_| is true. | 94 // used when notifying the delegate, if |use_override_prompt_text_| is true. |
| 95 string16 override_prompt_text_; | 95 string16 override_prompt_text_; |
| 96 bool use_override_prompt_text_; | 96 bool use_override_prompt_text_; |
| 97 | 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(JavaScriptAppModalDialog); | 98 DISALLOW_COPY_AND_ASSIGN(JavaScriptAppModalDialog); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JS_MODAL_DIALOG_H_ | 101 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JS_MODAL_DIALOG_H_ |
| OLD | NEW |