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_APP_MODAL_DIALOGS_JAVASCRIPT_APP_MODAL_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JAVASCRIPT_APP_MODAL_DIALOG_H_ |
6 #define CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JAVASCRIPT_APP_MODAL_DIALOG_H_ | 6 #define CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JAVASCRIPT_APP_MODAL_DIALOG_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 11 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
12 #include "content/public/browser/javascript_dialogs.h" | 12 #include "content/public/browser/javascript_dialog_manager.h" |
13 | 13 |
14 // Extra data for JavaScript dialogs to add Chrome-only features. | 14 // Extra data for JavaScript dialogs to add Chrome-only features. |
15 class ChromeJavaScriptDialogExtraData { | 15 class ChromeJavaScriptDialogExtraData { |
16 public: | 16 public: |
17 ChromeJavaScriptDialogExtraData(); | 17 ChromeJavaScriptDialogExtraData(); |
18 | 18 |
19 // The time that the last JavaScript dialog was dismissed. | 19 // The time that the last JavaScript dialog was dismissed. |
20 base::TimeTicks last_javascript_message_dismissal_; | 20 base::TimeTicks last_javascript_message_dismissal_; |
21 | 21 |
22 // True if the user has decided to block future JavaScript dialogs. | 22 // True if the user has decided to block future JavaScript dialogs. |
23 bool suppress_javascript_messages_; | 23 bool suppress_javascript_messages_; |
24 }; | 24 }; |
25 | 25 |
26 // A controller + model class for JavaScript alert, confirm, prompt, and | 26 // A controller + model class for JavaScript alert, confirm, prompt, and |
27 // onbeforeunload dialog boxes. | 27 // onbeforeunload dialog boxes. |
28 class JavaScriptAppModalDialog : public AppModalDialog { | 28 class JavaScriptAppModalDialog : public AppModalDialog { |
29 public: | 29 public: |
30 JavaScriptAppModalDialog( | 30 JavaScriptAppModalDialog( |
31 content::WebContents* web_contents, | 31 content::WebContents* web_contents, |
32 ChromeJavaScriptDialogExtraData* extra_data, | 32 ChromeJavaScriptDialogExtraData* extra_data, |
33 const string16& title, | 33 const string16& title, |
34 content::JavaScriptMessageType javascript_message_type, | 34 content::JavaScriptMessageType javascript_message_type, |
35 const string16& message_text, | 35 const string16& message_text, |
36 const string16& default_prompt_text, | 36 const string16& default_prompt_text, |
37 bool display_suppress_checkbox, | 37 bool display_suppress_checkbox, |
38 bool is_before_unload_dialog, | 38 bool is_before_unload_dialog, |
39 bool is_reload, | 39 bool is_reload, |
40 const content::JavaScriptDialogCreator::DialogClosedCallback& callback); | 40 const content::JavaScriptDialogManager::DialogClosedCallback& callback); |
41 virtual ~JavaScriptAppModalDialog(); | 41 virtual ~JavaScriptAppModalDialog(); |
42 | 42 |
43 // Overridden from AppModalDialog: | 43 // Overridden from AppModalDialog: |
44 virtual NativeAppModalDialog* CreateNativeDialog() OVERRIDE; | 44 virtual NativeAppModalDialog* CreateNativeDialog() OVERRIDE; |
45 virtual bool IsJavaScriptModalDialog() OVERRIDE; | 45 virtual bool IsJavaScriptModalDialog() OVERRIDE; |
46 virtual void Invalidate() OVERRIDE; | 46 virtual void Invalidate() OVERRIDE; |
47 | 47 |
48 // Callbacks from NativeDialog when the user accepts or cancels the dialog. | 48 // Callbacks from NativeDialog when the user accepts or cancels the dialog. |
49 void OnCancel(bool suppress_js_messages); | 49 void OnCancel(bool suppress_js_messages); |
50 void OnAccept(const string16& prompt_text, bool suppress_js_messages); | 50 void OnAccept(const string16& prompt_text, bool suppress_js_messages); |
(...skipping 25 matching lines...) Expand all Loading... |
76 ChromeJavaScriptDialogExtraData* extra_data_; | 76 ChromeJavaScriptDialogExtraData* extra_data_; |
77 | 77 |
78 // Information about the message box is held in the following variables. | 78 // Information about the message box is held in the following variables. |
79 const content::JavaScriptMessageType javascript_message_type_; | 79 const content::JavaScriptMessageType javascript_message_type_; |
80 string16 message_text_; | 80 string16 message_text_; |
81 string16 default_prompt_text_; | 81 string16 default_prompt_text_; |
82 bool display_suppress_checkbox_; | 82 bool display_suppress_checkbox_; |
83 bool is_before_unload_dialog_; | 83 bool is_before_unload_dialog_; |
84 bool is_reload_; | 84 bool is_reload_; |
85 | 85 |
86 content::JavaScriptDialogCreator::DialogClosedCallback callback_; | 86 content::JavaScriptDialogManager::DialogClosedCallback callback_; |
87 | 87 |
88 // Used only for testing. Specifies alternative prompt text that should be | 88 // Used only for testing. Specifies alternative prompt text that should be |
89 // used when notifying the delegate, if |use_override_prompt_text_| is true. | 89 // used when notifying the delegate, if |use_override_prompt_text_| is true. |
90 string16 override_prompt_text_; | 90 string16 override_prompt_text_; |
91 bool use_override_prompt_text_; | 91 bool use_override_prompt_text_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(JavaScriptAppModalDialog); | 93 DISALLOW_COPY_AND_ASSIGN(JavaScriptAppModalDialog); |
94 }; | 94 }; |
95 | 95 |
96 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JAVASCRIPT_APP_MODAL_DIALOG_H_ | 96 #endif // CHROME_BROWSER_UI_APP_MODAL_DIALOGS_JAVASCRIPT_APP_MODAL_DIALOG_H_ |
OLD | NEW |