Chromium Code Reviews| Index: chrome/browser/notifications/notification_ui_manager.cc |
| =================================================================== |
| --- chrome/browser/notifications/notification_ui_manager.cc (revision 67750) |
| +++ chrome/browser/notifications/notification_ui_manager.cc (working copy) |
| @@ -10,6 +10,8 @@ |
| #include "chrome/browser/notifications/balloon_collection.h" |
| #include "chrome/browser/notifications/notification.h" |
| #include "chrome/browser/renderer_host/site_instance.h" |
| +#include "chrome/common/notification_service.h" |
| +#include "chrome/common/notification_type.h" |
| // A class which represents a notification waiting to be shown. |
| class QueuedNotification { |
| @@ -38,6 +40,8 @@ |
| NotificationUIManager::NotificationUIManager() |
| : balloon_collection_(NULL) { |
| + registrar_.Add(this, NotificationType::APP_TERMINATING, |
| + NotificationService::AllSources()); |
| } |
| NotificationUIManager::~NotificationUIManager() { |
| @@ -96,6 +100,11 @@ |
| return balloon_collection_->RemoveBySourceOrigin(source) || removed; |
| } |
| +void NotificationUIManager::CancelAll() { |
| + STLDeleteElements(&show_queue_); |
| + balloon_collection_->RemoveAll(); |
| +} |
| + |
| void NotificationUIManager::CheckAndShowNotifications() { |
| // TODO(johnnyg): http://crbug.com/25061 - Check for user idle/presentation. |
| ShowNotifications(); |
| @@ -147,3 +156,12 @@ |
| return false; |
| } |
| + |
| +void NotificationUIManager::Observe(NotificationType type, |
| + const NotificationSource& source, |
| + const NotificationDetails& details) { |
| + if (type == NotificationType::APP_TERMINATING) |
| + CancelAll(); |
|
Andrew T Wilson (Slow)
2010/12/01 01:55:56
Could also be CHECK(type == NotificationType::APP_
|
| + else |
| + NOTREACHED(); |
| +} |