| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_APP_MODAL_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_APP_MODAL_DIALOG_H_ |
| 6 #define CHROME_BROWSER_APP_MODAL_DIALOG_H_ | 6 #define CHROME_BROWSER_APP_MODAL_DIALOG_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/common/notification_observer.h" | 11 #include "chrome/common/notification_observer.h" |
| 12 #include "chrome/common/notification_registrar.h" | 12 #include "chrome/common/notification_registrar.h" |
| 13 | 13 |
| 14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 15 class JavascriptMessageBoxDialog; | 15 class JavascriptMessageBoxDialog; |
| 16 typedef JavascriptMessageBoxDialog* NativeDialog; | 16 typedef JavascriptMessageBoxDialog* NativeDialog; |
| 17 #elif defined(OS_LINUX) | 17 #elif defined(OS_LINUX) |
| 18 typedef struct _GtkWidget GtkWidget; | 18 typedef struct _GtkWidget GtkWidget; |
| 19 typedef GtkWidget* NativeDialog; | 19 typedef GtkWidget* NativeDialog; |
| 20 #elif defined(OS_MACOSX) | 20 #elif defined(OS_MACOSX) |
| 21 typedef void* NativeDialog; | 21 typedef void* NativeDialog; |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 class TabContents; | 24 class JavaScriptMessageBoxClient; |
| 25 namespace IPC { | 25 namespace IPC { |
| 26 class Message; | 26 class Message; |
| 27 } | 27 } |
| 28 | 28 |
| 29 // A controller+model class for javascript alert, confirm, prompt, and | 29 // A controller+model class for javascript alert, confirm, prompt, and |
| 30 // onbeforeunload dialog boxes. |NativeDialog| is a platform specific | 30 // onbeforeunload dialog boxes. |NativeDialog| is a platform specific |
| 31 // view. | 31 // view. |
| 32 class AppModalDialog : public NotificationObserver { | 32 class AppModalDialog : public NotificationObserver { |
| 33 public: | 33 public: |
| 34 // A union of data necessary to determine the type of message box to | 34 // A union of data necessary to determine the type of message box to |
| 35 // show. |dialog_flags| is a MessageBox flag. | 35 // show. |dialog_flags| is a MessageBox flag. |
| 36 AppModalDialog(TabContents* tab_contents, | 36 AppModalDialog(JavaScriptMessageBoxClient* client, |
| 37 const std::wstring& title, | 37 const std::wstring& title, |
| 38 int dialog_flags, | 38 int dialog_flags, |
| 39 const std::wstring& message_text, | 39 const std::wstring& message_text, |
| 40 const std::wstring& default_prompt_text, | 40 const std::wstring& default_prompt_text, |
| 41 bool display_suppress_checkbox, | 41 bool display_suppress_checkbox, |
| 42 bool is_before_unload_dialog, | 42 bool is_before_unload_dialog, |
| 43 IPC::Message* reply_msg); | 43 IPC::Message* reply_msg); |
| 44 ~AppModalDialog(); | 44 ~AppModalDialog(); |
| 45 | 45 |
| 46 // Called by the app modal window queue when it is time to show this window. | 46 // Called by the app modal window queue when it is time to show this window. |
| 47 void ShowModalDialog(); | 47 void ShowModalDialog(); |
| 48 | 48 |
| 49 ///////////////////////////////////////////////////////////////////////////// | 49 ///////////////////////////////////////////////////////////////////////////// |
| 50 // The following methods are platform specific and should be implemented in | 50 // The following methods are platform specific and should be implemented in |
| 51 // the platform specific .cc files. | 51 // the platform specific .cc files. |
| 52 // Create the platform specific NativeDialog and display it. When the | 52 // Create the platform specific NativeDialog and display it. When the |
| 53 // NativeDialog is closed, it should call OnAccept or OnCancel to notify the | 53 // NativeDialog is closed, it should call OnAccept or OnCancel to notify the |
| 54 // renderer of the user's action. The NativeDialog is also expected to | 54 // renderer of the user's action. The NativeDialog is also expected to |
| 55 // delete the AppModalDialog associated with it. | 55 // delete the AppModalDialog associated with it. |
| 56 void CreateAndShowDialog(); | 56 void CreateAndShowDialog(); |
| 57 | 57 |
| 58 // Close the dialog if it is showing. | 58 // Close the dialog if it is showing. |
| 59 void CloseModalDialog(); | 59 void CloseModalDialog(); |
| 60 | 60 |
| 61 // Called by the app modal window queue to activate the window. | 61 // Called by the app modal window queue to activate the window. |
| 62 void ActivateModalDialog(); | 62 void ActivateModalDialog(); |
| 63 | 63 |
| 64 ///////////////////////////////////////////////////////////////////////////// | 64 ///////////////////////////////////////////////////////////////////////////// |
| 65 // Getters so NativeDialog can get information about the message box. | 65 // Getters so NativeDialog can get information about the message box. |
| 66 TabContents* tab_contents() { | 66 JavaScriptMessageBoxClient* client() { |
| 67 return tab_contents_; | 67 return client_; |
| 68 } | 68 } |
| 69 int dialog_flags() { | 69 int dialog_flags() { |
| 70 return dialog_flags_; | 70 return dialog_flags_; |
| 71 } | 71 } |
| 72 std::wstring title() { | 72 std::wstring title() { |
| 73 return title_; | 73 return title_; |
| 74 } | 74 } |
| 75 bool is_before_unload_dialog() { | 75 bool is_before_unload_dialog() { |
| 76 return is_before_unload_dialog_; | 76 return is_before_unload_dialog_; |
| 77 } | 77 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 96 const NotificationDetails& details); | 96 const NotificationDetails& details); |
| 97 | 97 |
| 98 // Sends APP_MODAL_DIALOG_CLOSED notification. | 98 // Sends APP_MODAL_DIALOG_CLOSED notification. |
| 99 void SendCloseNotification(); | 99 void SendCloseNotification(); |
| 100 | 100 |
| 101 NotificationRegistrar registrar_; | 101 NotificationRegistrar registrar_; |
| 102 | 102 |
| 103 // A reference to the platform native dialog box. | 103 // A reference to the platform native dialog box. |
| 104 NativeDialog dialog_; | 104 NativeDialog dialog_; |
| 105 | 105 |
| 106 // An implementation of the client interface to provide supporting methods |
| 107 // and receive results. |
| 108 JavaScriptMessageBoxClient* client_; |
| 109 |
| 110 // True if the dialog should no longer be shown, e.g. because the underlying |
| 111 // tab navigated away while the dialog was queued. |
| 112 bool skip_this_dialog_; |
| 113 |
| 106 // Information about the message box is held in the following variables. | 114 // Information about the message box is held in the following variables. |
| 107 TabContents* tab_contents_; | |
| 108 std::wstring title_; | 115 std::wstring title_; |
| 109 int dialog_flags_; | 116 int dialog_flags_; |
| 110 std::wstring message_text_; | 117 std::wstring message_text_; |
| 111 std::wstring default_prompt_text_; | 118 std::wstring default_prompt_text_; |
| 112 bool display_suppress_checkbox_; | 119 bool display_suppress_checkbox_; |
| 113 bool is_before_unload_dialog_; | 120 bool is_before_unload_dialog_; |
| 114 IPC::Message* reply_msg_; | 121 IPC::Message* reply_msg_; |
| 115 }; | 122 }; |
| 116 | 123 |
| 117 #endif // #ifndef CHROME_BROWSER_APP_MODAL_DIALOG_H_ | 124 #endif // #ifndef CHROME_BROWSER_APP_MODAL_DIALOG_H_ |
| OLD | NEW |