1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/repost_form_warning_controller.h"
7 #if defined(TOOLKIT_GTK)
11 #include "base/bind.h"
12 #include "base/bind_helpers.h"
13 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/notification_source.h"
15 #include "content/public/browser/notification_types.h"
16 #include "content/public/browser/web_contents.h"
17 #include "grit/generated_resources.h"
18 #include "ui/base/l10n/l10n_util.h"
20 using content::NavigationController
;
21 using content::WebContents
;
23 RepostFormWarningController::RepostFormWarningController(
24 WebContents
* web_contents
)
25 : TabModalConfirmDialogDelegate(web_contents
),
26 navigation_controller_(&web_contents
->GetController()) {
27 registrar_
.Add(this, content::NOTIFICATION_REPOST_WARNING_SHOWN
,
28 content::Source
<NavigationController
>(
29 navigation_controller_
));
32 RepostFormWarningController::~RepostFormWarningController() {
35 string16
RepostFormWarningController::GetTitle() {
36 return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE
);
39 string16
RepostFormWarningController::GetMessage() {
40 return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING
);
43 string16
RepostFormWarningController::GetAcceptButtonTitle() {
44 return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_RESEND
);
47 #if defined(TOOLKIT_GTK)
48 const char* RepostFormWarningController::GetAcceptButtonIcon() {
49 return GTK_STOCK_REFRESH
;
52 const char* RepostFormWarningController::GetCancelButtonIcon() {
53 return GTK_STOCK_CANCEL
;
55 #endif // defined(TOOLKIT_GTK)
57 void RepostFormWarningController::OnAccepted() {
58 navigation_controller_
->ContinuePendingReload();
61 void RepostFormWarningController::OnCanceled() {
62 navigation_controller_
->CancelPendingReload();
65 void RepostFormWarningController::Observe(
67 const content::NotificationSource
& source
,
68 const content::NotificationDetails
& details
) {
69 // Close the dialog if we show an additional dialog, to avoid them
71 if (type
== content::NOTIFICATION_REPOST_WARNING_SHOWN
)
74 TabModalConfirmDialogDelegate::Observe(type
, source
, details
);