OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #import "ui/message_center/cocoa/popup_collection.h" | 5 #import "ui/message_center/cocoa/popup_collection.h" |
6 | 6 |
7 #import "ui/message_center/cocoa/notification_controller.h" | 7 #import "ui/message_center/cocoa/notification_controller.h" |
8 #import "ui/message_center/cocoa/popup_controller.h" | 8 #import "ui/message_center/cocoa/popup_controller.h" |
9 #include "ui/message_center/message_center.h" | 9 #include "ui/message_center/message_center.h" |
10 #include "ui/message_center/message_center_constants.h" | 10 #include "ui/message_center/message_center_constants.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 popup_collection_(popup_collection) { | 44 popup_collection_(popup_collection) { |
45 message_center_->AddObserver(this); | 45 message_center_->AddObserver(this); |
46 } | 46 } |
47 | 47 |
48 virtual ~PopupCollectionObserver() { | 48 virtual ~PopupCollectionObserver() { |
49 message_center_->RemoveObserver(this); | 49 message_center_->RemoveObserver(this); |
50 } | 50 } |
51 | 51 |
52 virtual void OnNotificationAdded( | 52 virtual void OnNotificationAdded( |
53 const std::string& notification_id) OVERRIDE { | 53 const std::string& notification_id) OVERRIDE { |
54 const auto& popups = message_center_->GetPopupNotifications(); | 54 for (const auto& notification : message_center_->GetPopupNotifications()) { |
55 for (auto it = popups.begin(); it != popups.end(); ++it) { | 55 if (notification->id() == notification_id) { |
56 if ((*it)->id() == notification_id) { | 56 [popup_collection_ addNotification:notification]; |
57 [popup_collection_ addNotification:*it]; | |
58 return; | 57 return; |
59 } | 58 } |
60 } | 59 } |
61 } | 60 } |
62 | 61 |
63 virtual void OnNotificationRemoved(const std::string& notification_id, | 62 virtual void OnNotificationRemoved(const std::string& notification_id, |
64 bool user_id) OVERRIDE { | 63 bool user_id) OVERRIDE { |
65 [popup_collection_ removeNotification:notification_id]; | 64 [popup_collection_ removeNotification:notification_id]; |
66 } | 65 } |
67 | 66 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // If there's no room left on screen to display notifications, stop | 256 // If there's no room left on screen to display notifications, stop |
258 // trying. | 257 // trying. |
259 if (![self addNotification:*it]) | 258 if (![self addNotification:*it]) |
260 break; | 259 break; |
261 } | 260 } |
262 } | 261 } |
263 } | 262 } |
264 } | 263 } |
265 | 264 |
266 @end | 265 @end |
OLD | NEW |