Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: ui/arc/notification/arc_custom_notification_item.cc

Issue 2308663002: Migrate ArcBitmap to use typemapping (Closed)
Patch Set: Addressed comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/arc/bitmap/bitmap_type_converters.h"
11 #include "ui/arc/notification/arc_custom_notification_view.h" 10 #include "ui/arc/notification/arc_custom_notification_view.h"
12 #include "ui/message_center/notification.h" 11 #include "ui/message_center/notification.h"
13 #include "ui/message_center/notification_types.h" 12 #include "ui/message_center/notification_types.h"
14 13
15 namespace arc { 14 namespace arc {
16 15
17 namespace { 16 namespace {
18 17
19 constexpr char kNotifierId[] = "ARC_NOTIFICATION"; 18 constexpr char kNotifierId[] = "ARC_NOTIFICATION";
20 19
(...skipping 26 matching lines...) Expand all
47 message_center, 46 message_center,
48 notification_key, 47 notification_key,
49 profile_id) { 48 profile_id) {
50 } 49 }
51 50
52 ArcCustomNotificationItem::~ArcCustomNotificationItem() { 51 ArcCustomNotificationItem::~ArcCustomNotificationItem() {
53 FOR_EACH_OBSERVER(Observer, observers_, OnItemDestroying()); 52 FOR_EACH_OBSERVER(Observer, observers_, OnItemDestroying());
54 } 53 }
55 54
56 void ArcCustomNotificationItem::UpdateWithArcNotificationData( 55 void ArcCustomNotificationItem::UpdateWithArcNotificationData(
57 const mojom::ArcNotificationData& data) { 56 mojom::ArcNotificationDataPtr data) {
58 DCHECK(CalledOnValidThread()); 57 DCHECK(CalledOnValidThread());
59 DCHECK_EQ(notification_key(), data.key); 58 DCHECK_EQ(notification_key(), data->key);
60 59
61 if (CacheArcNotificationData(data)) 60 if (HasPendingNotification()) {
61 CacheArcNotificationData(std::move(data));
62 return; 62 return;
63 }
63 64
64 message_center::RichNotificationData rich_data; 65 message_center::RichNotificationData rich_data;
65 rich_data.pinned = (data.no_clear || data.ongoing_event); 66 rich_data.pinned = (data->no_clear || data->ongoing_event);
66 rich_data.priority = ConvertAndroidPriority(data.priority); 67 rich_data.priority = ConvertAndroidPriority(data->priority);
67 rich_data.small_image = ConvertAndroidSmallIcon(data.small_icon); 68 if (data->small_icon)
68 if (!data.accessible_name.is_null()) 69 rich_data.small_image = gfx::Image::CreateFrom1xBitmap(*data->small_icon);
69 rich_data.accessible_name = base::UTF8ToUTF16(data.accessible_name.get()); 70 if (!data->accessible_name.is_null())
71 rich_data.accessible_name = base::UTF8ToUTF16(data->accessible_name.get());
70 72
71 message_center::NotifierId notifier_id( 73 message_center::NotifierId notifier_id(
72 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); 74 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId);
73 notifier_id.profile_id = profile_id().GetUserEmail(); 75 notifier_id.profile_id = profile_id().GetUserEmail();
74 76
75 DCHECK(!data.title.is_null()); 77 DCHECK(!data->title.is_null());
76 DCHECK(!data.message.is_null()); 78 DCHECK(!data->message.is_null());
77 SetNotification(base::MakeUnique<message_center::Notification>( 79 SetNotification(base::MakeUnique<message_center::Notification>(
78 message_center::NOTIFICATION_TYPE_CUSTOM, notification_id(), 80 message_center::NOTIFICATION_TYPE_CUSTOM, notification_id(),
79 base::UTF8ToUTF16(data.title.get()), 81 base::UTF8ToUTF16(data->title.get()),
80 base::UTF8ToUTF16(data.message.get()), gfx::Image(), 82 base::UTF8ToUTF16(data->message.get()), gfx::Image(),
81 base::UTF8ToUTF16("arc"), // display source 83 base::UTF8ToUTF16("arc"), // display source
82 GURL(), // empty origin url, for system component 84 GURL(), // empty origin url, for system component
83 notifier_id, rich_data, new ArcNotificationDelegate(this))); 85 notifier_id, rich_data, new ArcNotificationDelegate(this)));
84 86
85 pinned_ = rich_data.pinned; 87 pinned_ = rich_data.pinned;
86 88
87 if (data.snapshot_image.is_null()) { 89 if (!data->snapshot_image || data->snapshot_image->isNull()) {
88 snapshot_ = gfx::ImageSkia(); 90 snapshot_ = gfx::ImageSkia();
89 } else { 91 } else {
90 snapshot_ = gfx::ImageSkia(gfx::ImageSkiaRep( 92 snapshot_ = gfx::ImageSkia(gfx::ImageSkiaRep(
91 data.snapshot_image.To<SkBitmap>(), data.snapshot_image_scale)); 93 *data->snapshot_image, data->snapshot_image_scale));
92 } 94 }
93 95
94 FOR_EACH_OBSERVER(Observer, observers_, OnItemUpdated()); 96 FOR_EACH_OBSERVER(Observer, observers_, OnItemUpdated());
95 97
96 AddToMessageCenter(); 98 AddToMessageCenter();
97 } 99 }
98 100
99 void ArcCustomNotificationItem::CloseFromCloseButton() { 101 void ArcCustomNotificationItem::CloseFromCloseButton() {
100 // Needs to manually remove notification from MessageCenter because 102 // Needs to manually remove notification from MessageCenter because
101 // the floating close button is not part of MessageCenter. 103 // the floating close button is not part of MessageCenter.
(...skipping 16 matching lines...) Expand all
118 } 120 }
119 121
120 void ArcCustomNotificationItem::DecrementWindowRefCount() { 122 void ArcCustomNotificationItem::DecrementWindowRefCount() {
121 DCHECK_GT(window_ref_count_, 0); 123 DCHECK_GT(window_ref_count_, 0);
122 --window_ref_count_; 124 --window_ref_count_;
123 if (window_ref_count_ == 0) 125 if (window_ref_count_ == 0)
124 manager()->CloseNotificationWindow(notification_key()); 126 manager()->CloseNotificationWindow(notification_key());
125 } 127 }
126 128
127 } // namespace arc 129 } // namespace arc
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_custom_notification_item.h ('k') | ui/arc/notification/arc_notification_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698