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