summaryrefslogtreecommitdiffstats
path: root/chrome/browser/repost_form_warning_controller.cc
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-17 02:54:43 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-17 02:54:43 +0000
commitcb928b74a8f2a612d746a06321d14c34cffedb50 (patch)
tree65420c15864fc903263eb3084c21038fa6c6d99b /chrome/browser/repost_form_warning_controller.cc
parent196fd8a8240ffa5750867f4253475a1f440ca2a6 (diff)
downloadchromium_src-cb928b74a8f2a612d746a06321d14c34cffedb50.zip
chromium_src-cb928b74a8f2a612d746a06321d14c34cffedb50.tar.gz
chromium_src-cb928b74a8f2a612d746a06321d14c34cffedb50.tar.bz2
Revert 114898 - 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. BUG=92795 TEST=none Review URL: http://codereview.chromium.org/8658005 TBR=bauerb@chromium.org Review URL: http://codereview.chromium.org/8962012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/repost_form_warning_controller.cc')
-rw-r--r--chrome/browser/repost_form_warning_controller.cc90
1 files changed, 44 insertions, 46 deletions
diff --git a/chrome/browser/repost_form_warning_controller.cc b/chrome/browser/repost_form_warning_controller.cc
index a53e95e..987b7d6 100644
--- a/chrome/browser/repost_form_warning_controller.cc
+++ b/chrome/browser/repost_form_warning_controller.cc
@@ -4,68 +4,66 @@
#include "chrome/browser/repost_form_warning_controller.h"
-#if defined(TOOLKIT_USES_GTK)
-#include <gtk/gtk.h>
-#endif
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "content/browser/tab_contents/navigation_controller.h"
+#include "chrome/browser/ui/constrained_window.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
RepostFormWarningController::RepostFormWarningController(
TabContents* tab_contents)
- : TabModalConfirmDialogDelegate(tab_contents),
- navigation_controller_(&tab_contents->controller()) {
+ : tab_contents_(tab_contents),
+ window_(NULL) {
+ NavigationController* controller = &tab_contents->controller();
+ registrar_.Add(this, content::NOTIFICATION_LOAD_START,
+ content::Source<NavigationController>(controller));
+ registrar_.Add(this, content::NOTIFICATION_TAB_CLOSING,
+ content::Source<NavigationController>(controller));
registrar_.Add(this, content::NOTIFICATION_REPOST_WARNING_SHOWN,
- content::Source<NavigationController>(navigation_controller_));
+ content::Source<NavigationController>(controller));
}
RepostFormWarningController::~RepostFormWarningController() {
+ // If we end up here, the constrained window has been closed, so make sure we
+ // don't close it again.
+ window_ = NULL;
+ // Make sure everything is cleaned up.
+ Cancel();
}
-string16 RepostFormWarningController::GetTitle() {
- return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE);
-}
-
-string16 RepostFormWarningController::GetMessage() {
- return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING);
+void RepostFormWarningController::Cancel() {
+ if (tab_contents_) {
+ tab_contents_->controller().CancelPendingReload();
+ CloseDialog();
+ }
}
-string16 RepostFormWarningController::GetAcceptButtonTitle() {
- return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_RESEND);
+void RepostFormWarningController::Continue() {
+ if (tab_contents_) {
+ tab_contents_->controller().ContinuePendingReload();
+ // If we reload the page, the dialog will be closed anyway.
+ }
}
-#if defined(TOOLKIT_USES_GTK)
-const char* RepostFormWarningController::GetAcceptButtonIcon() {
- return GTK_STOCK_REFRESH;
-}
-
-const char* RepostFormWarningController::GetCancelButtonIcon() {
- return GTK_STOCK_CANCEL;
-}
-#endif // defined(TOOLKIT_USES_GTK)
-
-void RepostFormWarningController::OnAccepted() {
- navigation_controller_->ContinuePendingReload();
-}
-
-void RepostFormWarningController::OnCanceled() {
- navigation_controller_->CancelPendingReload();
+void RepostFormWarningController::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ // Close the dialog if we load a page (because reloading might not apply to
+ // the same page anymore) or if the tab is closed, because then we won't have
+ // a navigation controller anymore.
+ if (tab_contents_ &&
+ (type == content::NOTIFICATION_LOAD_START ||
+ type == content::NOTIFICATION_TAB_CLOSING ||
+ type == content::NOTIFICATION_REPOST_WARNING_SHOWN)) {
+ DCHECK_EQ(content::Source<NavigationController>(source).ptr(),
+ &tab_contents_->controller());
+ Cancel();
+ }
}
-void RepostFormWarningController::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- // Close the dialog if we show an additional dialog, to avoid them
- // stacking up.
- if (type == content::NOTIFICATION_REPOST_WARNING_SHOWN)
- Cancel();
- else
- TabModalConfirmDialogDelegate::Observe(type, source, details);
+void RepostFormWarningController::CloseDialog() {
+ // Make sure we won't do anything when |Cancel()| is called again.
+ tab_contents_ = NULL;
+ if (window_) {
+ window_->CloseConstrainedWindow();
+ }
}