| 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 bool BalloonCollectionBase::DoesIdExist(const std::string& id, |
| 39 Notification* matched_notification) { |
| 39 Balloons::iterator iter; | 40 Balloons::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) { |
| 43 if (matched_notification) |
| 44 *matched_notification = (*iter)->notification(); |
| 42 return true; | 45 return true; |
| 46 } |
| 43 } | 47 } |
| 44 return false; | 48 return false; |
| 45 } | 49 } |
| 46 | 50 |
| 47 bool BalloonCollectionBase::CloseById(const std::string& id) { | 51 bool BalloonCollectionBase::CloseById(const std::string& id) { |
| 48 // Use a local list of balloons to close to avoid breaking | 52 // Use a local list of balloons to close to avoid breaking |
| 49 // iterator changes on each close. | 53 // iterator changes on each close. |
| 50 Balloons to_close; | 54 Balloons to_close; |
| 51 Balloons::iterator iter; | 55 Balloons::iterator iter; |
| 52 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { | 56 for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 if ((*iter)->notification().notification_id() == notification_id) { | 110 if ((*iter)->notification().notification_id() == notification_id) { |
| 107 return *iter; | 111 return *iter; |
| 108 } | 112 } |
| 109 } | 113 } |
| 110 return NULL; | 114 return NULL; |
| 111 } | 115 } |
| 112 | 116 |
| 113 Balloon* BalloonCollectionBase::FindBalloon(const Notification& notification) { | 117 Balloon* BalloonCollectionBase::FindBalloon(const Notification& notification) { |
| 114 return FindBalloonById(notification.notification_id()); | 118 return FindBalloonById(notification.notification_id()); |
| 115 } | 119 } |
| OLD | NEW |