diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-03 18:02:07 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-03 18:02:07 +0000 |
commit | 3ab9cb81731759c6e11f8c5296c1b75a7d2dadf1 (patch) | |
tree | 9344ece34a634b18d3e226c738471159d32484a6 /chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h | |
parent | eadd4e31649b1a9da5d47864ff26ccd06b45edba (diff) | |
download | chromium_src-3ab9cb81731759c6e11f8c5296c1b75a7d2dadf1.zip chromium_src-3ab9cb81731759c6e11f8c5296c1b75a7d2dadf1.tar.gz chromium_src-3ab9cb81731759c6e11f8c5296c1b75a7d2dadf1.tar.bz2 |
Remove JS dialog dependency from content.
BUG=71097
TEST=all types of javascript dialogs work, onbeforeunload dialogs work too
Review URL: http://codereview.chromium.org/7096016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87806 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h')
-rw-r--r-- | chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h | 62 |
1 files changed, 26 insertions, 36 deletions
diff --git a/chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h b/chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h index 851b039..6a05b8e 100644 --- a/chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h +++ b/chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h @@ -8,12 +8,12 @@ #include <string> -#include "base/utf_string_conversions.h" +#include "base/time.h" #include "build/build_config.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" +#include "content/browser/javascript_dialogs.h" #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" -#include "ui/gfx/native_widget_types.h" class ExtensionHost; class NativeAppModalDialog; @@ -23,28 +23,16 @@ namespace IPC { class Message; } -class JavaScriptAppModalDialogDelegate { +// Extra data for JavaScript dialogs to add Chrome-only features. +class ChromeJavaScriptDialogExtraData { public: - // AppModalDialog calls this when the dialog is closed. - virtual void OnMessageBoxClosed(IPC::Message* reply_msg, - bool success, - const std::wstring& prompt) = 0; - - // Indicates whether additional message boxes should be suppressed. - virtual void SetSuppressMessageBoxes(bool suppress_message_boxes) = 0; - - // Returns the root native window with which the message box is associated. - virtual gfx::NativeWindow GetMessageBoxRootWindow() = 0; - - // Returns the TabContents or ExtensionHost associated with this message - // box -- in practice, the object implementing this interface. Exactly one - // of these must be non-NULL; behavior is undefined (read: it'll probably - // crash) if that is not the case. - virtual TabContents* AsTabContents() = 0; - virtual ExtensionHost* AsExtensionHost() = 0; - - protected: - virtual ~JavaScriptAppModalDialogDelegate() {} + ChromeJavaScriptDialogExtraData(); + + // The time that the last JavaScript dialog was dismissed. + base::TimeTicks last_javascript_message_dismissal_; + + // True if the user has decided to block future JavaScript dialogs. + bool suppress_javascript_messages_; }; // A controller + model class for JavaScript alert, confirm, prompt, and @@ -52,11 +40,12 @@ class JavaScriptAppModalDialogDelegate { class JavaScriptAppModalDialog : public AppModalDialog, public NotificationObserver { public: - JavaScriptAppModalDialog(JavaScriptAppModalDialogDelegate* delegate, - const std::wstring& title, + JavaScriptAppModalDialog(content::JavaScriptDialogDelegate* delegate, + ChromeJavaScriptDialogExtraData* extra_data, + const string16& title, int dialog_flags, - const std::wstring& message_text, - const std::wstring& default_prompt_text, + const string16& message_text, + const string16& default_prompt_text, bool display_suppress_checkbox, bool is_before_unload_dialog, IPC::Message* reply_msg); @@ -66,11 +55,11 @@ class JavaScriptAppModalDialog : public AppModalDialog, virtual NativeAppModalDialog* CreateNativeDialog(); virtual bool IsJavaScriptModalDialog(); - JavaScriptAppModalDialogDelegate* delegate() const { return delegate_; } + content::JavaScriptDialogDelegate* delegate() const { return delegate_; } // Callbacks from NativeDialog when the user accepts or cancels the dialog. void OnCancel(bool suppress_js_messages); - void OnAccept(const std::wstring& prompt_text, bool suppress_js_messages); + void OnAccept(const string16& prompt_text, bool suppress_js_messages); // NOTE: This is only called under Views, and should be removed. Any critical // work should be done in OnCancel or OnAccept. See crbug.com/63732 for more. @@ -82,10 +71,8 @@ class JavaScriptAppModalDialog : public AppModalDialog, // Accessors int dialog_flags() const { return dialog_flags_; } - std::wstring message_text() const { return message_text_; } - std::wstring default_prompt_text() const { - return UTF16ToWideHack(default_prompt_text_); - } + string16 message_text() const { return message_text_; } + string16 default_prompt_text() const { return default_prompt_text_; } bool display_suppress_checkbox() const { return display_suppress_checkbox_; } bool is_before_unload_dialog() const { return is_before_unload_dialog_; } @@ -99,14 +86,17 @@ class JavaScriptAppModalDialog : public AppModalDialog, void InitNotifications(); // Notifies the delegate with the result of the dialog. - void NotifyDelegate(bool success, const std::wstring& prompt_text, + void NotifyDelegate(bool success, const string16& prompt_text, bool suppress_js_messages); NotificationRegistrar registrar_; // An implementation of the client interface to provide supporting methods // and receive results. - JavaScriptAppModalDialogDelegate* delegate_; + content::JavaScriptDialogDelegate* delegate_; + + // The extra Chrome-only data associated with the delegate_. + ChromeJavaScriptDialogExtraData* extra_data_; // The client_ as an ExtensionHost, cached for use during notifications that // may arrive after the client has entered its destructor (and is thus @@ -116,7 +106,7 @@ class JavaScriptAppModalDialog : public AppModalDialog, // Information about the message box is held in the following variables. int dialog_flags_; - std::wstring message_text_; + string16 message_text_; string16 default_prompt_text_; bool display_suppress_checkbox_; bool is_before_unload_dialog_; |