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_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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // If old |newer_data_| has been stored, discard the old one. | 98 // If old |newer_data_| has been stored, discard the old one. |
99 newer_data_ = data.Clone(); | 99 newer_data_ = data.Clone(); |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 message_center::RichNotificationData rich_data; | 103 message_center::RichNotificationData rich_data; |
104 message_center::NotificationType type; | 104 message_center::NotificationType type; |
105 | 105 |
106 switch (data.type) { | 106 switch (data.type) { |
107 case ArcNotificationType::BASIC: | 107 case ArcNotificationType::BASIC: |
108 type = message_center::NOTIFICATION_TYPE_SIMPLE; | 108 type = message_center::NOTIFICATION_TYPE_BASE_FORMAT; |
109 break; | 109 break; |
110 case ArcNotificationType::IMAGE: | 110 case ArcNotificationType::IMAGE: |
111 // TODO(yoshiki): Implement this types. | 111 // TODO(yoshiki): Implement this types. |
112 type = message_center::NOTIFICATION_TYPE_SIMPLE; | 112 type = message_center::NOTIFICATION_TYPE_BASE_FORMAT; |
113 LOG(ERROR) << "Unsupported notification type: image"; | 113 LOG(ERROR) << "Unsupported notification type: image"; |
114 break; | 114 break; |
115 case ArcNotificationType::PROGRESS: | 115 case ArcNotificationType::PROGRESS: |
116 type = message_center::NOTIFICATION_TYPE_PROGRESS; | 116 type = message_center::NOTIFICATION_TYPE_PROGRESS; |
117 rich_data.timestamp = base::Time::UnixEpoch() + | 117 rich_data.timestamp = base::Time::UnixEpoch() + |
118 base::TimeDelta::FromMilliseconds(data.time); | 118 base::TimeDelta::FromMilliseconds(data.time); |
119 rich_data.progress = std::max( | 119 rich_data.progress = std::max( |
120 0, std::min(100, static_cast<int>(std::round( | 120 0, std::min(100, static_cast<int>(std::round( |
121 static_cast<float>(data.progress_current) / | 121 static_cast<float>(data.progress_current) / |
122 data.progress_max * 100)))); | 122 data.progress_max * 100)))); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 message_center_->AddNotification(std::move(notification_)); | 189 message_center_->AddNotification(std::move(notification_)); |
190 | 190 |
191 if (newer_data_) { | 191 if (newer_data_) { |
192 // There is the newer data, so updates again. | 192 // There is the newer data, so updates again. |
193 ArcNotificationDataPtr data(std::move(newer_data_)); | 193 ArcNotificationDataPtr data(std::move(newer_data_)); |
194 UpdateWithArcNotificationData(*data); | 194 UpdateWithArcNotificationData(*data); |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 } // namespace arc | 198 } // namespace arc |
OLD | NEW |