OLD | NEW |
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 "url/gurl.h" | 10 #include "url/gurl.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 scoped_ptr<Balloon> to_delete(balloon); | 28 scoped_ptr<Balloon> to_delete(balloon); |
29 Balloons::iterator iter; | 29 Balloons::iterator iter; |
30 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { | 30 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { |
31 if ((*iter) == balloon) { | 31 if ((*iter) == balloon) { |
32 balloons_.erase(iter); | 32 balloons_.erase(iter); |
33 return; | 33 return; |
34 } | 34 } |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 bool BalloonCollectionBase::DoesIdExist(const std::string& id) { | 38 const Notification* BalloonCollectionBase::FindById( |
39 Balloons::iterator iter; | 39 const std::string& id) const { |
| 40 Balloons::const_iterator iter; |
40 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { | 41 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { |
41 if ((*iter)->notification().notification_id() == id) | 42 if ((*iter)->notification().notification_id() == id) { |
42 return true; | 43 return &((*iter)->notification()); |
| 44 } |
43 } | 45 } |
44 return false; | 46 return NULL; |
45 } | 47 } |
46 | 48 |
47 bool BalloonCollectionBase::CloseById(const std::string& id) { | 49 bool BalloonCollectionBase::CloseById(const std::string& id) { |
48 // Use a local list of balloons to close to avoid breaking | 50 // Use a local list of balloons to close to avoid breaking |
49 // iterator changes on each close. | 51 // iterator changes on each close. |
50 Balloons to_close; | 52 Balloons to_close; |
51 Balloons::iterator iter; | 53 Balloons::iterator iter; |
52 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { | 54 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { |
53 if ((*iter)->notification().notification_id() == id) | 55 if ((*iter)->notification().notification_id() == id) |
54 to_close.push_back(*iter); | 56 to_close.push_back(*iter); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if ((*iter)->notification().notification_id() == notification_id) { | 108 if ((*iter)->notification().notification_id() == notification_id) { |
107 return *iter; | 109 return *iter; |
108 } | 110 } |
109 } | 111 } |
110 return NULL; | 112 return NULL; |
111 } | 113 } |
112 | 114 |
113 Balloon* BalloonCollectionBase::FindBalloon(const Notification& notification) { | 115 Balloon* BalloonCollectionBase::FindBalloon(const Notification& notification) { |
114 return FindBalloonById(notification.notification_id()); | 116 return FindBalloonById(notification.notification_id()); |
115 } | 117 } |
OLD | NEW |