| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/arc/notification/arc_custom_notification_item.h" | 5 #include "ui/arc/notification/arc_custom_notification_item.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/arc/notification/arc_custom_notification_view.h" | 10 #include "ui/arc/notification/arc_custom_notification_view.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 message_center::MessageCenter* message_center, | 42 message_center::MessageCenter* message_center, |
| 43 const std::string& notification_key, | 43 const std::string& notification_key, |
| 44 const AccountId& profile_id) | 44 const AccountId& profile_id) |
| 45 : ArcNotificationItem(manager, | 45 : ArcNotificationItem(manager, |
| 46 message_center, | 46 message_center, |
| 47 notification_key, | 47 notification_key, |
| 48 profile_id) { | 48 profile_id) { |
| 49 } | 49 } |
| 50 | 50 |
| 51 ArcCustomNotificationItem::~ArcCustomNotificationItem() { | 51 ArcCustomNotificationItem::~ArcCustomNotificationItem() { |
| 52 FOR_EACH_OBSERVER(Observer, observers_, OnItemDestroying()); | 52 for (auto& observer : observers_) |
| 53 observer.OnItemDestroying(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void ArcCustomNotificationItem::UpdateWithArcNotificationData( | 56 void ArcCustomNotificationItem::UpdateWithArcNotificationData( |
| 56 mojom::ArcNotificationDataPtr data) { | 57 mojom::ArcNotificationDataPtr data) { |
| 57 DCHECK(CalledOnValidThread()); | 58 DCHECK(CalledOnValidThread()); |
| 58 DCHECK_EQ(notification_key(), data->key); | 59 DCHECK_EQ(notification_key(), data->key); |
| 59 | 60 |
| 60 if (HasPendingNotification()) { | 61 if (HasPendingNotification()) { |
| 61 CacheArcNotificationData(std::move(data)); | 62 CacheArcNotificationData(std::move(data)); |
| 62 return; | 63 return; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 86 | 87 |
| 87 pinned_ = rich_data.pinned; | 88 pinned_ = rich_data.pinned; |
| 88 | 89 |
| 89 if (!data->snapshot_image || data->snapshot_image->isNull()) { | 90 if (!data->snapshot_image || data->snapshot_image->isNull()) { |
| 90 snapshot_ = gfx::ImageSkia(); | 91 snapshot_ = gfx::ImageSkia(); |
| 91 } else { | 92 } else { |
| 92 snapshot_ = gfx::ImageSkia(gfx::ImageSkiaRep( | 93 snapshot_ = gfx::ImageSkia(gfx::ImageSkiaRep( |
| 93 *data->snapshot_image, data->snapshot_image_scale)); | 94 *data->snapshot_image, data->snapshot_image_scale)); |
| 94 } | 95 } |
| 95 | 96 |
| 96 FOR_EACH_OBSERVER(Observer, observers_, OnItemUpdated()); | 97 for (auto& observer : observers_) |
| 98 observer.OnItemUpdated(); |
| 97 | 99 |
| 98 AddToMessageCenter(); | 100 AddToMessageCenter(); |
| 99 } | 101 } |
| 100 | 102 |
| 101 void ArcCustomNotificationItem::CloseFromCloseButton() { | 103 void ArcCustomNotificationItem::CloseFromCloseButton() { |
| 102 // Needs to manually remove notification from MessageCenter because | 104 // Needs to manually remove notification from MessageCenter because |
| 103 // the floating close button is not part of MessageCenter. | 105 // the floating close button is not part of MessageCenter. |
| 104 message_center()->RemoveNotification(notification_id(), true); | 106 message_center()->RemoveNotification(notification_id(), true); |
| 105 Close(true); | 107 Close(true); |
| 106 } | 108 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 120 } | 122 } |
| 121 | 123 |
| 122 void ArcCustomNotificationItem::DecrementWindowRefCount() { | 124 void ArcCustomNotificationItem::DecrementWindowRefCount() { |
| 123 DCHECK_GT(window_ref_count_, 0); | 125 DCHECK_GT(window_ref_count_, 0); |
| 124 --window_ref_count_; | 126 --window_ref_count_; |
| 125 if (window_ref_count_ == 0) | 127 if (window_ref_count_ == 0) |
| 126 manager()->CloseNotificationWindow(notification_key()); | 128 manager()->CloseNotificationWindow(notification_key()); |
| 127 } | 129 } |
| 128 | 130 |
| 129 } // namespace arc | 131 } // namespace arc |
| OLD | NEW |