diff options
-rw-r--r-- | chrome/app/generated_resources.grd | 3 | ||||
-rw-r--r-- | chrome/browser/download/download_item_model.h | 2 | ||||
-rw-r--r-- | chrome/browser/download/notification/download_group_notification.cc | 55 |
3 files changed, 58 insertions, 2 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index b14fffb..f71226f 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -1962,6 +1962,9 @@ Psst! Incognito mode <ph name="SHORTCUT_KEY">$1<ex>(Ctrl+Shift+N)</ex></ph> may <message name="IDS_DOWNLOAD_STATUS_INTERRUPTED" desc="Status text for a download item that was interrupted."> Failed - <ph name="INTERRUPT_REASON">$1<ex>Disk full</ex></ph> </message> + <message name="IDS_DOWNLOAD_STATUS_COMPLETED" desc="Status text for download item that was completed."> + Completed + </message> <message name="IDS_DOWNLOAD_UNCONFIRMED_PREFIX" desc="The prefix used in the unconfirmed download file."> Unconfirmed </message> diff --git a/chrome/browser/download/download_item_model.h b/chrome/browser/download/download_item_model.h index ee6fb0c..5cc4ddb 100644 --- a/chrome/browser/download/download_item_model.h +++ b/chrome/browser/download/download_item_model.h @@ -160,7 +160,6 @@ class DownloadItemModel { content::DownloadItem* download() { return download_; } - private: // Returns a string representations of the current download progress sizes. If // the total size of the download is known, this string looks like: "100/200 // MB" where the numerator is the transferred size and the denominator is the @@ -168,6 +167,7 @@ class DownloadItemModel { // string (e.g.: "100 MB"). base::string16 GetProgressSizesString() const; + private: // Returns a string indicating the status of an in-progress download. base::string16 GetInProgressStatusString() const; diff --git a/chrome/browser/download/notification/download_group_notification.cc b/chrome/browser/download/notification/download_group_notification.cc index cb9f283..321a20c 100644 --- a/chrome/browser/download/notification/download_group_notification.cc +++ b/chrome/browser/download/notification/download_group_notification.cc @@ -9,6 +9,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/download/download_crx_util.h" #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" #include "chrome/common/url_constants.h" @@ -35,6 +36,58 @@ base::string16 TruncateFilename(const base::FilePath& filename) { kMaxFilenameWidth); } +base::string16 GetStatusString(content::DownloadItem* download) { + switch (download->GetState()) { + case content::DownloadItem::IN_PROGRESS: + // "Adding to Chrome..." + if (download->AllDataSaved() && + download_crx_util::IsExtensionDownload(*download)) { + return l10n_util::GetStringUTF16( + IDS_DOWNLOAD_STATUS_CRX_INSTALL_RUNNING); + } + + // "Paused" + if (download->IsPaused()) + return l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); + + // "100/120 MB" or "100 MB" + if (download->GetReceivedBytes() > 0) { + DownloadItemModel model(download); + return model.GetProgressSizesString(); + } + + // "Starting..." + return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); + case content::DownloadItem::COMPLETE: + // "Removed" or "Completed" + if (download->GetFileExternallyRemoved()) + return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_REMOVED); + else + return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_COMPLETED); + case content::DownloadItem::CANCELLED: + // "Cancelled" + return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CANCELLED); + case content::DownloadItem::INTERRUPTED: { + content::DownloadInterruptReason reason = download->GetLastReason(); + if (reason != content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED) { + // "Failed - <REASON>" + DownloadItemModel model(download); + base::string16 interrupt_reason = model.GetInterruptReasonText(); + return l10n_util::GetStringFUTF16( + IDS_DOWNLOAD_STATUS_INTERRUPTED, interrupt_reason); + } + + // Same as DownloadItem::CANCELLED. + return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CANCELLED); + } + case content::DownloadItem::MAX_DOWNLOAD_STATE: + break; + } + + NOTREACHED(); + return base::string16(); +} + } // anonymous namespace DownloadGroupNotification::DownloadGroupNotification( @@ -197,7 +250,7 @@ void DownloadGroupNotification::UpdateNotificationData() { // TODO(yoshiki): Use emplace_back when C++11 becomes allowed. subitems.push_back(message_center::NotificationItem( truncated_filename_cache_[download].truncated_filename, - model.GetStatusText())); + GetStatusString(download))); if (!download->IsDone()) all_finished = false; |