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/download/download_item_model.h" | 5 #include "chrome/browser/download/download_item_model.h" |
6 | 6 |
7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 ui::ElideFilename(download_->GetFileNameToReportUser(), | 131 ui::ElideFilename(download_->GetFileNameToReportUser(), |
132 font, base_width)); | 132 font, base_width)); |
133 } | 133 } |
134 | 134 |
135 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | 135 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: |
136 return l10n_util::GetStringFUTF16( | 136 return l10n_util::GetStringFUTF16( |
137 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, | 137 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, |
138 ui::ElideFilename(download_->GetFileNameToReportUser(), | 138 ui::ElideFilename(download_->GetFileNameToReportUser(), |
139 font, base_width)); | 139 font, base_width)); |
140 | 140 |
| 141 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: |
| 142 return l10n_util::GetStringFUTF16( |
| 143 IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT, |
| 144 ui::ElideFilename(download_->GetFileNameToReportUser(), |
| 145 font, base_width)); |
| 146 |
141 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: | 147 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: |
142 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: | 148 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: |
143 case content::DOWNLOAD_DANGER_TYPE_MAX: | 149 case content::DOWNLOAD_DANGER_TYPE_MAX: |
144 NOTREACHED(); | 150 NOTREACHED(); |
145 } | 151 } |
146 return string16(); | 152 return string16(); |
147 } | 153 } |
148 | 154 |
149 string16 DownloadItemModel::GetWarningConfirmButtonText() { | 155 string16 DownloadItemModel::GetWarningConfirmButtonText() { |
150 // Should only be called if IsDangerous() | 156 // Should only be called if IsDangerous() |
151 DCHECK(IsDangerous()); | 157 DCHECK(IsDangerous()); |
152 if (download_->GetDangerType() == | 158 if (download_->GetDangerType() == |
153 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE && | 159 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE && |
154 ChromeDownloadManagerDelegate::IsExtensionDownload(download_)) { | 160 ChromeDownloadManagerDelegate::IsExtensionDownload(download_)) { |
155 return l10n_util::GetStringUTF16(IDS_CONTINUE_EXTENSION_DOWNLOAD); | 161 return l10n_util::GetStringUTF16(IDS_CONTINUE_EXTENSION_DOWNLOAD); |
156 } else { | 162 } else { |
157 return l10n_util::GetStringUTF16(IDS_CONFIRM_DOWNLOAD); | 163 return l10n_util::GetStringUTF16(IDS_CONFIRM_DOWNLOAD); |
158 } | 164 } |
159 } | 165 } |
160 | 166 |
161 bool DownloadItemModel::IsMalicious() { | 167 bool DownloadItemModel::IsMalicious() { |
162 if (!IsDangerous()) | 168 if (!IsDangerous()) |
163 return false; | 169 return false; |
164 switch (download_->GetDangerType()) { | 170 switch (download_->GetDangerType()) { |
165 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: | 171 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: |
166 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | 172 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: |
| 173 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: |
167 return true; | 174 return true; |
168 | 175 |
169 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: | 176 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: |
170 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: | 177 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: |
171 case content::DOWNLOAD_DANGER_TYPE_MAX: | 178 case content::DOWNLOAD_DANGER_TYPE_MAX: |
172 // We shouldn't get any of these due to the IsDangerous() test above. | 179 // We shouldn't get any of these due to the IsDangerous() test above. |
173 NOTREACHED(); | 180 NOTREACHED(); |
174 // Fallthrough. | 181 // Fallthrough. |
175 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | 182 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: |
176 return false; | 183 return false; |
177 } | 184 } |
178 NOTREACHED(); | 185 NOTREACHED(); |
179 return false; | 186 return false; |
180 } | 187 } |
181 | 188 |
182 bool DownloadItemModel::IsDangerous() { | 189 bool DownloadItemModel::IsDangerous() { |
183 return download_->GetSafetyState() == DownloadItem::DANGEROUS; | 190 return download_->GetSafetyState() == DownloadItem::DANGEROUS; |
184 } | 191 } |
OLD | NEW |