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

Side by Side 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: Fix merge that caused test error. 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/balloon_notification_ui_manager.h" 5 #include "chrome/browser/notifications/balloon_notification_ui_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 "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 bool BalloonNotificationUIManager::CancelById(const std::string& id) { 54 bool BalloonNotificationUIManager::CancelById(const std::string& id) {
55 // See if this ID hasn't been shown yet. 55 // See if this ID hasn't been shown yet.
56 if (NotificationUIManagerImpl::CancelById(id)) 56 if (NotificationUIManagerImpl::CancelById(id))
57 return true; 57 return true;
58 // If it has been shown, remove it from the balloon collections. 58 // If it has been shown, remove it from the balloon collections.
59 return balloon_collection_->RemoveById(id); 59 return balloon_collection_->RemoveById(id);
60 } 60 }
61 61
62 void BalloonNotificationUIManager::GetAllIdsByProfileAndSourceOrigin(
63 Profile* profile,
64 const GURL& source,
65 std::set<std::string>* notification_ids) {
66 DCHECK(notification_ids);
67 NotificationUIManagerImpl::GetAllIdsByProfileAndSourceOrigin(
68 profile, source, notification_ids);
69
70 const BalloonCollection::Balloons& balloons =
71 balloon_collection_->GetActiveBalloons();
72 for (BalloonCollection::Balloons::const_iterator iter = balloons.begin();
73 iter != balloons.end();
Dmitry Titov 2013/05/16 20:39:15 this loop can be in 2 lines.
dewittj 2013/05/16 23:40:34 ALL HAIL CLANG-FORMAT-DIFF
74 ++iter) {
75 if (profile == (*iter)->profile() &&
76 source == (*iter)->notification().origin_url()) {
77 notification_ids->insert((*iter)->notification().notification_id());
78 }
79 }
80 }
81
62 bool BalloonNotificationUIManager::CancelAllBySourceOrigin(const GURL& source) { 82 bool BalloonNotificationUIManager::CancelAllBySourceOrigin(const GURL& source) {
63 // Same pattern as CancelById, but more complicated than the above 83 // Same pattern as CancelById, but more complicated than the above
64 // because there may be multiple notifications from the same source. 84 // because there may be multiple notifications from the same source.
65 bool removed = NotificationUIManagerImpl::CancelAllBySourceOrigin(source); 85 bool removed = NotificationUIManagerImpl::CancelAllBySourceOrigin(source);
66 return balloon_collection_->RemoveBySourceOrigin(source) || removed; 86 return balloon_collection_->RemoveBySourceOrigin(source) || removed;
67 } 87 }
68 88
69 bool BalloonNotificationUIManager::CancelAllByProfile(Profile* profile) { 89 bool BalloonNotificationUIManager::CancelAllByProfile(Profile* profile) {
70 // Same pattern as CancelAllBySourceOrigin. 90 // Same pattern as CancelAllBySourceOrigin.
71 bool removed = NotificationUIManagerImpl::CancelAllByProfile(profile); 91 bool removed = NotificationUIManagerImpl::CancelAllByProfile(profile);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 BalloonNotificationUIManager::GetInstanceForTesting() { 167 BalloonNotificationUIManager::GetInstanceForTesting() {
148 if (NotificationUIManager::DelegatesToMessageCenter()) { 168 if (NotificationUIManager::DelegatesToMessageCenter()) {
149 LOG(ERROR) << "Attempt to run a test that requires " 169 LOG(ERROR) << "Attempt to run a test that requires "
150 << "BalloonNotificationUIManager while delegating to a " 170 << "BalloonNotificationUIManager while delegating to a "
151 << "native MessageCenter. Test will fail. Ask dimich@"; 171 << "native MessageCenter. Test will fail. Ask dimich@";
152 return NULL; 172 return NULL;
153 } 173 }
154 return static_cast<BalloonNotificationUIManager*>( 174 return static_cast<BalloonNotificationUIManager*>(
155 g_browser_process->notification_ui_manager()); 175 g_browser_process->notification_ui_manager());
156 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698