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