Index: chrome/browser/download/notification/download_item_notification.cc |
diff --git a/chrome/browser/download/notification/download_item_notification.cc b/chrome/browser/download/notification/download_item_notification.cc |
index 41c1d8d7bbbf43de7ccb30c082e162b32acf2ec9..66b5d26ceaaab825b0a72dc4d23298d6851214e4 100644 |
--- a/chrome/browser/download/notification/download_item_notification.cc |
+++ b/chrome/browser/download/notification/download_item_notification.cc |
@@ -163,9 +163,7 @@ |
content::DownloadItem* item, |
DownloadNotificationManagerForProfile* manager) |
: item_(item), |
- message_center_(manager->message_center()), |
weak_factory_(this) { |
- |
// Creates the notification instance. |title|, |body| and |icon| will be |
// overridden by UpdateNotificationData() below. |
notification_.reset(new Notification( |
@@ -201,6 +199,8 @@ |
} |
void DownloadItemNotification::OnNotificationClose() { |
+ visible_ = false; |
+ |
if (item_ && item_->IsDangerous() && !item_->IsDone()) { |
content::RecordAction( |
UserMetricsAction("DownloadNotification.Close_Dangerous")); |
@@ -314,7 +314,7 @@ |
// MessageCenter instance. |
// Note that: this calling has no side-effect even when the message center |
// is not opened. |
- message_center_->RemoveNotification( |
+ g_browser_process->message_center()->RemoveNotification( |
notification_id_in_message_center, true /* by_user */); |
} |
@@ -331,11 +331,13 @@ |
(download_state == content::DownloadItem::INTERRUPTED && |
previous_download_state_ != content::DownloadItem::INTERRUPTED)); |
- if (IsNotificationVisible()) { |
+ if (visible_) { |
UpdateNotificationData(popup ? UPDATE_AND_POPUP : UPDATE); |
} else { |
- if (show_next_ || popup) |
+ if (show_next_ || popup) { |
UpdateNotificationData(ADD); |
+ visible_ = true; |
+ } |
} |
show_next_ = false; |
@@ -427,7 +429,7 @@ |
// immediately when the message center is visible. |
// See the comment in MessageCenterImpl::UpdateNotification() for detail. |
if (type == UPDATE_AND_POPUP && |
- message_center_->IsMessageCenterVisible() && |
+ g_browser_process->message_center()->IsMessageCenterVisible() && |
(item_->GetState() == content::DownloadItem::COMPLETE || |
item_->GetState() == content::DownloadItem::INTERRUPTED)) { |
DCHECK_EQ(notification_->type(), |
@@ -899,17 +901,12 @@ |
bool DownloadItemNotification::IsNotificationVisible() const { |
const std::string& notification_id = watcher()->id(); |
const ProfileID profile_id = NotificationUIManager::GetProfileID(profile()); |
- if (!g_browser_process->notification_ui_manager()) |
- return false; |
- const Notification* notification = g_browser_process-> |
- notification_ui_manager()->FindById(notification_id, profile_id); |
- if (!notification) |
- return false; |
- |
- const std::string notification_id_in_message_center = notification->id(); |
+ const std::string notification_id_in_message_center = |
+ ProfileNotification::GetProfileNotificationId(notification_id, |
+ profile_id); |
message_center::NotificationList::Notifications visible_notifications = |
- message_center_->GetVisibleNotifications(); |
+ g_browser_process->message_center()->GetVisibleNotifications(); |
for (const auto& notification : visible_notifications) { |
if (notification->id() == notification_id_in_message_center) |
return true; |