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/notifications/message_center_notification_manager.h" | 5 #include "chrome/browser/notifications/message_center_notification_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // MessageCenter::Observer | 300 // MessageCenter::Observer |
301 void MessageCenterNotificationManager::OnNotificationRemoved( | 301 void MessageCenterNotificationManager::OnNotificationRemoved( |
302 const std::string& notification_id, | 302 const std::string& notification_id, |
303 bool by_user) { | 303 bool by_user) { |
304 // Do not call FindProfileNotification(). Some tests create notifications | 304 // Do not call FindProfileNotification(). Some tests create notifications |
305 // directly to MessageCenter, but this method will be called for the removals | 305 // directly to MessageCenter, but this method will be called for the removals |
306 // of such notifications. | 306 // of such notifications. |
307 NotificationMap::const_iterator iter = | 307 NotificationMap::const_iterator iter = |
308 profile_notifications_.find(notification_id); | 308 profile_notifications_.find(notification_id); |
309 if (iter != profile_notifications_.end()) | 309 if (iter != profile_notifications_.end()) |
310 RemoveProfileNotification(iter->second, by_user); | 310 RemoveProfileNotification(iter->second); |
311 | 311 |
312 #if defined(OS_WIN) | 312 #if defined(OS_WIN) |
313 CheckFirstRunTimer(); | 313 CheckFirstRunTimer(); |
314 #endif | 314 #endif |
315 } | 315 } |
316 | 316 |
317 void MessageCenterNotificationManager::OnNotificationCenterClosed() { | 317 void MessageCenterNotificationManager::OnNotificationCenterClosed() { |
318 // When the center is open it halts all notifications, so we need to listen | 318 // When the center is open it halts all notifications, so we need to listen |
319 // for events indicating it's been closed. | 319 // for events indicating it's been closed. |
320 CheckAndShowNotifications(); | 320 CheckAndShowNotifications(); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 scoped_ptr<message_center::Notification> message_center_notification( | 542 scoped_ptr<message_center::Notification> message_center_notification( |
543 new message_center::Notification(notification)); | 543 new message_center::Notification(notification)); |
544 message_center_notification->set_extension_id( | 544 message_center_notification->set_extension_id( |
545 profile_notification->GetExtensionId()); | 545 profile_notification->GetExtensionId()); |
546 message_center_->AddNotification(message_center_notification.Pass()); | 546 message_center_->AddNotification(message_center_notification.Pass()); |
547 | 547 |
548 profile_notification->StartDownloads(); | 548 profile_notification->StartDownloads(); |
549 } | 549 } |
550 | 550 |
551 void MessageCenterNotificationManager::RemoveProfileNotification( | 551 void MessageCenterNotificationManager::RemoveProfileNotification( |
552 ProfileNotification* profile_notification, | 552 ProfileNotification* profile_notification) { |
553 bool by_user) { | |
554 profile_notification->notification().Close(by_user); | |
555 std::string id = profile_notification->notification().notification_id(); | 553 std::string id = profile_notification->notification().notification_id(); |
556 profile_notifications_.erase(id); | 554 profile_notifications_.erase(id); |
557 delete profile_notification; | 555 delete profile_notification; |
558 } | 556 } |
559 | 557 |
560 MessageCenterNotificationManager::ProfileNotification* | 558 MessageCenterNotificationManager::ProfileNotification* |
561 MessageCenterNotificationManager::FindProfileNotification( | 559 MessageCenterNotificationManager::FindProfileNotification( |
562 const std::string& id) const { | 560 const std::string& id) const { |
563 NotificationMap::const_iterator iter = profile_notifications_.find(id); | 561 NotificationMap::const_iterator iter = profile_notifications_.find(id); |
564 if (iter == profile_notifications_.end()) | 562 if (iter == profile_notifications_.end()) |
565 return NULL; | 563 return NULL; |
566 | 564 |
567 return (*iter).second; | 565 return (*iter).second; |
568 } | 566 } |
OLD | NEW |