| OLD | NEW |
| (Empty) |
| 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/ui/views/repost_form_warning_view.h" | |
| 6 | |
| 7 #include "base/utf_string_conversions.h" | |
| 8 #include "chrome/browser/repost_form_warning_controller.h" | |
| 9 #include "chrome/browser/ui/browser_list.h" | |
| 10 #include "chrome/browser/ui/browser_window.h" | |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
| 12 #include "chrome/browser/ui/views/constrained_window_views.h" | |
| 13 #include "content/browser/tab_contents/navigation_controller.h" | |
| 14 #include "content/browser/tab_contents/tab_contents.h" | |
| 15 #include "grit/generated_resources.h" | |
| 16 #include "ui/base/l10n/l10n_util.h" | |
| 17 #include "ui/views/controls/message_box_view.h" | |
| 18 | |
| 19 namespace browser { | |
| 20 | |
| 21 // Declared in browser_dialogs.h so others don't have to depend on our header. | |
| 22 void ShowRepostFormWarningDialog(gfx::NativeWindow parent_window, | |
| 23 TabContents* tab_contents) { | |
| 24 new RepostFormWarningView(parent_window, tab_contents); | |
| 25 } | |
| 26 | |
| 27 } // namespace browser | |
| 28 | |
| 29 ////////////////////////////////////////////////////////////////////////////// | |
| 30 // RepostFormWarningView, constructor & destructor: | |
| 31 | |
| 32 RepostFormWarningView::RepostFormWarningView( | |
| 33 gfx::NativeWindow parent_window, | |
| 34 TabContents* tab_contents) | |
| 35 : controller_(new RepostFormWarningController(tab_contents)), | |
| 36 message_box_view_(NULL) { | |
| 37 message_box_view_ = new views::MessageBoxView( | |
| 38 views::MessageBoxView::NO_OPTIONS, | |
| 39 l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING), | |
| 40 string16()); | |
| 41 TabContentsWrapper* wrapper = | |
| 42 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); | |
| 43 controller_->set_window(new ConstrainedWindowViews(wrapper, this)); | |
| 44 } | |
| 45 | |
| 46 RepostFormWarningView::~RepostFormWarningView() { | |
| 47 } | |
| 48 | |
| 49 ////////////////////////////////////////////////////////////////////////////// | |
| 50 // RepostFormWarningView, views::DialogDelegate implementation: | |
| 51 | |
| 52 string16 RepostFormWarningView::GetWindowTitle() const { | |
| 53 return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE); | |
| 54 } | |
| 55 | |
| 56 string16 RepostFormWarningView::GetDialogButtonLabel( | |
| 57 ui::DialogButton button) const { | |
| 58 if (button == ui::DIALOG_BUTTON_OK) | |
| 59 return l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_RESEND); | |
| 60 if (button == ui::DIALOG_BUTTON_CANCEL) | |
| 61 return l10n_util::GetStringUTF16(IDS_CANCEL); | |
| 62 return string16(); | |
| 63 } | |
| 64 | |
| 65 views::View* RepostFormWarningView::GetContentsView() { | |
| 66 return message_box_view_; | |
| 67 } | |
| 68 | |
| 69 views::Widget* RepostFormWarningView::GetWidget() { | |
| 70 return message_box_view_->GetWidget(); | |
| 71 } | |
| 72 | |
| 73 const views::Widget* RepostFormWarningView::GetWidget() const { | |
| 74 return message_box_view_->GetWidget(); | |
| 75 } | |
| 76 | |
| 77 bool RepostFormWarningView::Cancel() { | |
| 78 controller_->Cancel(); | |
| 79 return true; | |
| 80 } | |
| 81 | |
| 82 bool RepostFormWarningView::Accept() { | |
| 83 controller_->Continue(); | |
| 84 return true; | |
| 85 } | |
| 86 | |
| 87 /////////////////////////////////////////////////////////////////////////////// | |
| 88 // RepostFormWarningView, RepostFormWarning implementation: | |
| 89 | |
| 90 void RepostFormWarningView::DeleteDelegate() { | |
| 91 delete this; | |
| 92 } | |
| OLD | NEW |