repost_form_warning_controller.cc revision a36e5920737c6adbddd3e43b760e5de8431db6e0
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.
4
5#include "chrome/browser/repost_form_warning_controller.h"
6
7#if defined(TOOLKIT_GTK)
8#include <gtk/gtk.h>
9#endif
10
11#include "content/public/browser/navigation_controller.h"
12#include "content/public/browser/web_contents.h"
13#include "grit/generated_resources.h"
14#include "ui/base/l10n/l10n_util.h"
15
16RepostFormWarningController::RepostFormWarningController(
17    content::WebContents* web_contents)
18    : TabModalConfirmDialogDelegate(web_contents),
19      content::WebContentsObserver(web_contents) {
20}
21
22RepostFormWarningController::~RepostFormWarningController() {
23}
24
25string16 RepostFormWarningController::GetTitle() {
26  return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE);
27}
28
29string16 RepostFormWarningController::GetMessage() {
30  return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING);
31}
32
33string16 RepostFormWarningController::GetAcceptButtonTitle() {
34  return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_RESEND);
35}
36
37#if defined(TOOLKIT_GTK)
38const char* RepostFormWarningController::GetAcceptButtonIcon() {
39  return GTK_STOCK_REFRESH;
40}
41
42const char* RepostFormWarningController::GetCancelButtonIcon() {
43  return GTK_STOCK_CANCEL;
44}
45#endif  // defined(TOOLKIT_GTK)
46
47void RepostFormWarningController::OnAccepted() {
48  web_contents()->GetController().ContinuePendingReload();
49}
50
51void RepostFormWarningController::OnCanceled() {
52  web_contents()->GetController().CancelPendingReload();
53}
54
55void RepostFormWarningController::OnClosed() {
56  web_contents()->GetController().CancelPendingReload();
57}
58
59void RepostFormWarningController::BeforeFormRepostWarningShow() {
60  // Close the dialog if we show an additional dialog, to avoid them
61  // stacking up.
62  Cancel();
63}
64