| 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/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 return l10n_util::GetStringUTF16( | 295 return l10n_util::GetStringUTF16( |
| 296 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); | 296 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); |
| 297 } else { | 297 } else { |
| 298 return l10n_util::GetStringFUTF16( | 298 return l10n_util::GetStringFUTF16( |
| 299 IDS_PROMPT_DANGEROUS_DOWNLOAD, | 299 IDS_PROMPT_DANGEROUS_DOWNLOAD, |
| 300 ui::ElideFilename(download_->GetFileNameToReportUser(), | 300 ui::ElideFilename(download_->GetFileNameToReportUser(), |
| 301 font, base_width)); | 301 font, base_width)); |
| 302 } | 302 } |
| 303 | 303 |
| 304 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | 304 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: |
| 305 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: |
| 305 return l10n_util::GetStringFUTF16( | 306 return l10n_util::GetStringFUTF16( |
| 306 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, | 307 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, |
| 307 ui::ElideFilename(download_->GetFileNameToReportUser(), | 308 ui::ElideFilename(download_->GetFileNameToReportUser(), |
| 308 font, base_width)); | 309 font, base_width)); |
| 309 | 310 |
| 310 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: | 311 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: |
| 311 return l10n_util::GetStringFUTF16( | 312 return l10n_util::GetStringFUTF16( |
| 312 IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT, | 313 IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT, |
| 313 ui::ElideFilename(download_->GetFileNameToReportUser(), | 314 ui::ElideFilename(download_->GetFileNameToReportUser(), |
| 314 font, base_width)); | 315 font, base_width)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 return download_->IsDangerous(); | 355 return download_->IsDangerous(); |
| 355 } | 356 } |
| 356 | 357 |
| 357 bool DownloadItemModel::IsMalicious() const { | 358 bool DownloadItemModel::IsMalicious() const { |
| 358 if (!IsDangerous()) | 359 if (!IsDangerous()) |
| 359 return false; | 360 return false; |
| 360 switch (download_->GetDangerType()) { | 361 switch (download_->GetDangerType()) { |
| 361 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: | 362 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: |
| 362 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | 363 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: |
| 363 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: | 364 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: |
| 365 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: |
| 364 return true; | 366 return true; |
| 365 | 367 |
| 366 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: | 368 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: |
| 367 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: | 369 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: |
| 368 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: | 370 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: |
| 369 case content::DOWNLOAD_DANGER_TYPE_MAX: | 371 case content::DOWNLOAD_DANGER_TYPE_MAX: |
| 370 // We shouldn't get any of these due to the IsDangerous() test above. | 372 // We shouldn't get any of these due to the IsDangerous() test above. |
| 371 NOTREACHED(); | 373 NOTREACHED(); |
| 372 // Fallthrough. | 374 // Fallthrough. |
| 373 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | 375 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 484 } |
| 483 | 485 |
| 484 // In progress download with no known time left and non-zero completed bytes: | 486 // In progress download with no known time left and non-zero completed bytes: |
| 485 // "100/120 MB" or "100 MB" | 487 // "100/120 MB" or "100 MB" |
| 486 if (GetCompletedBytes() > 0) | 488 if (GetCompletedBytes() > 0) |
| 487 return size_ratio; | 489 return size_ratio; |
| 488 | 490 |
| 489 // Instead of displaying "0 B" we say "Starting..." | 491 // Instead of displaying "0 B" we say "Starting..." |
| 490 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); | 492 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); |
| 491 } | 493 } |
| OLD | NEW |