Chromium Code Reviews| 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 void NotificationUIManagerImpl::GetAllIdsByProfileAndSourceOrigin( | |
| 99 Profile* profile, | |
| 100 const GURL& source, | |
| 101 std::set<std::string>* notification_ids) { | |
| 102 DCHECK(notification_ids); | |
| 103 for (NotificationDeque::iterator loopiter = show_queue_.begin(); | |
|
Dmitry Titov
2013/05/16 20:39:15
just 'iter'?
dewittj
2013/05/16 23:40:34
okay.
| |
| 104 loopiter != show_queue_.end();) { | |
| 105 if ((*loopiter)->notification().origin_url() == source && | |
| 106 (*loopiter)->profile() == profile) { | |
| 107 notification_ids->insert((*loopiter)->notification().notification_id()); | |
| 108 } | |
| 109 } | |
| 110 } | |
| 111 | |
| 98 bool NotificationUIManagerImpl::CancelAllBySourceOrigin(const GURL& source) { | 112 bool NotificationUIManagerImpl::CancelAllBySourceOrigin(const GURL& source) { |
| 99 // Same pattern as CancelById, but more complicated than the above | 113 // Same pattern as CancelById, but more complicated than the above |
| 100 // because there may be multiple notifications from the same source. | 114 // because there may be multiple notifications from the same source. |
| 101 bool removed = false; | 115 bool removed = false; |
| 102 for (NotificationDeque::iterator loopiter = show_queue_.begin(); | 116 for (NotificationDeque::iterator loopiter = show_queue_.begin(); |
| 103 loopiter != show_queue_.end(); ) { | 117 loopiter != show_queue_.end(); ) { |
| 104 if ((*loopiter)->notification().origin_url() != source) { | 118 if ((*loopiter)->notification().origin_url() != source) { |
| 105 ++loopiter; | 119 ++loopiter; |
| 106 continue; | 120 continue; |
| 107 } | 121 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 CancelAllBySourceOrigin(extension->url()); | 232 CancelAllBySourceOrigin(extension->url()); |
| 219 } | 233 } |
| 220 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { | 234 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { |
| 221 // We only want to remove the incognito notifications. | 235 // We only want to remove the incognito notifications. |
| 222 if (content::Source<Profile>(source)->IsOffTheRecord()) | 236 if (content::Source<Profile>(source)->IsOffTheRecord()) |
| 223 CancelAllByProfile(content::Source<Profile>(source).ptr()); | 237 CancelAllByProfile(content::Source<Profile>(source).ptr()); |
| 224 } else { | 238 } else { |
| 225 NOTREACHED(); | 239 NOTREACHED(); |
| 226 } | 240 } |
| 227 } | 241 } |
| OLD | NEW |