| 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 <memory> |
| 8 #include <string> |
| 9 #include <utility> |
| 10 |
| 7 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/arc/notification/arc_custom_notification_view.h" | 14 #include "ui/arc/notification/arc_custom_notification_view.h" |
| 11 #include "ui/message_center/notification.h" | 15 #include "ui/message_center/notification.h" |
| 12 #include "ui/message_center/notification_types.h" | 16 #include "ui/message_center/notification_types.h" |
| 13 | 17 |
| 14 namespace arc { | 18 namespace arc { |
| 15 | 19 |
| 16 namespace { | 20 namespace { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 if (HasPendingNotification()) { | 65 if (HasPendingNotification()) { |
| 62 CacheArcNotificationData(std::move(data)); | 66 CacheArcNotificationData(std::move(data)); |
| 63 return; | 67 return; |
| 64 } | 68 } |
| 65 | 69 |
| 66 message_center::RichNotificationData rich_data; | 70 message_center::RichNotificationData rich_data; |
| 67 rich_data.pinned = (data->no_clear || data->ongoing_event); | 71 rich_data.pinned = (data->no_clear || data->ongoing_event); |
| 68 rich_data.priority = ConvertAndroidPriority(data->priority); | 72 rich_data.priority = ConvertAndroidPriority(data->priority); |
| 69 if (data->small_icon) | 73 if (data->small_icon) |
| 70 rich_data.small_image = gfx::Image::CreateFrom1xBitmap(*data->small_icon); | 74 rich_data.small_image = gfx::Image::CreateFrom1xBitmap(*data->small_icon); |
| 71 if (!data->accessible_name.is_null()) | 75 if (data->accessible_name.has_value()) |
| 72 rich_data.accessible_name = base::UTF8ToUTF16(data->accessible_name.get()); | 76 rich_data.accessible_name = base::UTF8ToUTF16(*data->accessible_name); |
| 73 | 77 |
| 74 message_center::NotifierId notifier_id( | 78 message_center::NotifierId notifier_id( |
| 75 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); | 79 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); |
| 76 notifier_id.profile_id = profile_id().GetUserEmail(); | 80 notifier_id.profile_id = profile_id().GetUserEmail(); |
| 77 | 81 |
| 78 DCHECK(!data->title.is_null()); | |
| 79 DCHECK(!data->message.is_null()); | |
| 80 SetNotification(base::MakeUnique<message_center::Notification>( | 82 SetNotification(base::MakeUnique<message_center::Notification>( |
| 81 message_center::NOTIFICATION_TYPE_CUSTOM, notification_id(), | 83 message_center::NOTIFICATION_TYPE_CUSTOM, notification_id(), |
| 82 base::UTF8ToUTF16(data->title.get()), | 84 base::UTF8ToUTF16(data->title), base::UTF8ToUTF16(data->message), |
| 83 base::UTF8ToUTF16(data->message.get()), gfx::Image(), | 85 gfx::Image(), |
| 84 base::UTF8ToUTF16("arc"), // display source | 86 base::UTF8ToUTF16("arc"), // display source |
| 85 GURL(), // empty origin url, for system component | 87 GURL(), // empty origin url, for system component |
| 86 notifier_id, rich_data, new ArcNotificationDelegate(this))); | 88 notifier_id, rich_data, new ArcNotificationDelegate(this))); |
| 87 | 89 |
| 88 pinned_ = rich_data.pinned; | 90 pinned_ = rich_data.pinned; |
| 89 | 91 |
| 90 if (!data->snapshot_image || data->snapshot_image->isNull()) { | 92 if (!data->snapshot_image || data->snapshot_image->isNull()) { |
| 91 snapshot_ = gfx::ImageSkia(); | 93 snapshot_ = gfx::ImageSkia(); |
| 92 } else { | 94 } else { |
| 93 snapshot_ = gfx::ImageSkia(gfx::ImageSkiaRep( | 95 snapshot_ = gfx::ImageSkia(gfx::ImageSkiaRep( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 122 } | 124 } |
| 123 | 125 |
| 124 void ArcCustomNotificationItem::DecrementWindowRefCount() { | 126 void ArcCustomNotificationItem::DecrementWindowRefCount() { |
| 125 DCHECK_GT(window_ref_count_, 0); | 127 DCHECK_GT(window_ref_count_, 0); |
| 126 --window_ref_count_; | 128 --window_ref_count_; |
| 127 if (window_ref_count_ == 0) | 129 if (window_ref_count_ == 0) |
| 128 manager()->CloseNotificationWindow(notification_key()); | 130 manager()->CloseNotificationWindow(notification_key()); |
| 129 } | 131 } |
| 130 | 132 |
| 131 } // namespace arc | 133 } // namespace arc |
| OLD | NEW |