blob: 53eabd5be376547177c12a2bd6b0532481caebd9 [file] [log] [blame]
[email protected]ebbbb9f2011-03-09 13:16:141// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]965bb092010-04-09 11:59:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/repost_form_warning_controller.h"
6
[email protected]a13283cc2012-04-05 00:21:227#if defined(TOOLKIT_GTK)
[email protected]67baffc82011-12-19 18:03:078#include <gtk/gtk.h>
9#endif
10
11#include "base/bind.h"
12#include "base/bind_helpers.h"
[email protected]cdcb1dee2012-01-04 00:46:2013#include "content/public/browser/navigation_controller.h"
[email protected]6c2381d2011-10-19 02:52:5314#include "content/public/browser/notification_source.h"
[email protected]0d6e9bd2011-10-18 04:29:1615#include "content/public/browser/notification_types.h"
[email protected]2a6bc3e2011-12-28 23:51:3316#include "content/public/browser/web_contents.h"
[email protected]67baffc82011-12-19 18:03:0717#include "grit/generated_resources.h"
18#include "ui/base/l10n/l10n_util.h"
[email protected]965bb092010-04-09 11:59:0219
[email protected]c5eed492012-01-04 17:07:5020using content::NavigationController;
[email protected]2a6bc3e2011-12-28 23:51:3321using content::WebContents;
22
[email protected]965bb092010-04-09 11:59:0223RepostFormWarningController::RepostFormWarningController(
[email protected]2a6bc3e2011-12-28 23:51:3324 WebContents* web_contents)
25 : TabModalConfirmDialogDelegate(web_contents),
26 navigation_controller_(&web_contents->GetController()) {
[email protected]432115822011-07-10 15:52:2727 registrar_.Add(this, content::NOTIFICATION_REPOST_WARNING_SHOWN,
[email protected]c5eed492012-01-04 17:07:5028 content::Source<NavigationController>(
[email protected]cca0f1e2012-01-03 18:27:4629 navigation_controller_));
[email protected]965bb092010-04-09 11:59:0230}
31
32RepostFormWarningController::~RepostFormWarningController() {
33}
34
[email protected]67baffc82011-12-19 18:03:0735string16 RepostFormWarningController::GetTitle() {
36 return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE);
[email protected]965bb092010-04-09 11:59:0237}
38
[email protected]67baffc82011-12-19 18:03:0739string16 RepostFormWarningController::GetMessage() {
40 return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING);
[email protected]965bb092010-04-09 11:59:0241}
42
[email protected]67baffc82011-12-19 18:03:0743string16 RepostFormWarningController::GetAcceptButtonTitle() {
44 return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_RESEND);
45}
46
[email protected]a13283cc2012-04-05 00:21:2247#if defined(TOOLKIT_GTK)
[email protected]67baffc82011-12-19 18:03:0748const char* RepostFormWarningController::GetAcceptButtonIcon() {
49 return GTK_STOCK_REFRESH;
50}
51
52const char* RepostFormWarningController::GetCancelButtonIcon() {
53 return GTK_STOCK_CANCEL;
54}
[email protected]a13283cc2012-04-05 00:21:2255#endif // defined(TOOLKIT_GTK)
[email protected]67baffc82011-12-19 18:03:0756
57void RepostFormWarningController::OnAccepted() {
58 navigation_controller_->ContinuePendingReload();
59}
60
61void RepostFormWarningController::OnCanceled() {
62 navigation_controller_->CancelPendingReload();
63}
64
65void RepostFormWarningController::Observe(
66 int type,
67 const content::NotificationSource& source,
68 const content::NotificationDetails& details) {
69 // Close the dialog if we show an additional dialog, to avoid them
70 // stacking up.
71 if (type == content::NOTIFICATION_REPOST_WARNING_SHOWN)
[email protected]965bb092010-04-09 11:59:0272 Cancel();
[email protected]67baffc82011-12-19 18:03:0773 else
74 TabModalConfirmDialogDelegate::Observe(type, source, details);
[email protected]965bb092010-04-09 11:59:0275}