| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/repost_form_warning_view.h" | 5 #include "chrome/browser/ui/views/repost_form_warning_view.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/message_box_flags.h" | |
| 9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 11 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
| 12 #include "chrome/browser/repost_form_warning_controller.h" | 11 #include "chrome/browser/repost_form_warning_controller.h" |
| 13 #include "chrome/browser/tab_contents/navigation_controller.h" | 12 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 15 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "ui/base/message_box_flags.h" |
| 16 #include "views/controls/message_box_view.h" | 16 #include "views/controls/message_box_view.h" |
| 17 #include "views/window/window.h" | 17 #include "views/window/window.h" |
| 18 | 18 |
| 19 namespace browser { | 19 namespace browser { |
| 20 | 20 |
| 21 // Declared in browser_dialogs.h so others don't have to depend on our header. | 21 // Declared in browser_dialogs.h so others don't have to depend on our header. |
| 22 void ShowRepostFormWarningDialog(gfx::NativeWindow parent_window, | 22 void ShowRepostFormWarningDialog(gfx::NativeWindow parent_window, |
| 23 TabContents* tab_contents) { | 23 TabContents* tab_contents) { |
| 24 new RepostFormWarningView(parent_window, tab_contents); | 24 new RepostFormWarningView(parent_window, tab_contents); |
| 25 } | 25 } |
| 26 | 26 |
| 27 } // namespace browser | 27 } // namespace browser |
| 28 | 28 |
| 29 ////////////////////////////////////////////////////////////////////////////// | 29 ////////////////////////////////////////////////////////////////////////////// |
| 30 // RepostFormWarningView, constructor & destructor: | 30 // RepostFormWarningView, constructor & destructor: |
| 31 | 31 |
| 32 RepostFormWarningView::RepostFormWarningView( | 32 RepostFormWarningView::RepostFormWarningView( |
| 33 gfx::NativeWindow parent_window, | 33 gfx::NativeWindow parent_window, |
| 34 TabContents* tab_contents) | 34 TabContents* tab_contents) |
| 35 : controller_(new RepostFormWarningController(tab_contents)), | 35 : controller_(new RepostFormWarningController(tab_contents)), |
| 36 message_box_view_(NULL) { | 36 message_box_view_(NULL) { |
| 37 message_box_view_ = new MessageBoxView( | 37 message_box_view_ = new MessageBoxView( |
| 38 MessageBoxFlags::kIsConfirmMessageBox, | 38 ui::MessageBoxFlags::kIsConfirmMessageBox, |
| 39 UTF16ToWide(l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING)), | 39 UTF16ToWide(l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING)), |
| 40 std::wstring()); | 40 std::wstring()); |
| 41 controller_->Show(this); | 41 controller_->Show(this); |
| 42 } | 42 } |
| 43 | 43 |
| 44 RepostFormWarningView::~RepostFormWarningView() { | 44 RepostFormWarningView::~RepostFormWarningView() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 ////////////////////////////////////////////////////////////////////////////// | 47 ////////////////////////////////////////////////////////////////////////////// |
| 48 // RepostFormWarningView, views::DialogDelegate implementation: | 48 // RepostFormWarningView, views::DialogDelegate implementation: |
| 49 | 49 |
| 50 std::wstring RepostFormWarningView::GetWindowTitle() const { | 50 std::wstring RepostFormWarningView::GetWindowTitle() const { |
| 51 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE)); | 51 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_TITLE)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 std::wstring RepostFormWarningView::GetDialogButtonLabel( | 54 std::wstring RepostFormWarningView::GetDialogButtonLabel( |
| 55 MessageBoxFlags::DialogButton button) const { | 55 ui::MessageBoxFlags::DialogButton button) const { |
| 56 if (button == MessageBoxFlags::DIALOGBUTTON_OK) | 56 if (button == ui::MessageBoxFlags::DIALOGBUTTON_OK) |
| 57 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_RESEND)); | 57 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_HTTP_POST_WARNING_RESEND)); |
| 58 if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL) | 58 if (button == ui::MessageBoxFlags::DIALOGBUTTON_CANCEL) |
| 59 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_CANCEL)); | 59 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_CANCEL)); |
| 60 return std::wstring(); | 60 return std::wstring(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 views::View* RepostFormWarningView::GetContentsView() { | 63 views::View* RepostFormWarningView::GetContentsView() { |
| 64 return message_box_view_; | 64 return message_box_view_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool RepostFormWarningView::Cancel() { | 67 bool RepostFormWarningView::Cancel() { |
| 68 controller_->Cancel(); | 68 controller_->Cancel(); |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool RepostFormWarningView::Accept() { | 72 bool RepostFormWarningView::Accept() { |
| 73 controller_->Continue(); | 73 controller_->Continue(); |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 /////////////////////////////////////////////////////////////////////////////// | 77 /////////////////////////////////////////////////////////////////////////////// |
| 78 // RepostFormWarningView, RepostFormWarning implementation: | 78 // RepostFormWarningView, RepostFormWarning implementation: |
| 79 | 79 |
| 80 void RepostFormWarningView::DeleteDelegate() { | 80 void RepostFormWarningView::DeleteDelegate() { |
| 81 delete this; | 81 delete this; |
| 82 } | 82 } |
| OLD | NEW |