| 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/download/download_in_progress_dialog_view.h" | 5 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "views/controls/label.h" | 21 #include "views/controls/label.h" |
| 22 #include "views/layout/grid_layout.h" | 22 #include "views/layout/grid_layout.h" |
| 23 #include "views/widget/widget.h" | 23 #include "views/widget/widget.h" |
| 24 | 24 |
| 25 DownloadInProgressDialogView::DownloadInProgressDialogView(Browser* browser) | 25 DownloadInProgressDialogView::DownloadInProgressDialogView(Browser* browser) |
| 26 : browser_(browser), | 26 : browser_(browser), |
| 27 product_name_(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)) { | 27 product_name_(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)) { |
| 28 int download_count = browser->profile()->GetDownloadManager()-> | 28 int download_count = browser->profile()->GetDownloadManager()-> |
| 29 in_progress_count(); | 29 in_progress_count(); |
| 30 | 30 |
| 31 string16 warning_text; | 31 std::wstring warning_text; |
| 32 string16 explanation_text; | 32 std::wstring explanation_text; |
| 33 if (download_count == 1) { | 33 if (download_count == 1) { |
| 34 warning_text = l10n_util::GetStringFUTF16( | 34 warning_text = UTF16ToWide(l10n_util::GetStringFUTF16( |
| 35 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING, | 35 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_WARNING, |
| 36 product_name_); | 36 product_name_)); |
| 37 explanation_text = l10n_util::GetStringFUTF16( | 37 explanation_text = UTF16ToWide(l10n_util::GetStringFUTF16( |
| 38 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, | 38 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, |
| 39 product_name_); | 39 product_name_)); |
| 40 ok_button_text_ = l10n_util::GetStringUTF16( | 40 ok_button_text_ = UTF16ToWide(l10n_util::GetStringUTF16( |
| 41 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL); | 41 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL)); |
| 42 cancel_button_text_ = l10n_util::GetStringUTF16( | 42 cancel_button_text_ = UTF16ToWide(l10n_util::GetStringUTF16( |
| 43 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL); | 43 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL)); |
| 44 } else { | 44 } else { |
| 45 warning_text = l10n_util::GetStringFUTF16( | 45 warning_text = UTF16ToWide(l10n_util::GetStringFUTF16( |
| 46 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING, | 46 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING, |
| 47 product_name_, | 47 product_name_, |
| 48 UTF8ToUTF16(base::IntToString(download_count))); | 48 UTF8ToUTF16(base::IntToString(download_count)))); |
| 49 explanation_text = l10n_util::GetStringFUTF16( | 49 explanation_text = UTF16ToWide(l10n_util::GetStringFUTF16( |
| 50 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION, | 50 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION, |
| 51 product_name_); | 51 product_name_)); |
| 52 ok_button_text_ = l10n_util::GetStringUTF16( | 52 ok_button_text_ = UTF16ToWide(l10n_util::GetStringUTF16( |
| 53 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_OK_BUTTON_LABEL); | 53 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_OK_BUTTON_LABEL)); |
| 54 cancel_button_text_ = l10n_util::GetStringUTF16( | 54 cancel_button_text_ = UTF16ToWide(l10n_util::GetStringUTF16( |
| 55 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL); | 55 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // There are two lines of text: the bold warning label and the text | 58 // There are two lines of text: the bold warning label and the text |
| 59 // explanation label. | 59 // explanation label. |
| 60 views::GridLayout* layout = new views::GridLayout(this); | 60 views::GridLayout* layout = new views::GridLayout(this); |
| 61 SetLayoutManager(layout); | 61 SetLayoutManager(layout); |
| 62 const int columnset_id = 0; | 62 const int columnset_id = 0; |
| 63 views::ColumnSet* column_set = layout->AddColumnSet(columnset_id); | 63 views::ColumnSet* column_set = layout->AddColumnSet(columnset_id); |
| 64 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::LEADING, 1, | 64 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::LEADING, 1, |
| 65 views::GridLayout::USE_PREF, 0, 0); | 65 views::GridLayout::USE_PREF, 0, 0); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 93 | 93 |
| 94 DownloadInProgressDialogView::~DownloadInProgressDialogView() {} | 94 DownloadInProgressDialogView::~DownloadInProgressDialogView() {} |
| 95 | 95 |
| 96 gfx::Size DownloadInProgressDialogView::GetPreferredSize() { | 96 gfx::Size DownloadInProgressDialogView::GetPreferredSize() { |
| 97 return dialog_dimensions_; | 97 return dialog_dimensions_; |
| 98 } | 98 } |
| 99 | 99 |
| 100 std::wstring DownloadInProgressDialogView::GetDialogButtonLabel( | 100 std::wstring DownloadInProgressDialogView::GetDialogButtonLabel( |
| 101 MessageBoxFlags::DialogButton button) const { | 101 MessageBoxFlags::DialogButton button) const { |
| 102 if (button == MessageBoxFlags::DIALOGBUTTON_OK) | 102 if (button == MessageBoxFlags::DIALOGBUTTON_OK) |
| 103 return UTF16ToWideHack(ok_button_text_); | 103 return ok_button_text_; |
| 104 | 104 |
| 105 DCHECK_EQ(MessageBoxFlags::DIALOGBUTTON_CANCEL, button); | 105 DCHECK_EQ(MessageBoxFlags::DIALOGBUTTON_CANCEL, button); |
| 106 return UTF16ToWideHack(cancel_button_text_); | 106 return cancel_button_text_; |
| 107 } | 107 } |
| 108 | 108 |
| 109 int DownloadInProgressDialogView::GetDefaultDialogButton() const { | 109 int DownloadInProgressDialogView::GetDefaultDialogButton() const { |
| 110 return MessageBoxFlags::DIALOGBUTTON_CANCEL; | 110 return MessageBoxFlags::DIALOGBUTTON_CANCEL; |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool DownloadInProgressDialogView::Cancel() { | 113 bool DownloadInProgressDialogView::Cancel() { |
| 114 browser_->InProgressDownloadResponse(false); | 114 browser_->InProgressDownloadResponse(false); |
| 115 return true; | 115 return true; |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool DownloadInProgressDialogView::Accept() { | 118 bool DownloadInProgressDialogView::Accept() { |
| 119 browser_->InProgressDownloadResponse(true); | 119 browser_->InProgressDownloadResponse(true); |
| 120 return true; | 120 return true; |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool DownloadInProgressDialogView::IsModal() const { | 123 bool DownloadInProgressDialogView::IsModal() const { |
| 124 return true; | 124 return true; |
| 125 } | 125 } |
| 126 | 126 |
| 127 string16 DownloadInProgressDialogView::GetWindowTitle() const { | 127 string16 DownloadInProgressDialogView::GetWindowTitle() const { |
| 128 return product_name_; | 128 return product_name_; |
| 129 } | 129 } |
| 130 | 130 |
| 131 views::View* DownloadInProgressDialogView::GetContentsView() { | 131 views::View* DownloadInProgressDialogView::GetContentsView() { |
| 132 return this; | 132 return this; |
| 133 } | 133 } |
| OLD | NEW |