diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-02 19:20:13 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-02 19:20:13 +0000 |
commit | 1db06851c0de18c6049a88379750f5651cc92a75 (patch) | |
tree | b73c3fc45a07f77ab55fc3de83c4e035b5ba2387 /chrome/browser/js_modal_dialog.h | |
parent | 7fef9717afc4570883a9207fb8ea70f295685488 (diff) | |
download | chromium_src-1db06851c0de18c6049a88379750f5651cc92a75.zip chromium_src-1db06851c0de18c6049a88379750f5651cc92a75.tar.gz chromium_src-1db06851c0de18c6049a88379750f5651cc92a75.tar.bz2 |
Add a Delegate to JavaScriptAppModalDialog.
Done a couples of things here:
- Renamed JavaScriptMessageBoxClient to JavaScriptMessageBoxDelegate (since this is a common pattern in chrome and helps the reader to find out where the message box goes).
- Moved that class into js_modal_dialog.h file.
- Deleted jsmessage_box_client.h
It is a following to http://codereview.chromium.org/3384036.
BUG=54988
TEST=trybots
Review URL: http://codereview.chromium.org/3576003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61309 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/js_modal_dialog.h')
-rw-r--r-- | chrome/browser/js_modal_dialog.h | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/chrome/browser/js_modal_dialog.h b/chrome/browser/js_modal_dialog.h index b2cccff..eef7540 100644 --- a/chrome/browser/js_modal_dialog.h +++ b/chrome/browser/js_modal_dialog.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,23 +12,46 @@ #include "chrome/browser/app_modal_dialog.h" #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" +#include "gfx/native_widget_types.h" class ExtensionHost; -class JavaScriptMessageBoxClient; class NativeAppModalDialog; +class TabContents; namespace IPC { class Message; } -// A controller+model class for JavaScript alert, confirm, prompt, and +class JavaScriptAppModalDialogDelegate { + 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() {} +}; + +// A controller + model class for JavaScript alert, confirm, prompt, and // onbeforeunload dialog boxes. class JavaScriptAppModalDialog : public AppModalDialog, public NotificationObserver { public: - // A union of data necessary to determine the type of message box to - // show. |dialog_flags| is a MessageBox flag. - JavaScriptAppModalDialog(JavaScriptMessageBoxClient* client, + JavaScriptAppModalDialog(JavaScriptAppModalDialogDelegate* delegate, const std::wstring& title, int dialog_flags, const std::wstring& message_text, @@ -38,12 +61,10 @@ class JavaScriptAppModalDialog : public AppModalDialog, IPC::Message* reply_msg); virtual ~JavaScriptAppModalDialog(); - // AppModalDialog overrides. + // Overridden from AppModalDialog: virtual NativeAppModalDialog* CreateNativeDialog(); - ///////////////////////////////////////////////////////////////////////////// - // Getters so NativeDialog can get information about the message box. - JavaScriptMessageBoxClient* client() const { return client_; } + JavaScriptAppModalDialogDelegate* delegate() const { return delegate_; } // Callbacks from NativeDialog when the user accepts or cancels the dialog. void OnCancel(); @@ -58,11 +79,11 @@ class JavaScriptAppModalDialog : public AppModalDialog, bool is_before_unload_dialog() const { return is_before_unload_dialog_; } protected: - // AppModalDialog overrides. + // Overridden from AppModalDialog: virtual void Cleanup(); private: - // NotificationObserver implementation. + // Overridden from NotificationObserver: virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details); @@ -76,12 +97,12 @@ class JavaScriptAppModalDialog : public AppModalDialog, // An implementation of the client interface to provide supporting methods // and receive results. - JavaScriptMessageBoxClient* client_; + JavaScriptAppModalDialogDelegate* delegate_; // The client_ as an ExtensionHost, cached for use during notifications that // may arrive after the client has entered its destructor (and is thus - // treated as a base JavaScriptMessageBoxClient). This will be NULL if the - // client is not an ExtensionHost. + // treated as a base Delegate). This will be NULL if the |delegate_| is not an + // ExtensionHost. ExtensionHost* extension_host_; // Information about the message box is held in the following variables. |