| 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_observer.h" | 10 #include "ui/message_center/message_center_observer.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 class PopupCollectionObserver : public message_center::MessageCenterObserver { | 51 class PopupCollectionObserver : public message_center::MessageCenterObserver { |
| 52 public: | 52 public: |
| 53 PopupCollectionObserver(message_center::MessageCenter* message_center, | 53 PopupCollectionObserver(message_center::MessageCenter* message_center, |
| 54 MCPopupCollection* popup_collection) | 54 MCPopupCollection* popup_collection) |
| 55 : message_center_(message_center), | 55 : message_center_(message_center), |
| 56 popup_collection_(popup_collection) { | 56 popup_collection_(popup_collection) { |
| 57 message_center_->AddObserver(this); | 57 message_center_->AddObserver(this); |
| 58 } | 58 } |
| 59 | 59 |
| 60 virtual ~PopupCollectionObserver() { | 60 ~PopupCollectionObserver() override { message_center_->RemoveObserver(this); } |
| 61 message_center_->RemoveObserver(this); | |
| 62 } | |
| 63 | 61 |
| 64 virtual void OnNotificationAdded( | 62 void OnNotificationAdded(const std::string& notification_id) override { |
| 65 const std::string& notification_id) override { | |
| 66 [popup_collection_ layoutNewNotifications]; | 63 [popup_collection_ layoutNewNotifications]; |
| 67 } | 64 } |
| 68 | 65 |
| 69 virtual void OnNotificationRemoved(const std::string& notification_id, | 66 void OnNotificationRemoved(const std::string& notification_id, |
| 70 bool user_id) override { | 67 bool user_id) override { |
| 71 [popup_collection_ removeNotification:notification_id]; | 68 [popup_collection_ removeNotification:notification_id]; |
| 72 } | 69 } |
| 73 | 70 |
| 74 virtual void OnNotificationUpdated( | 71 void OnNotificationUpdated(const std::string& notification_id) override { |
| 75 const std::string& notification_id) override { | |
| 76 [popup_collection_ updateNotification:notification_id]; | 72 [popup_collection_ updateNotification:notification_id]; |
| 77 } | 73 } |
| 78 | 74 |
| 79 private: | 75 private: |
| 80 message_center::MessageCenter* message_center_; // Weak, global. | 76 message_center::MessageCenter* message_center_; // Weak, global. |
| 81 | 77 |
| 82 MCPopupCollection* popup_collection_; // Weak, owns this. | 78 MCPopupCollection* popup_collection_; // Weak, owns this. |
| 83 }; | 79 }; |
| 84 | 80 |
| 85 } // namespace | 81 } // namespace |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 } | 389 } |
| 394 | 390 |
| 395 pendingUpdateNotificationIDs_.clear(); | 391 pendingUpdateNotificationIDs_.clear(); |
| 396 | 392 |
| 397 // Start re-layout of all notifications, so that it readjusts the Y origin of | 393 // Start re-layout of all notifications, so that it readjusts the Y origin of |
| 398 // all updated popups and any popups that come below them. | 394 // all updated popups and any popups that come below them. |
| 399 [self layoutNotifications]; | 395 [self layoutNotifications]; |
| 400 } | 396 } |
| 401 | 397 |
| 402 @end | 398 @end |
| OLD | NEW |