| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/grit/chromium_strings.h" | 10 #include "chrome/grit/chromium_strings.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 int download_count, | 33 int download_count, |
| 34 Browser::DownloadClosePreventionType dialog_type, | 34 Browser::DownloadClosePreventionType dialog_type, |
| 35 bool app_modal, | 35 bool app_modal, |
| 36 const base::Callback<void(bool)>& callback) | 36 const base::Callback<void(bool)>& callback) |
| 37 : app_modal_(app_modal), | 37 : app_modal_(app_modal), |
| 38 callback_(callback), | 38 callback_(callback), |
| 39 message_box_view_(NULL) { | 39 message_box_view_(NULL) { |
| 40 base::string16 explanation_text; | 40 base::string16 explanation_text; |
| 41 switch (dialog_type) { | 41 switch (dialog_type) { |
| 42 case Browser::DOWNLOAD_CLOSE_BROWSER_SHUTDOWN: | 42 case Browser::DOWNLOAD_CLOSE_BROWSER_SHUTDOWN: |
| 43 if (download_count == 1) { | 43 title_text_ = l10n_util::GetPluralStringFUTF16( |
| 44 title_text_ = l10n_util::GetStringUTF16( | 44 IDS_DOWNLOAD_REMOVE_CONFIRM_TITLE, download_count); |
| 45 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_TITLE); | 45 explanation_text = l10n_util::GetPluralStringFUTF16( |
| 46 explanation_text = l10n_util::GetStringUTF16( | 46 IDS_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, download_count); |
| 47 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION); | 47 ok_button_text_ = l10n_util::GetPluralStringFUTF16( |
| 48 } else { | 48 IDS_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL, download_count); |
| 49 title_text_ = l10n_util::GetStringUTF16( | |
| 50 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_TITLE); | |
| 51 explanation_text = l10n_util::GetStringUTF16( | |
| 52 IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION); | |
| 53 } | |
| 54 ok_button_text_ = l10n_util::GetStringUTF16( | |
| 55 IDS_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL); | |
| 56 break; | 49 break; |
| 57 case Browser::DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE: | 50 case Browser::DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE: |
| 58 if (download_count == 1) { | 51 title_text_ = l10n_util::GetPluralStringFUTF16( |
| 59 title_text_ = l10n_util::GetStringUTF16( | 52 IDS_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_TITLE, download_count); |
| 60 IDS_SINGLE_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_TITLE); | 53 explanation_text = l10n_util::GetPluralStringFUTF16( |
| 61 explanation_text = l10n_util::GetStringUTF16( | 54 IDS_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, download_count); |
| 62 IDS_SINGLE_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION); | 55 ok_button_text_ = l10n_util::GetPluralStringFUTF16( |
| 63 } else { | 56 IDS_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL, |
| 64 title_text_ = l10n_util::GetStringUTF16( | 57 download_count); |
| 65 IDS_MULTIPLE_INCOGNITO_DOWNLOADS_REMOVE_CONFIRM_TITLE); | |
| 66 explanation_text = l10n_util::GetStringUTF16( | |
| 67 IDS_MULTIPLE_INCOGNITO_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION); | |
| 68 } | |
| 69 ok_button_text_ = l10n_util::GetStringUTF16( | |
| 70 IDS_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL); | |
| 71 break; | 58 break; |
| 72 default: | 59 default: |
| 73 // This dialog should have been created within the same thread invocation | 60 // This dialog should have been created within the same thread invocation |
| 74 // as the original test that lead to us, so it should always not be ok | 61 // as the original test that lead to us, so it should always not be ok |
| 75 // to close. | 62 // to close. |
| 76 NOTREACHED(); | 63 NOTREACHED(); |
| 77 } | 64 } |
| 78 cancel_button_text_ = l10n_util::GetStringUTF16( | 65 cancel_button_text_ = l10n_util::GetPluralStringFUTF16( |
| 79 IDS_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL); | 66 IDS_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL, download_count); |
| 80 | 67 |
| 81 message_box_view_ = new views::MessageBoxView( | 68 message_box_view_ = new views::MessageBoxView( |
| 82 views::MessageBoxView::InitParams(explanation_text)); | 69 views::MessageBoxView::InitParams(explanation_text)); |
| 83 } | 70 } |
| 84 | 71 |
| 85 DownloadInProgressDialogView::~DownloadInProgressDialogView() {} | 72 DownloadInProgressDialogView::~DownloadInProgressDialogView() {} |
| 86 | 73 |
| 87 int DownloadInProgressDialogView::GetDefaultDialogButton() const { | 74 int DownloadInProgressDialogView::GetDefaultDialogButton() const { |
| 88 return ui::DIALOG_BUTTON_CANCEL; | 75 return ui::DIALOG_BUTTON_CANCEL; |
| 89 } | 76 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 120 return message_box_view_->GetWidget(); | 107 return message_box_view_->GetWidget(); |
| 121 } | 108 } |
| 122 | 109 |
| 123 const views::Widget* DownloadInProgressDialogView::GetWidget() const { | 110 const views::Widget* DownloadInProgressDialogView::GetWidget() const { |
| 124 return message_box_view_->GetWidget(); | 111 return message_box_view_->GetWidget(); |
| 125 } | 112 } |
| 126 | 113 |
| 127 views::View* DownloadInProgressDialogView::GetContentsView() { | 114 views::View* DownloadInProgressDialogView::GetContentsView() { |
| 128 return message_box_view_; | 115 return message_box_view_; |
| 129 } | 116 } |
| OLD | NEW |