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

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

Issue 1885683005: Add module suffix in .mojom files for components/arc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase only Created 4 years, 8 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_notification_item.h" 5 #include "ui/arc/notification/arc_notification_item.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const std::string& notification_key, 82 const std::string& notification_key,
83 const AccountId& profile_id) 83 const AccountId& profile_id)
84 : manager_(manager), 84 : manager_(manager),
85 message_center_(message_center), 85 message_center_(message_center),
86 profile_id_(profile_id), 86 profile_id_(profile_id),
87 notification_key_(notification_key), 87 notification_key_(notification_key),
88 notification_id_(kNotificationIdPrefix + notification_key_), 88 notification_id_(kNotificationIdPrefix + notification_key_),
89 weak_ptr_factory_(this) {} 89 weak_ptr_factory_(this) {}
90 90
91 void ArcNotificationItem::UpdateWithArcNotificationData( 91 void ArcNotificationItem::UpdateWithArcNotificationData(
92 const ArcNotificationData& data) { 92 const mojom::ArcNotificationData& data) {
93 DCHECK(thread_checker_.CalledOnValidThread()); 93 DCHECK(thread_checker_.CalledOnValidThread());
94 DCHECK(notification_key_ == data.key); 94 DCHECK(notification_key_ == data.key);
95 95
96 // Check if a decode task is on-going or not. If |notification_| is non-null, 96 // Check if a decode task is on-going or not. If |notification_| is non-null,
97 // a decode task is on-going asynchronously. Otherwise, there is no task. 97 // a decode task is on-going asynchronously. Otherwise, there is no task.
98 // TODO(yoshiki): Refactor and remove this check by omitting image decoding 98 // TODO(yoshiki): Refactor and remove this check by omitting image decoding
99 // from here. 99 // from here.
100 if (notification_) { 100 if (notification_) {
101 // Store the latest data to the |newer_data_| property and returns, if the 101 // Store the latest data to the |newer_data_| property and returns, if the
102 // previous decode is still in progress. 102 // previous decode is still in progress.
103 // If old |newer_data_| has been stored, discard the old one. 103 // If old |newer_data_| has been stored, discard the old one.
104 newer_data_ = data.Clone(); 104 newer_data_ = data.Clone();
105 return; 105 return;
106 } 106 }
107 107
108 message_center::RichNotificationData rich_data; 108 message_center::RichNotificationData rich_data;
109 message_center::NotificationType type; 109 message_center::NotificationType type;
110 110
111 switch (data.type) { 111 switch (data.type) {
112 case ArcNotificationType::BASIC: 112 case mojom::ArcNotificationType::BASIC:
113 type = message_center::NOTIFICATION_TYPE_BASE_FORMAT; 113 type = message_center::NOTIFICATION_TYPE_BASE_FORMAT;
114 break; 114 break;
115 case ArcNotificationType::IMAGE: 115 case mojom::ArcNotificationType::IMAGE:
116 // TODO(yoshiki): Implement this types. 116 // TODO(yoshiki): Implement this types.
117 type = message_center::NOTIFICATION_TYPE_BASE_FORMAT; 117 type = message_center::NOTIFICATION_TYPE_BASE_FORMAT;
118 LOG(ERROR) << "Unsupported notification type: image"; 118 LOG(ERROR) << "Unsupported notification type: image";
119 break; 119 break;
120 case ArcNotificationType::PROGRESS: 120 case mojom::ArcNotificationType::PROGRESS:
121 type = message_center::NOTIFICATION_TYPE_PROGRESS; 121 type = message_center::NOTIFICATION_TYPE_PROGRESS;
122 rich_data.timestamp = base::Time::UnixEpoch() + 122 rich_data.timestamp = base::Time::UnixEpoch() +
123 base::TimeDelta::FromMilliseconds(data.time); 123 base::TimeDelta::FromMilliseconds(data.time);
124 rich_data.progress = std::max( 124 rich_data.progress = std::max(
125 0, std::min(100, static_cast<int>(std::round( 125 0, std::min(100, static_cast<int>(std::round(
126 static_cast<float>(data.progress_current) / 126 static_cast<float>(data.progress_current) /
127 data.progress_max * 100)))); 127 data.progress_max * 100))));
128 break; 128 break;
129 } 129 }
130 DCHECK(IsKnownEnumValue(data.type)) << "Unsupported notification type: " 130 DCHECK(IsKnownEnumValue(data.type)) << "Unsupported notification type: "
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 DCHECK(thread_checker_.CalledOnValidThread()); 202 DCHECK(thread_checker_.CalledOnValidThread());
203 203
204 gfx::Image image = gfx::Image::CreateFrom1xBitmap(bitmap); 204 gfx::Image image = gfx::Image::CreateFrom1xBitmap(bitmap);
205 notification_->set_icon(image); 205 notification_->set_icon(image);
206 206
207 DCHECK(notification_); 207 DCHECK(notification_);
208 message_center_->AddNotification(std::move(notification_)); 208 message_center_->AddNotification(std::move(notification_));
209 209
210 if (newer_data_) { 210 if (newer_data_) {
211 // There is the newer data, so updates again. 211 // There is the newer data, so updates again.
212 ArcNotificationDataPtr data(std::move(newer_data_)); 212 mojom::ArcNotificationDataPtr data(std::move(newer_data_));
213 UpdateWithArcNotificationData(*data); 213 UpdateWithArcNotificationData(*data);
214 } 214 }
215 } 215 }
216 216
217 } // namespace arc 217 } // namespace arc
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_notification_item.h ('k') | ui/arc/notification/arc_notification_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698