summaryrefslogtreecommitdiffstats
path: root/chrome/browser/app_modal_dialog.h
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-28 15:40:20 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-28 15:40:20 +0000
commit160ad3d101988b9d842fef8b18cc49c54c9a1de5 (patch)
tree567875d2f363d0b110ad25da9a9aa07cffcaa201 /chrome/browser/app_modal_dialog.h
parent341078d4b72bd3de280b960be6cd4ac5e5ab0265 (diff)
downloadchromium_src-160ad3d101988b9d842fef8b18cc49c54c9a1de5.zip
chromium_src-160ad3d101988b9d842fef8b18cc49c54c9a1de5.tar.gz
chromium_src-160ad3d101988b9d842fef8b18cc49c54c9a1de5.tar.bz2
Refactor AppModalDialog to more clearly isolate platform specific UI pieces and eliminate the dependency on individual frontends from cross platform code.
BUG=none TEST=none Review URL: http://codereview.chromium.org/3398015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60785 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/app_modal_dialog.h')
-rw-r--r--chrome/browser/app_modal_dialog.h95
1 files changed, 33 insertions, 62 deletions
diff --git a/chrome/browser/app_modal_dialog.h b/chrome/browser/app_modal_dialog.h
index a3bf31a..708e86e 100644
--- a/chrome/browser/app_modal_dialog.h
+++ b/chrome/browser/app_modal_dialog.h
@@ -13,19 +13,7 @@
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
-// Define NativeDialog type as platform specific dialog view.
-#if defined(OS_WIN)
-class ModalDialogDelegate;
-typedef ModalDialogDelegate* NativeDialog;
-#elif defined(OS_MACOSX)
-typedef void* NativeDialog;
-#elif defined(TOOLKIT_USES_GTK)
-typedef struct _GtkDialog GtkDialog;
-typedef struct _GtkWidget GtkWidget;
-typedef int gint;
-typedef GtkWidget* NativeDialog;
-#endif
-
+class NativeAppModalDialog;
class TabContents;
// A controller+model base class for modal dialogs.
@@ -37,74 +25,57 @@ class AppModalDialog {
AppModalDialog(TabContents* tab_contents, const std::wstring& title);
virtual ~AppModalDialog();
- // Called by the app modal window queue when it is time to show this window.
+ // Called by the AppModalDialogQueue to show this dialog.
void ShowModalDialog();
- // Returns true if the dialog is still valid. As dialogs are created they are
- // added to the AppModalDialogQueue. When the current modal dialog finishes
- // and it's time to show the next dialog in the queue IsValid is invoked.
- // If IsValid returns false the dialog is deleted and not shown.
- virtual bool IsValid() { return !skip_this_dialog_; }
-
- /////////////////////////////////////////////////////////////////////////////
- // The following methods are platform specific and should be implemented in
- // the platform specific .cc files.
- // Create the platform specific NativeDialog and display it. When the
- // NativeDialog is closed, it should call OnAccept or OnCancel to notify the
- // renderer of the user's action. The NativeDialog is also expected to
- // delete the AppModalDialog associated with it.
- virtual void CreateAndShowDialog();
-
-#if defined(TOOLKIT_USES_GTK)
- virtual void HandleDialogResponse(GtkDialog* dialog, gint response_id) = 0;
- // Callback for dialog response calls, passes results to specialized
- // HandleDialogResponse() implementation.
- static void OnDialogResponse(GtkDialog* dialog, gint response_id,
- AppModalDialog* app_modal_dialog);
-#endif
-
- // Close the dialog if it is showing.
- virtual void CloseModalDialog();
-
- // Called by the app modal window queue to activate the window.
+ // Called by the AppModalDialogQueue to activate the dialog.
void ActivateModalDialog();
+ // Closes the dialog if it is showing.
+ void CloseModalDialog();
+
// Completes dialog handling, shows next modal dialog from the queue.
+ // TODO(beng): Get rid of this method.
void CompleteDialog();
// Dialog window title.
- std::wstring title() {
- return title_;
- }
+ std::wstring title() const { return title_; }
- // Helper methods used to query or control the dialog. This is used by
- // automation.
- virtual int GetDialogButtons() = 0;
- virtual void AcceptWindow() = 0;
- virtual void CancelWindow() = 0;
+ NativeAppModalDialog* native_dialog() const { return native_dialog_; }
- protected:
- // Cleans up the dialog class.
- virtual void Cleanup();
- // Creates the actual platform specific dialog view class.
- virtual NativeDialog CreateNativeDialog() = 0;
+ // Methods overridable by AppModalDialog subclasses:
- // A reference to the platform native dialog box.
-#if defined(OS_LINUX) || defined(OS_WIN)
- NativeDialog dialog_;
-#endif
+ // Creates an implementation of NativeAppModalDialog and shows it.
+ // When the native dialog is closed, the implementation of
+ // NativeAppModalDialog should call OnAccept or OnCancel to notify the
+ // renderer of the user's action. The NativeAppModalDialog is also
+ // expected to delete the AppModalDialog associated with it.
+ virtual void CreateAndShowDialog();
- // Parent tab contents.
- TabContents* tab_contents_;
+ // Returns true if the dialog is still valid. As dialogs are created they are
+ // added to the AppModalDialogQueue. When the current modal dialog finishes
+ // and it's time to show the next dialog in the queue IsValid is invoked.
+ // If IsValid returns false the dialog is deleted and not shown.
+ virtual bool IsValid() { return !skip_this_dialog_; }
- // Information about the message box is held in the following variables.
- std::wstring title_;
+ protected:
+ // Overridden by subclasses to create the feature-specific native dialog box.
+ virtual NativeAppModalDialog* CreateNativeDialog() = 0;
// True if the dialog should no longer be shown, e.g. because the underlying
// tab navigated away while the dialog was queued.
bool skip_this_dialog_;
+ // Parent tab contents.
+ TabContents* tab_contents_;
+
private:
+ // The toolkit-specific implementation of the app modal dialog box.
+ NativeAppModalDialog* native_dialog_;
+
+ // Information about the message box is held in the following variables.
+ std::wstring title_;
+
DISALLOW_COPY_AND_ASSIGN(AppModalDialog);
};