OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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-inl.h" | 7 #include "base/stl_util-inl.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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { | 56 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { |
57 if ((*iter)->notification().origin_url() == source_origin) | 57 if ((*iter)->notification().origin_url() == source_origin) |
58 to_close.push_back(*iter); | 58 to_close.push_back(*iter); |
59 } | 59 } |
60 for (iter = to_close.begin(); iter != to_close.end(); ++iter) | 60 for (iter = to_close.begin(); iter != to_close.end(); ++iter) |
61 (*iter)->CloseByScript(); | 61 (*iter)->CloseByScript(); |
62 | 62 |
63 return !to_close.empty(); | 63 return !to_close.empty(); |
64 } | 64 } |
65 | 65 |
| 66 void BalloonCollectionBase::CloseAll() { |
| 67 // Use a local list of balloons to close to avoid breaking |
| 68 // iterator changes on each close. |
| 69 Balloons to_close = balloons_; |
| 70 for (Balloons::iterator iter = to_close.begin(); |
| 71 iter != to_close.end(); ++iter) |
| 72 (*iter)->CloseByScript(); |
| 73 } |
| 74 |
66 Balloon* BalloonCollectionBase::FindBalloon( | 75 Balloon* BalloonCollectionBase::FindBalloon( |
67 const Notification& notification) { | 76 const Notification& notification) { |
68 Balloons::iterator iter; | 77 Balloons::iterator iter; |
69 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { | 78 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { |
70 if ((*iter)->notification().notification_id() == | 79 if ((*iter)->notification().notification_id() == |
71 notification.notification_id()) { | 80 notification.notification_id()) { |
72 return *iter; | 81 return *iter; |
73 } | 82 } |
74 } | 83 } |
75 return NULL; | 84 return NULL; |
76 } | 85 } |
OLD | NEW |