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/notification_ui_manager_impl.h" | 5 #include "chrome/browser/notifications/notification_ui_manager_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 for (NotificationDeque::iterator iter = show_queue_.begin(); | 88 for (NotificationDeque::iterator iter = show_queue_.begin(); |
89 iter != show_queue_.end(); ++iter) { | 89 iter != show_queue_.end(); ++iter) { |
90 if ((*iter)->notification().notification_id() == id) { | 90 if ((*iter)->notification().notification_id() == id) { |
91 show_queue_.erase(iter); | 91 show_queue_.erase(iter); |
92 return true; | 92 return true; |
93 } | 93 } |
94 } | 94 } |
95 return false; | 95 return false; |
96 } | 96 } |
97 | 97 |
| 98 std::set<std::string> |
| 99 NotificationUIManagerImpl::GetAllIdsByProfileAndSourceOrigin( |
| 100 Profile* profile, |
| 101 const GURL& source) { |
| 102 std::set<std::string> notification_ids; |
| 103 for (NotificationDeque::iterator iter = show_queue_.begin(); |
| 104 iter != show_queue_.end(); iter++) { |
| 105 if ((*iter)->notification().origin_url() == source && |
| 106 profile->IsSameProfile((*iter)->profile())) { |
| 107 notification_ids.insert((*iter)->notification().notification_id()); |
| 108 } |
| 109 } |
| 110 return notification_ids; |
| 111 } |
| 112 |
98 bool NotificationUIManagerImpl::CancelAllBySourceOrigin(const GURL& source) { | 113 bool NotificationUIManagerImpl::CancelAllBySourceOrigin(const GURL& source) { |
99 // Same pattern as CancelById, but more complicated than the above | 114 // Same pattern as CancelById, but more complicated than the above |
100 // because there may be multiple notifications from the same source. | 115 // because there may be multiple notifications from the same source. |
101 bool removed = false; | 116 bool removed = false; |
102 for (NotificationDeque::iterator loopiter = show_queue_.begin(); | 117 for (NotificationDeque::iterator loopiter = show_queue_.begin(); |
103 loopiter != show_queue_.end(); ) { | 118 loopiter != show_queue_.end(); ) { |
104 if ((*loopiter)->notification().origin_url() != source) { | 119 if ((*loopiter)->notification().origin_url() != source) { |
105 ++loopiter; | 120 ++loopiter; |
106 continue; | 121 continue; |
107 } | 122 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 CancelAllBySourceOrigin(extension->url()); | 233 CancelAllBySourceOrigin(extension->url()); |
219 } | 234 } |
220 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { | 235 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { |
221 // We only want to remove the incognito notifications. | 236 // We only want to remove the incognito notifications. |
222 if (content::Source<Profile>(source)->IsOffTheRecord()) | 237 if (content::Source<Profile>(source)->IsOffTheRecord()) |
223 CancelAllByProfile(content::Source<Profile>(source).ptr()); | 238 CancelAllByProfile(content::Source<Profile>(source).ptr()); |
224 } else { | 239 } else { |
225 NOTREACHED(); | 240 NOTREACHED(); |
226 } | 241 } |
227 } | 242 } |
OLD | NEW |