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

Side by Side Diff: chrome/browser/notifications/balloon_collection_base.cc

Issue 11414215: Add CloseAllByProfile to NotificationUIManager and call before destroyng a Profile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac Created 8 years 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_collection_base.h" 5 #include "chrome/browser/notifications/balloon_collection_base.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/notifications/balloon.h" 8 #include "chrome/browser/notifications/balloon.h"
9 #include "chrome/browser/notifications/notification.h" 9 #include "chrome/browser/notifications/notification.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { 59 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) {
60 if ((*iter)->notification().origin_url() == source_origin) 60 if ((*iter)->notification().origin_url() == source_origin)
61 to_close.push_back(*iter); 61 to_close.push_back(*iter);
62 } 62 }
63 for (iter = to_close.begin(); iter != to_close.end(); ++iter) 63 for (iter = to_close.begin(); iter != to_close.end(); ++iter)
64 (*iter)->CloseByScript(); 64 (*iter)->CloseByScript();
65 65
66 return !to_close.empty(); 66 return !to_close.empty();
67 } 67 }
68 68
69 bool BalloonCollectionBase::CloseAllByProfile(Profile* profile) {
70 // Use a local list of balloons to close to avoid breaking
71 // iterator changes on each close.
72 Balloons to_close;
73 Balloons::iterator iter;
74 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) {
75 if ((*iter)->profile() == profile)
76 to_close.push_back(*iter);
77 }
78 for (iter = to_close.begin(); iter != to_close.end(); ++iter)
79 (*iter)->CloseByScript();
80
81 return !to_close.empty();
82 }
83
69 void BalloonCollectionBase::CloseAll() { 84 void BalloonCollectionBase::CloseAll() {
70 // Use a local list of balloons to close to avoid breaking 85 // Use a local list of balloons to close to avoid breaking
71 // iterator changes on each close. 86 // iterator changes on each close.
72 Balloons to_close = balloons_; 87 Balloons to_close = balloons_;
73 for (Balloons::iterator iter = to_close.begin(); 88 for (Balloons::iterator iter = to_close.begin();
74 iter != to_close.end(); ++iter) 89 iter != to_close.end(); ++iter)
75 (*iter)->CloseByScript(); 90 (*iter)->CloseByScript();
76 } 91 }
77 92
78 Balloon* BalloonCollectionBase::FindBalloonById( 93 Balloon* BalloonCollectionBase::FindBalloonById(
79 const std::string& notification_id) { 94 const std::string& notification_id) {
80 Balloons::iterator iter; 95 Balloons::iterator iter;
81 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { 96 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) {
82 if ((*iter)->notification().notification_id() == notification_id) { 97 if ((*iter)->notification().notification_id() == notification_id) {
83 return *iter; 98 return *iter;
84 } 99 }
85 } 100 }
86 return NULL; 101 return NULL;
87 } 102 }
88 103
89 Balloon* BalloonCollectionBase::FindBalloon(const Notification& notification) { 104 Balloon* BalloonCollectionBase::FindBalloon(const Notification& notification) {
90 return FindBalloonById(notification.notification_id()); 105 return FindBalloonById(notification.notification_id());
91 } 106 }
OLDNEW
« no previous file with comments | « chrome/browser/notifications/balloon_collection_base.h ('k') | chrome/browser/notifications/balloon_collection_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698