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

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

Issue 4635007: When an extension is uninstalled, close all desktop notifications from that e... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: lint fixes Created 10 years, 1 month 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/notification_ui_manager.cc
===================================================================
--- chrome/browser/notifications/notification_ui_manager.cc (revision 65581)
+++ chrome/browser/notifications/notification_ui_manager.cc (working copy)
@@ -66,19 +66,40 @@
CheckAndShowNotifications();
}
-bool NotificationUIManager::Cancel(const Notification& notification) {
- // First look through the notifications that haven't been shown. If not
- // found there, call to the active balloon collection to tear it down.
+bool NotificationUIManager::CancelById(const std::string& id) {
+ // See if this ID hasn't been shown yet.
NotificationDeque::iterator iter;
for (iter = show_queue_.begin(); iter != show_queue_.end(); ++iter) {
- if (notification.IsSame((*iter)->notification())) {
+ if ((*iter)->notification().notification_id() == id) {
show_queue_.erase(iter);
return true;
}
}
- return balloon_collection_->Remove(notification);
+ // If it has been shown, remove it from the balloon collections.
+ return balloon_collection_->RemoveById(id);
}
+bool NotificationUIManager::CancelAllBySourceOrigin(const GURL& source) {
+ // Same pattern as CancelById, but more complicated than the above
+ // because there may be multiple notifications from the same source.
+ bool searching = true;
+ bool removed = false;
+ while (searching) {
+ searching = false;
Andrew T Wilson (Slow) 2010/11/11 01:07:44 This seems like an odd way to implement this. I th
John Gregg 2010/11/11 18:13:51 thanks, i tend to play it safe when modifying iter
+ NotificationDeque::iterator iter;
+ for (iter = show_queue_.begin(); iter != show_queue_.end(); ++iter) {
+ if ((*iter)->notification().origin_url() == source) {
+ show_queue_.erase(iter);
+ searching = true;
+ removed = true;
+ break;
+ }
+ }
+ }
+
+ return balloon_collection_->RemoveBySourceOrigin(source) || removed;
+}
+
void NotificationUIManager::CheckAndShowNotifications() {
// TODO(johnnyg): http://crbug.com/25061 - Check for user idle/presentation.
ShowNotifications();

Powered by Google App Engine
This is Rietveld 408576698