Reland r114898: Add TabModalConfirmDialogDelegate to show simple tab-modal confirmation dialogs.
This CL carves a TabModalConfirmDialogDelegate class (modeled after ConfirmInfobarDelegate) out of RepostFormWarningController and makes it a subclass thereof.
It also removes the ShowRepostFormWarning method from BrowserWindow and its subclasses, in favor of a method in browser_dialogs.h.
[email protected],[email protected],[email protected],[email protected]
BUG=92795
TEST=none
Review URL: http://codereview.chromium.org/8986005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115000 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/repost_form_warning_controller.h b/chrome/browser/repost_form_warning_controller.h
index 7b8114a..808c9d3 100644
--- a/chrome/browser/repost_form_warning_controller.h
+++ b/chrome/browser/repost_form_warning_controller.h
@@ -7,44 +7,37 @@
#pragma once
#include "base/compiler_specific.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
+#include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
-class ConstrainedWindow;
+class NavigationController;
class TabContents;
// This class is used to continue or cancel a pending reload when the
// repost form warning is shown. It is owned by the platform-dependent
// |RepostFormWarning{Gtk,Mac,View}| classes.
-class RepostFormWarningController : public content::NotificationObserver {
+class RepostFormWarningController : public TabModalConfirmDialogDelegate {
public:
explicit RepostFormWarningController(TabContents* tab_contents);
virtual ~RepostFormWarningController();
- // Cancel the reload.
- void Cancel();
-
- // Continue the reload.
- void Continue();
-
- void set_window(ConstrainedWindow* window) { window_ = window; }
+ // TabModalConfirmDialogDelegate methods:
+ virtual string16 GetTitle() OVERRIDE;
+ virtual string16 GetMessage() OVERRIDE;
+ virtual string16 GetAcceptButtonTitle() OVERRIDE;
+#if defined(TOOLKIT_USES_GTK)
+ virtual const char* GetAcceptButtonIcon() OVERRIDE;
+ virtual const char* GetCancelButtonIcon() OVERRIDE;
+#endif // defined(TOOLKIT_USES_GTK)
+ virtual void OnAccepted() OVERRIDE;
+ virtual void OnCanceled() OVERRIDE;
private:
- // content::NotificationObserver implementation.
- // Watch for a new load or a closed tab and dismiss the dialog if they occur.
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
- // Close the warning dialog.
- void CloseDialog();
-
- content::NotificationRegistrar registrar_;
-
- // Tab contents, used to continue the reload.
- TabContents* tab_contents_;
-
- ConstrainedWindow* window_;
+ // Weak pointer; this dialog is cancelled when the TabContents is closed.
+ NavigationController* navigation_controller_;
DISALLOW_COPY_AND_ASSIGN(RepostFormWarningController);
};