summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/download/notification/download_item_notification.cc14
-rw-r--r--chrome/browser/download/notification/download_notification_browsertest.cc8
2 files changed, 15 insertions, 7 deletions
diff --git a/chrome/browser/download/notification/download_item_notification.cc b/chrome/browser/download/notification/download_item_notification.cc
index 98828b8..8209d0e 100644
--- a/chrome/browser/download/notification/download_item_notification.cc
+++ b/chrome/browser/download/notification/download_item_notification.cc
@@ -245,9 +245,16 @@ void DownloadItemNotification::UpdateNotificationData(
item_->GetBrowserContext()->IsOffTheRecord();
switch (item_->GetState()) {
- case content::DownloadItem::IN_PROGRESS:
- notification_->set_type(message_center::NOTIFICATION_TYPE_PROGRESS);
- notification_->set_progress(item_->PercentComplete());
+ case content::DownloadItem::IN_PROGRESS: {
+ int percent_complete = item_->PercentComplete();
+ if (percent_complete >= 0) {
+ notification_->set_type(message_center::NOTIFICATION_TYPE_PROGRESS);
+ notification_->set_progress(percent_complete);
+ } else {
+ notification_->set_type(
+ message_center::NOTIFICATION_TYPE_BASE_FORMAT);
+ notification_->set_progress(0);
+ }
if (is_off_the_record) {
// TODO(yoshiki): Replace the tentative image.
SetNotificationIcon(IDR_DOWNLOAD_NOTIFICATION_INCOGNITO);
@@ -255,6 +262,7 @@ void DownloadItemNotification::UpdateNotificationData(
SetNotificationIcon(IDR_DOWNLOAD_NOTIFICATION_DOWNLOADING);
}
break;
+ }
case content::DownloadItem::COMPLETE:
DCHECK(item_->IsDone());
diff --git a/chrome/browser/download/notification/download_notification_browsertest.cc b/chrome/browser/download/notification/download_notification_browsertest.cc
index 0b75a01..e8045b8 100644
--- a/chrome/browser/download/notification/download_notification_browsertest.cc
+++ b/chrome/browser/download/notification/download_notification_browsertest.cc
@@ -928,7 +928,7 @@ IN_PROC_BROWSER_TEST_F(DownloadNotificationTest,
EXPECT_EQ(download_incognito, downloads[0]);
// Confirms the types of download notifications are correct.
- EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS,
+ EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
GetNotification(notification_id1)->type());
EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS,
GetNotification(notification_id2)->type());
@@ -1096,7 +1096,7 @@ IN_PROC_BROWSER_TEST_F(MultiProfileDownloadNotificationTest,
// Confirms the types of download notifications are correct.
// Normal notification for user1.
- EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS,
+ EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
GetNotification(notification_id_user1)->type());
// Group notification for user2.
EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE,
@@ -1104,9 +1104,9 @@ IN_PROC_BROWSER_TEST_F(MultiProfileDownloadNotificationTest,
EXPECT_EQ(2u,
GetNotification(notification_id_user2_group)->items().size());
// Normal notification for user2.
- EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS,
+ EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
GetNotification(notification_id_user2_1)->type());
- EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS,
+ EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
GetNotification(notification_id_user2_2)->type());
// Requests to complete the downloads.