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

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

Issue 1618963006: Mojo C++ bindings: support enum validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
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))));
123 break; 123 break;
124 } 124 }
125 DCHECK(ArcNotificationType_IsValidValue(data.type)) 125 DCHECK(IsKnownEnumValue(data.type)) << "Unsupported notification type: "
126 << "Unsupported notification type: " << data.type; 126 << 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());
136 notification_.reset(new message_center::Notification( 136 notification_.reset(new message_center::Notification(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698