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

Side by Side Diff: trunk/src/chrome/browser/notifications/notification_ui_manager_impl.cc

Issue 15925003: Revert 201932 "Add API function chrome.notifications.getAll" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 std::set<std::string>
99 NotificationUIManagerImpl::GetAllIdsByProfileAndSourceOrigin(
100 Profile* profile,
101 const GURL& source) {
102 std::set<std::string> notification_ids;
103 for (NotificationDeque::iterator iter = show_queue_.begin();
104 iter != show_queue_.end(); iter++) {
105 if ((*iter)->notification().origin_url() == source &&
106 profile->IsSameProfile((*iter)->profile())) {
107 notification_ids.insert((*iter)->notification().notification_id());
108 }
109 }
110 return notification_ids;
111 }
112
113 bool NotificationUIManagerImpl::CancelAllBySourceOrigin(const GURL& source) { 98 bool NotificationUIManagerImpl::CancelAllBySourceOrigin(const GURL& source) {
114 // Same pattern as CancelById, but more complicated than the above 99 // Same pattern as CancelById, but more complicated than the above
115 // because there may be multiple notifications from the same source. 100 // because there may be multiple notifications from the same source.
116 bool removed = false; 101 bool removed = false;
117 for (NotificationDeque::iterator loopiter = show_queue_.begin(); 102 for (NotificationDeque::iterator loopiter = show_queue_.begin();
118 loopiter != show_queue_.end(); ) { 103 loopiter != show_queue_.end(); ) {
119 if ((*loopiter)->notification().origin_url() != source) { 104 if ((*loopiter)->notification().origin_url() != source) {
120 ++loopiter; 105 ++loopiter;
121 continue; 106 continue;
122 } 107 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 CancelAllBySourceOrigin(extension->url()); 218 CancelAllBySourceOrigin(extension->url());
234 } 219 }
235 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { 220 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) {
236 // We only want to remove the incognito notifications. 221 // We only want to remove the incognito notifications.
237 if (content::Source<Profile>(source)->IsOffTheRecord()) 222 if (content::Source<Profile>(source)->IsOffTheRecord())
238 CancelAllByProfile(content::Source<Profile>(source).ptr()); 223 CancelAllByProfile(content::Source<Profile>(source).ptr());
239 } else { 224 } else {
240 NOTREACHED(); 225 NOTREACHED();
241 } 226 }
242 } 227 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698