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 | |
113 bool NotificationUIManagerImpl::CancelAllBySourceOrigin(const GURL& source) { | 98 bool NotificationUIManagerImpl::CancelAllBySourceOrigin(const GURL& source) { |
114 // Same pattern as CancelById, but more complicated than the above | 99 // Same pattern as CancelById, but more complicated than the above |
115 // because there may be multiple notifications from the same source. | 100 // because there may be multiple notifications from the same source. |
116 bool removed = false; | 101 bool removed = false; |
117 for (NotificationDeque::iterator loopiter = show_queue_.begin(); | 102 for (NotificationDeque::iterator loopiter = show_queue_.begin(); |
118 loopiter != show_queue_.end(); ) { | 103 loopiter != show_queue_.end(); ) { |
119 if ((*loopiter)->notification().origin_url() != source) { | 104 if ((*loopiter)->notification().origin_url() != source) { |
120 ++loopiter; | 105 ++loopiter; |
121 continue; | 106 continue; |
122 } | 107 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 CancelAllBySourceOrigin(extension->url()); | 218 CancelAllBySourceOrigin(extension->url()); |
234 } | 219 } |
235 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { | 220 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { |
236 // We only want to remove the incognito notifications. | 221 // We only want to remove the incognito notifications. |
237 if (content::Source<Profile>(source)->IsOffTheRecord()) | 222 if (content::Source<Profile>(source)->IsOffTheRecord()) |
238 CancelAllByProfile(content::Source<Profile>(source).ptr()); | 223 CancelAllByProfile(content::Source<Profile>(source).ptr()); |
239 } else { | 224 } else { |
240 NOTREACHED(); | 225 NOTREACHED(); |
241 } | 226 } |
242 } | 227 } |
OLD | NEW |