| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED); | 248 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED); |
| 249 } else { | 249 } else { |
| 250 status_text.clear(); | 250 status_text.clear(); |
| 251 } | 251 } |
| 252 break; | 252 break; |
| 253 case DownloadItem::CANCELLED: | 253 case DownloadItem::CANCELLED: |
| 254 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CANCELLED); | 254 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CANCELLED); |
| 255 break; | 255 break; |
| 256 case DownloadItem::INTERRUPTED: { | 256 case DownloadItem::INTERRUPTED: { |
| 257 content::DownloadInterruptReason reason = download_->GetLastReason(); | 257 content::DownloadInterruptReason reason = download_->GetLastReason(); |
| 258 // TODO(ahendrickson) -- Add information about whether or not it can be |
| 259 // resumed. |
| 258 if (reason != content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED) { | 260 if (reason != content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED) { |
| 259 string16 interrupt_reason = InterruptReasonStatusMessage(reason); | 261 string16 interrupt_reason = InterruptReasonStatusMessage(reason); |
| 260 status_text = l10n_util::GetStringFUTF16( | 262 status_text = l10n_util::GetStringFUTF16( |
| 261 IDS_DOWNLOAD_STATUS_INTERRUPTED, interrupt_reason); | 263 IDS_DOWNLOAD_STATUS_INTERRUPTED, interrupt_reason); |
| 262 } else { | 264 } else { |
| 263 // Same as DownloadItem::CANCELLED. | 265 // Same as DownloadItem::CANCELLED. |
| 264 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CANCELLED); | 266 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CANCELLED); |
| 265 } | 267 } |
| 266 break; | 268 break; |
| 267 } | 269 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 string16 size_ratio = GetProgressSizesString(); | 426 string16 size_ratio = GetProgressSizesString(); |
| 425 | 427 |
| 426 // The download is a CRX (app, extension, theme, ...) and it is being unpacked | 428 // The download is a CRX (app, extension, theme, ...) and it is being unpacked |
| 427 // and validated. | 429 // and validated. |
| 428 if (download_->AllDataSaved() && | 430 if (download_->AllDataSaved() && |
| 429 download_crx_util::IsExtensionDownload(*download_)) { | 431 download_crx_util::IsExtensionDownload(*download_)) { |
| 430 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CRX_INSTALL_RUNNING); | 432 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CRX_INSTALL_RUNNING); |
| 431 } | 433 } |
| 432 | 434 |
| 433 // A paused download: "100/120 MB, Paused" | 435 // A paused download: "100/120 MB, Paused" |
| 434 if (download_->IsPaused()) { | 436 if (download_->IsPaused() || download_->CanResumeInterrupted()) { |
| 435 return l10n_util::GetStringFUTF16( | 437 return l10n_util::GetStringFUTF16( |
| 436 IDS_DOWNLOAD_STATUS_IN_PROGRESS, size_ratio, | 438 IDS_DOWNLOAD_STATUS_IN_PROGRESS, size_ratio, |
| 437 l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED)); | 439 l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED)); |
| 438 } | 440 } |
| 439 | 441 |
| 440 // A download scheduled to be opened when complete: "Opening in 10 secs" | 442 // A download scheduled to be opened when complete: "Opening in 10 secs" |
| 441 if (download_->GetOpenWhenComplete()) { | 443 if (download_->GetOpenWhenComplete()) { |
| 442 if (!time_remaining_known) | 444 if (!time_remaining_known) |
| 443 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_OPEN_WHEN_COMPLETE); | 445 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_OPEN_WHEN_COMPLETE); |
| 444 | 446 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 455 } | 457 } |
| 456 | 458 |
| 457 // In progress download with no known time left and non-zero completed bytes: | 459 // In progress download with no known time left and non-zero completed bytes: |
| 458 // "100/120 MB" or "100 MB" | 460 // "100/120 MB" or "100 MB" |
| 459 if (GetCompletedBytes() > 0) | 461 if (GetCompletedBytes() > 0) |
| 460 return size_ratio; | 462 return size_ratio; |
| 461 | 463 |
| 462 // Instead of displaying "0 B" we say "Starting..." | 464 // Instead of displaying "0 B" we say "Starting..." |
| 463 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); | 465 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); |
| 464 } | 466 } |
| OLD | NEW |