| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // previous decode is still in progress. | 97 // previous decode is still in progress. |
| 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 ARC_NOTIFICATION_TYPE_BASIC: | 107 case ArcNotificationType::BASIC: |
| 108 type = message_center::NOTIFICATION_TYPE_SIMPLE; | 108 type = message_center::NOTIFICATION_TYPE_SIMPLE; |
| 109 break; | 109 break; |
| 110 case ARC_NOTIFICATION_TYPE_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_SIMPLE; |
| 113 LOG(ERROR) << "Unsupported notification type: image"; | 113 LOG(ERROR) << "Unsupported notification type: image"; |
| 114 break; | 114 break; |
| 115 case ARC_NOTIFICATION_TYPE_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)))); |
| 123 break; | 123 break; |
| 124 } | 124 } |
| 125 DCHECK(0 <= data.type && data.type <= ARC_NOTIFICATION_TYPE_MAX) | 125 DCHECK(ArcNotificationType_IsValidValue(data.type)) |
| 126 << "Unsupported notification type: " << data.type; | 126 << "Unsupported notification type: " << data.type; |
| 127 | 127 |
| 128 // The identifier of the notifier, which is used to distinguish the notifiers | 128 // The identifier of the notifier, which is used to distinguish the notifiers |
| 129 // in the message center. | 129 // in the message center. |
| 130 message_center::NotifierId notifier_id( | 130 message_center::NotifierId notifier_id( |
| 131 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); | 131 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); |
| 132 notifier_id.profile_id = profile_id_.GetUserEmail(); | 132 notifier_id.profile_id = profile_id_.GetUserEmail(); |
| 133 | 133 |
| 134 DCHECK(!data.title.is_null()); | 134 DCHECK(!data.title.is_null()); |
| 135 DCHECK(!data.message.is_null()); | 135 DCHECK(!data.message.is_null()); |
| (...skipping 53 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 |