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 20 matching lines...) Expand all Loading... | |
31 | 31 |
32 DownloadInProgressDialogView::DownloadInProgressDialogView( | 32 DownloadInProgressDialogView::DownloadInProgressDialogView( |
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) { |
Peter Kasting
2015/05/12 21:52:03
Nit: Simpler:
DCHECK_NE(Browser::DOWNLOAD_CLOSE
| |
42 case Browser::DOWNLOAD_CLOSE_BROWSER_SHUTDOWN: | 42 case Browser::DOWNLOAD_CLOSE_BROWSER_SHUTDOWN: |
43 if (download_count == 1) { | 43 explanation_text = l10n_util::GetPluralStringFUTF16( |
44 title_text_ = l10n_util::GetStringUTF16( | 44 IDS_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, download_count); |
45 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_TITLE); | |
46 explanation_text = l10n_util::GetStringUTF16( | |
47 IDS_SINGLE_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION); | |
48 } else { | |
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; | 45 break; |
57 case Browser::DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE: | 46 case Browser::DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE: |
58 if (download_count == 1) { | 47 explanation_text = l10n_util::GetPluralStringFUTF16( |
59 title_text_ = l10n_util::GetStringUTF16( | 48 IDS_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION, download_count); |
60 IDS_SINGLE_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_TITLE); | |
61 explanation_text = l10n_util::GetStringUTF16( | |
62 IDS_SINGLE_INCOGNITO_DOWNLOAD_REMOVE_CONFIRM_EXPLANATION); | |
63 } else { | |
64 title_text_ = l10n_util::GetStringUTF16( | |
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; | 49 break; |
72 default: | 50 default: |
73 // This dialog should have been created within the same thread invocation | 51 // 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 | 52 // as the original test that lead to us, so it should always not be ok |
75 // to close. | 53 // to close. |
76 NOTREACHED(); | 54 NOTREACHED(); |
77 } | 55 } |
78 cancel_button_text_ = l10n_util::GetStringUTF16( | 56 title_text_ = l10n_util::GetPluralStringFUTF16( |
79 IDS_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL); | 57 IDS_DOWNLOAD_REMOVE_CONFIRM_TITLE, download_count); |
58 ok_button_text_ = l10n_util::GetPluralStringFUTF16( | |
59 IDS_DOWNLOAD_REMOVE_CONFIRM_OK_BUTTON_LABEL, download_count); | |
60 cancel_button_text_ = l10n_util::GetPluralStringFUTF16( | |
61 IDS_DOWNLOAD_REMOVE_CONFIRM_CANCEL_BUTTON_LABEL, download_count); | |
80 | 62 |
81 message_box_view_ = new views::MessageBoxView( | 63 message_box_view_ = new views::MessageBoxView( |
82 views::MessageBoxView::InitParams(explanation_text)); | 64 views::MessageBoxView::InitParams(explanation_text)); |
83 } | 65 } |
84 | 66 |
85 DownloadInProgressDialogView::~DownloadInProgressDialogView() {} | 67 DownloadInProgressDialogView::~DownloadInProgressDialogView() {} |
86 | 68 |
87 int DownloadInProgressDialogView::GetDefaultDialogButton() const { | 69 int DownloadInProgressDialogView::GetDefaultDialogButton() const { |
88 return ui::DIALOG_BUTTON_CANCEL; | 70 return ui::DIALOG_BUTTON_CANCEL; |
89 } | 71 } |
(...skipping 30 matching lines...) Expand all Loading... | |
120 return message_box_view_->GetWidget(); | 102 return message_box_view_->GetWidget(); |
121 } | 103 } |
122 | 104 |
123 const views::Widget* DownloadInProgressDialogView::GetWidget() const { | 105 const views::Widget* DownloadInProgressDialogView::GetWidget() const { |
124 return message_box_view_->GetWidget(); | 106 return message_box_view_->GetWidget(); |
125 } | 107 } |
126 | 108 |
127 views::View* DownloadInProgressDialogView::GetContentsView() { | 109 views::View* DownloadInProgressDialogView::GetContentsView() { |
128 return message_box_view_; | 110 return message_box_view_; |
129 } | 111 } |
OLD | NEW |