Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2200)

Unified Diff: chrome/browser/notifications/message_center_notification_manager.cc

Issue 14767029: Add API function chrome.notifications.getAll (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address dimich comments #2. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/message_center_notification_manager.cc
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc
index 7be078329f2219bf73ccc49169562739f342be16..f2574f97c996e67195a443fac80fcd75bfe35b63 100644
--- a/chrome/browser/notifications/message_center_notification_manager.cc
+++ b/chrome/browser/notifications/message_center_notification_manager.cc
@@ -70,6 +70,26 @@ bool MessageCenterNotificationManager::CancelById(const std::string& id) {
return true;
}
+std::set<std::string>
+MessageCenterNotificationManager::GetAllIdsByProfileAndSourceOrigin(
+ Profile* profile,
+ const GURL& source) {
+
+ std::set<std::string> notification_ids =
+ NotificationUIManagerImpl::GetAllIdsByProfileAndSourceOrigin(profile,
+ source);
+
+ for (NotificationMap::iterator loopiter = profile_notifications_.begin();
+ loopiter != profile_notifications_.end();) {
+ NotificationMap::iterator curiter = loopiter++;
Dmitry Titov 2013/05/17 00:14:41 This loop does not need curiter/loopiter treatment
+ if ((*curiter).second->notification().origin_url() == source &&
+ profile->IsSameProfile((*curiter).second->profile())) {
+ notification_ids.insert(curiter->first);
+ }
+ }
+ return notification_ids;
+}
+
bool MessageCenterNotificationManager::CancelAllBySourceOrigin(
const GURL& source) {
// Same pattern as CancelById, but more complicated than the above
@@ -94,7 +114,7 @@ bool MessageCenterNotificationManager::CancelAllByProfile(Profile* profile) {
for (NotificationMap::iterator loopiter = profile_notifications_.begin();
loopiter != profile_notifications_.end(); ) {
NotificationMap::iterator curiter = loopiter++;
- if ((*curiter).second->profile() == profile) {
+ if (profile->IsSameProfile((*curiter).second->profile())) {
message_center_->RemoveNotification(curiter->first, /* by_user */ false);
removed = true;
}

Powered by Google App Engine
This is Rietveld 408576698