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/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, | 322 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, |
323 ui::ElideFilename(download_->GetFileNameToReportUser(), | 323 ui::ElideFilename(download_->GetFileNameToReportUser(), |
324 font, base_width)); | 324 font, base_width)); |
325 | 325 |
326 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: | 326 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: |
327 return l10n_util::GetStringFUTF16( | 327 return l10n_util::GetStringFUTF16( |
328 IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT, | 328 IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT, |
329 ui::ElideFilename(download_->GetFileNameToReportUser(), | 329 ui::ElideFilename(download_->GetFileNameToReportUser(), |
330 font, base_width)); | 330 font, base_width)); |
331 | 331 |
332 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: | |
333 return l10n_util::GetStringFUTF16( | |
334 IDS_PROMPT_POTENTIALLY_UNWANTED_DOWNLOAD, | |
335 ui::ElideFilename(download_->GetFileNameToReportUser(), | |
benjhayden
2013/07/22 20:16:19
pre-compute elided_filename to reduce code duplica
asanka
2013/07/23 15:10:36
Done.
| |
336 font, base_width)); | |
337 | |
332 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: | 338 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: |
333 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: | 339 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: |
334 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: | 340 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: |
335 case content::DOWNLOAD_DANGER_TYPE_MAX: | 341 case content::DOWNLOAD_DANGER_TYPE_MAX: |
336 NOTREACHED(); | 342 break; |
337 } | 343 } |
344 NOTREACHED(); | |
338 return string16(); | 345 return string16(); |
339 } | 346 } |
340 | 347 |
341 string16 DownloadItemModel::GetWarningConfirmButtonText() const { | 348 string16 DownloadItemModel::GetWarningConfirmButtonText() const { |
342 // Should only be called if IsDangerous() | 349 // Should only be called if IsDangerous() |
343 DCHECK(IsDangerous()); | 350 DCHECK(IsDangerous()); |
344 if (download_->GetDangerType() == | 351 if (download_->GetDangerType() == |
345 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE && | 352 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE && |
346 download_crx_util::IsExtensionDownload(*download_)) { | 353 download_crx_util::IsExtensionDownload(*download_)) { |
347 return l10n_util::GetStringUTF16(IDS_CONTINUE_EXTENSION_DOWNLOAD); | 354 return l10n_util::GetStringUTF16(IDS_CONTINUE_EXTENSION_DOWNLOAD); |
(...skipping 23 matching lines...) Expand all Loading... | |
371 } | 378 } |
372 | 379 |
373 bool DownloadItemModel::IsMalicious() const { | 380 bool DownloadItemModel::IsMalicious() const { |
374 if (!IsDangerous()) | 381 if (!IsDangerous()) |
375 return false; | 382 return false; |
376 switch (download_->GetDangerType()) { | 383 switch (download_->GetDangerType()) { |
377 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: | 384 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: |
378 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | 385 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: |
379 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: | 386 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: |
380 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: | 387 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: |
388 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: | |
381 return true; | 389 return true; |
382 | 390 |
383 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: | 391 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: |
384 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: | 392 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: |
385 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: | 393 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: |
386 case content::DOWNLOAD_DANGER_TYPE_MAX: | 394 case content::DOWNLOAD_DANGER_TYPE_MAX: |
387 // We shouldn't get any of these due to the IsDangerous() test above. | 395 // We shouldn't get any of these due to the IsDangerous() test above. |
388 NOTREACHED(); | 396 NOTREACHED(); |
389 // Fallthrough. | 397 // Fallthrough. |
390 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | 398 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 } | 536 } |
529 | 537 |
530 // In progress download with no known time left and non-zero completed bytes: | 538 // In progress download with no known time left and non-zero completed bytes: |
531 // "100/120 MB" or "100 MB" | 539 // "100/120 MB" or "100 MB" |
532 if (GetCompletedBytes() > 0) | 540 if (GetCompletedBytes() > 0) |
533 return size_ratio; | 541 return size_ratio; |
534 | 542 |
535 // Instead of displaying "0 B" we say "Starting..." | 543 // Instead of displaying "0 B" we say "Starting..." |
536 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); | 544 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); |
537 } | 545 } |
OLD | NEW |