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/message_center_notification_manager.h" | 5 #include "chrome/browser/notifications/message_center_notification_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/extensions/extension_info_map.h" | 10 #include "chrome/browser/extensions/extension_info_map.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 | 63 |
64 // If it has been shown, remove it. | 64 // If it has been shown, remove it. |
65 NotificationMap::iterator iter = profile_notifications_.find(id); | 65 NotificationMap::iterator iter = profile_notifications_.find(id); |
66 if (iter == profile_notifications_.end()) | 66 if (iter == profile_notifications_.end()) |
67 return false; | 67 return false; |
68 | 68 |
69 message_center_->RemoveNotification(id, /* by_user */ false); | 69 message_center_->RemoveNotification(id, /* by_user */ false); |
70 return true; | 70 return true; |
71 } | 71 } |
72 | 72 |
73 void MessageCenterNotificationManager::GetAllIdsByProfileAndSourceOrigin( | |
74 Profile* profile, | |
75 const GURL& source, | |
76 std::set<std::string>* notification_ids) { | |
77 DCHECK(notification_ids); | |
78 NotificationUIManagerImpl::GetAllIdsByProfileAndSourceOrigin( | |
79 profile, source, notification_ids); | |
80 | |
81 for (NotificationMap::iterator loopiter = profile_notifications_.begin(); | |
82 loopiter != profile_notifications_.end();) { | |
83 NotificationMap::iterator curiter = loopiter++; | |
84 if ((*curiter).second->notification().origin_url() == source && | |
85 (*curiter).second->profile() == profile) { | |
Dmitry Titov
2013/05/16 20:39:15
Should it be == or IsSameProfile() ?
dewittj
2013/05/16 23:40:34
Good catch, probably the same extension would hand
| |
86 notification_ids->insert(curiter->first); | |
87 } | |
88 } | |
89 } | |
90 | |
73 bool MessageCenterNotificationManager::CancelAllBySourceOrigin( | 91 bool MessageCenterNotificationManager::CancelAllBySourceOrigin( |
74 const GURL& source) { | 92 const GURL& source) { |
75 // Same pattern as CancelById, but more complicated than the above | 93 // Same pattern as CancelById, but more complicated than the above |
76 // because there may be multiple notifications from the same source. | 94 // because there may be multiple notifications from the same source. |
77 bool removed = NotificationUIManagerImpl::CancelAllBySourceOrigin(source); | 95 bool removed = NotificationUIManagerImpl::CancelAllBySourceOrigin(source); |
78 | 96 |
79 for (NotificationMap::iterator loopiter = profile_notifications_.begin(); | 97 for (NotificationMap::iterator loopiter = profile_notifications_.begin(); |
80 loopiter != profile_notifications_.end(); ) { | 98 loopiter != profile_notifications_.end(); ) { |
81 NotificationMap::iterator curiter = loopiter++; | 99 NotificationMap::iterator curiter = loopiter++; |
82 if ((*curiter).second->notification().origin_url() == source) { | 100 if ((*curiter).second->notification().origin_url() == source) { |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 | 498 |
481 MessageCenterNotificationManager::ProfileNotification* | 499 MessageCenterNotificationManager::ProfileNotification* |
482 MessageCenterNotificationManager::FindProfileNotification( | 500 MessageCenterNotificationManager::FindProfileNotification( |
483 const std::string& id) const { | 501 const std::string& id) const { |
484 NotificationMap::const_iterator iter = profile_notifications_.find(id); | 502 NotificationMap::const_iterator iter = profile_notifications_.find(id); |
485 if (iter == profile_notifications_.end()) | 503 if (iter == profile_notifications_.end()) |
486 return NULL; | 504 return NULL; |
487 | 505 |
488 return (*iter).second; | 506 return (*iter).second; |
489 } | 507 } |
OLD | NEW |