[email protected] | ebbbb9f | 2011-03-09 13:16:14 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 965bb09 | 2010-04-09 11:59:02 | [diff] [blame] | 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 | |||||
[email protected] | a13283cc | 2012-04-05 00:21:22 | [diff] [blame] | 7 | #if defined(TOOLKIT_GTK) |
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 8 | #include <gtk/gtk.h> |
9 | #endif | ||||
10 | |||||
[email protected] | cdcb1dee | 2012-01-04 00:46:20 | [diff] [blame] | 11 | #include "content/public/browser/navigation_controller.h" |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 12 | #include "content/public/browser/web_contents.h" |
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 13 | #include "grit/generated_resources.h" |
14 | #include "ui/base/l10n/l10n_util.h" | ||||
[email protected] | 965bb09 | 2010-04-09 11:59:02 | [diff] [blame] | 15 | |
[email protected] | 965bb09 | 2010-04-09 11:59:02 | [diff] [blame] | 16 | RepostFormWarningController::RepostFormWarningController( |
[email protected] | 17e286e | 2013-03-01 23:29:39 | [diff] [blame] | 17 | content::WebContents* web_contents) |
[email protected] | 2a6bc3e | 2011-12-28 23:51:33 | [diff] [blame] | 18 | : TabModalConfirmDialogDelegate(web_contents), |
[email protected] | 17e286e | 2013-03-01 23:29:39 | [diff] [blame] | 19 | content::WebContentsObserver(web_contents) { |
[email protected] | 965bb09 | 2010-04-09 11:59:02 | [diff] [blame] | 20 | } |
21 | |||||
22 | RepostFormWarningController::~RepostFormWarningController() { | ||||
23 | } | ||||
24 | |||||
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 25 | string16 RepostFormWarningController::GetTitle() { |
26 | return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE); | ||||
[email protected] | 965bb09 | 2010-04-09 11:59:02 | [diff] [blame] | 27 | } |
28 | |||||
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 29 | string16 RepostFormWarningController::GetMessage() { |
30 | return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING); | ||||
[email protected] | 965bb09 | 2010-04-09 11:59:02 | [diff] [blame] | 31 | } |
32 | |||||
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 33 | string16 RepostFormWarningController::GetAcceptButtonTitle() { |
34 | return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_RESEND); | ||||
35 | } | ||||
36 | |||||
[email protected] | a13283cc | 2012-04-05 00:21:22 | [diff] [blame] | 37 | #if defined(TOOLKIT_GTK) |
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 38 | const char* RepostFormWarningController::GetAcceptButtonIcon() { |
39 | return GTK_STOCK_REFRESH; | ||||
40 | } | ||||
41 | |||||
42 | const char* RepostFormWarningController::GetCancelButtonIcon() { | ||||
43 | return GTK_STOCK_CANCEL; | ||||
44 | } | ||||
[email protected] | a13283cc | 2012-04-05 00:21:22 | [diff] [blame] | 45 | #endif // defined(TOOLKIT_GTK) |
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 46 | |
47 | void RepostFormWarningController::OnAccepted() { | ||||
[email protected] | 17e286e | 2013-03-01 23:29:39 | [diff] [blame] | 48 | web_contents()->GetController().ContinuePendingReload(); |
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 49 | } |
50 | |||||
51 | void RepostFormWarningController::OnCanceled() { | ||||
[email protected] | 17e286e | 2013-03-01 23:29:39 | [diff] [blame] | 52 | web_contents()->GetController().CancelPendingReload(); |
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 53 | } |
54 | |||||
[email protected] | 17e286e | 2013-03-01 23:29:39 | [diff] [blame] | 55 | void RepostFormWarningController::BeforeFormRepostWarningShow() { |
[email protected] | 67baffc8 | 2011-12-19 18:03:07 | [diff] [blame] | 56 | // Close the dialog if we show an additional dialog, to avoid them |
57 | // stacking up. | ||||
[email protected] | 17e286e | 2013-03-01 23:29:39 | [diff] [blame] | 58 | Cancel(); |
[email protected] | 965bb09 | 2010-04-09 11:59:02 | [diff] [blame] | 59 | } |