| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 case ArcNotificationType::PROGRESS: | 120 case 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(ArcNotificationType_IsValidValue(data.type)) | 130 DCHECK(IsKnownEnumValue(data.type)) << "Unsupported notification type: " |
| 131 << "Unsupported notification type: " << data.type; | 131 << data.type; |
| 132 | 132 |
| 133 for (size_t i = 0; i < data.buttons.size(); i++) { | 133 for (size_t i = 0; i < data.buttons.size(); i++) { |
| 134 rich_data.buttons.push_back(message_center::ButtonInfo( | 134 rich_data.buttons.push_back(message_center::ButtonInfo( |
| 135 base::UTF8ToUTF16(data.buttons.at(i)->label.get()))); | 135 base::UTF8ToUTF16(data.buttons.at(i)->label.get()))); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // The identifier of the notifier, which is used to distinguish the notifiers | 138 // The identifier of the notifier, which is used to distinguish the notifiers |
| 139 // in the message center. | 139 // in the message center. |
| 140 message_center::NotifierId notifier_id( | 140 message_center::NotifierId notifier_id( |
| 141 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); | 141 message_center::NotifierId::SYSTEM_COMPONENT, kNotifierId); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 message_center_->AddNotification(std::move(notification_)); | 204 message_center_->AddNotification(std::move(notification_)); |
| 205 | 205 |
| 206 if (newer_data_) { | 206 if (newer_data_) { |
| 207 // There is the newer data, so updates again. | 207 // There is the newer data, so updates again. |
| 208 ArcNotificationDataPtr data(std::move(newer_data_)); | 208 ArcNotificationDataPtr data(std::move(newer_data_)); |
| 209 UpdateWithArcNotificationData(*data); | 209 UpdateWithArcNotificationData(*data); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace arc | 213 } // namespace arc |
| OLD | NEW |