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

Unified Diff: chrome/browser/notifications/balloon_notification_ui_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/balloon_notification_ui_manager.cc
diff --git a/chrome/browser/notifications/balloon_notification_ui_manager.cc b/chrome/browser/notifications/balloon_notification_ui_manager.cc
index 63883975653ca8129af3b6d1dffd1e5d61d22141..7c942d86a5473264228ecd8433c6b3349bb69b2d 100644
--- a/chrome/browser/notifications/balloon_notification_ui_manager.cc
+++ b/chrome/browser/notifications/balloon_notification_ui_manager.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/idle.h"
#include "chrome/browser/notifications/balloon_collection.h"
#include "chrome/browser/notifications/notification.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/notification_service.h"
@@ -59,6 +60,26 @@ bool BalloonNotificationUIManager::CancelById(const std::string& id) {
return balloon_collection_->RemoveById(id);
}
+std::set<std::string>
+BalloonNotificationUIManager::GetAllIdsByProfileAndSourceOrigin(
+ Profile* profile,
+ const GURL& source) {
+ std::set<std::string> notification_ids =
+ NotificationUIManagerImpl::GetAllIdsByProfileAndSourceOrigin(profile,
+ source);
+
+ const BalloonCollection::Balloons& balloons =
+ balloon_collection_->GetActiveBalloons();
+ for (BalloonCollection::Balloons::const_iterator iter = balloons.begin();
+ iter != balloons.end(); ++iter) {
+ if (profile->IsSameProfile((*iter)->profile()) &&
+ source == (*iter)->notification().origin_url()) {
+ notification_ids.insert((*iter)->notification().notification_id());
+ }
+ }
+ return notification_ids;
+}
+
bool BalloonNotificationUIManager::CancelAllBySourceOrigin(const GURL& source) {
// Same pattern as CancelById, but more complicated than the above
// because there may be multiple notifications from the same source.

Powered by Google App Engine
This is Rietveld 408576698