Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2142)

Unified Diff: chrome/browser/repost_form_warning_controller.cc

Issue 8851007: WIP / Do not commit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/repost_form_warning_controller.h ('k') | chrome/browser/resources/plugins_mac.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/repost_form_warning_controller.cc
diff --git a/chrome/browser/repost_form_warning_controller.cc b/chrome/browser/repost_form_warning_controller.cc
index 987b7d621fb69950834a4f1a0d4b80759946438a..ca4c1228a71d534f58c816d6aada699b4ebdaa0c 100644
--- a/chrome/browser/repost_form_warning_controller.cc
+++ b/chrome/browser/repost_form_warning_controller.cc
@@ -4,66 +4,68 @@
#include "chrome/browser/repost_form_warning_controller.h"
-#include "chrome/browser/ui/constrained_window.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 "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)
- : 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));
+ : TabModalDialogDelegate(tab_contents) {
registrar_.Add(this, content::NOTIFICATION_REPOST_WARNING_SHOWN,
- content::Source<NavigationController>(controller));
+ content::Source<NavigationController>(
+ &tab_contents->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();
}
-void RepostFormWarningController::Cancel() {
- if (tab_contents_) {
- tab_contents_->controller().CancelPendingReload();
- CloseDialog();
- }
+string16 RepostFormWarningController::GetTitle() {
+ return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE);
}
-void RepostFormWarningController::Continue() {
- if (tab_contents_) {
- tab_contents_->controller().ContinuePendingReload();
- // If we reload the page, the dialog will be closed anyway.
- }
+string16 RepostFormWarningController::GetMessage() {
+ return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING);
}
-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();
- }
+string16 RepostFormWarningController::GetAcceptButtonTitle() {
+ return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_RESEND);
+}
+
+#if defined(TOOLKIT_USES_GTK)
+const char* RepostFormWarningController::GetAcceptButtonIcon() {
+ return GTK_STOCK_REFRESH;
+}
+
+const char* RepostFormWarningController::GetCancelButtonTitleIcon() {
+ return GTK_STOCK_CANCEL;
}
+#endif // defined(TOOLKIT_USES_GTK)
-void RepostFormWarningController::CloseDialog() {
- // Make sure we won't do anything when |Cancel()| is called again.
- tab_contents_ = NULL;
- if (window_) {
- window_->CloseConstrainedWindow();
- }
+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 show an additional dialog, to avoid them
+ // stacking up.
+ if (type == content::NOTIFICATION_REPOST_WARNING_SHOWN)
+ Cancel();
+ else
+ TabModalDialogDelegate::Observe(type, source, details);
}
« no previous file with comments | « chrome/browser/repost_form_warning_controller.h ('k') | chrome/browser/resources/plugins_mac.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698