| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/notification_ui_manager.h" | 5 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "chrome/browser/notifications/balloon_collection.h" | 10 #include "chrome/browser/notifications/balloon_collection.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 // If it has been shown, remove it from the balloon collections. | 82 // If it has been shown, remove it from the balloon collections. |
| 83 return balloon_collection_->RemoveById(id); | 83 return balloon_collection_->RemoveById(id); |
| 84 } | 84 } |
| 85 | 85 |
| 86 bool NotificationUIManager::CancelAllBySourceOrigin(const GURL& source) { | 86 bool NotificationUIManager::CancelAllBySourceOrigin(const GURL& source) { |
| 87 // Same pattern as CancelById, but more complicated than the above | 87 // Same pattern as CancelById, but more complicated than the above |
| 88 // because there may be multiple notifications from the same source. | 88 // because there may be multiple notifications from the same source. |
| 89 bool removed = false; | 89 bool removed = false; |
| 90 NotificationDeque::iterator iter; | 90 NotificationDeque::iterator iter; |
| 91 for (iter = show_queue_.begin(); iter != show_queue_.end(); ++iter) { | 91 for (iter = show_queue_.begin(); iter != show_queue_.end();) { |
| 92 if ((*iter)->notification().origin_url() == source) { | 92 if ((*iter)->notification().origin_url() == source) { |
| 93 iter = show_queue_.erase(iter); | 93 iter = show_queue_.erase(iter); |
| 94 removed = true; | 94 removed = true; |
| 95 } else { | 95 } else { |
| 96 ++iter; | 96 ++iter; |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 return balloon_collection_->RemoveBySourceOrigin(source) || removed; | 100 return balloon_collection_->RemoveBySourceOrigin(source) || removed; |
| 101 } | 101 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 void NotificationUIManager::Observe(NotificationType type, | 160 void NotificationUIManager::Observe(NotificationType type, |
| 161 const NotificationSource& source, | 161 const NotificationSource& source, |
| 162 const NotificationDetails& details) { | 162 const NotificationDetails& details) { |
| 163 if (type == NotificationType::APP_TERMINATING) | 163 if (type == NotificationType::APP_TERMINATING) |
| 164 CancelAll(); | 164 CancelAll(); |
| 165 else | 165 else |
| 166 NOTREACHED(); | 166 NOTREACHED(); |
| 167 } | 167 } |
| OLD | NEW |