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

Unified Diff: ui/arc/notification/arc_notification_item.cc

Issue 1924213002: ARC: Support Android Notification Priority (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/arc/notification/arc_notification_item.cc
diff --git a/ui/arc/notification/arc_notification_item.cc b/ui/arc/notification/arc_notification_item.cc
index dc7288546f67f9027a7a9f57c14738782afb4e74..d9ac5dd973f49ae0f2dac84840d7d9cd9fc8aa93 100644
--- a/ui/arc/notification/arc_notification_item.cc
+++ b/ui/arc/notification/arc_notification_item.cc
@@ -39,6 +39,28 @@ SkBitmap DecodeImage(const std::vector<uint8_t>& data) {
return bitmap;
}
+// Converts from Android notification priority to Chrome notification priority.
+// On Android, PRIORITY_DEFAULT does not pop up, so this maps PRIORITY_DEFAULT
+// to Chrome's -1 to adapt that behavior. Also, this maps PRIORITY_LOW and _HIGH
+// to -2 and 0 respectively to adjust the value with keeping the order among
+// _LOW, _DEFAULT and _HIGH.
+int convertAndroidPriority(const int android_priority) {
+ switch (android_priority) {
+ case -2: // PRIORITY_MIN
+ case -1: // PRIORITY_LOW
+ return -2;
+ case 0: // PRIORITY_DEFAULT
+ return -1;
+ case 1: // PRIORITY_HIGH
+ return 0;
+ case 2: // PRIORITY_MAX
+ return 2;
+ default:
+ NOTREACHED() << "Invalid Priority: " << android_priority;
+ return 0;
+ }
+}
+
class ArcNotificationDelegate : public message_center::NotificationDelegate {
public:
explicit ArcNotificationDelegate(base::WeakPtr<ArcNotificationItem> item)
@@ -139,6 +161,8 @@ void ArcNotificationItem::UpdateWithArcNotificationData(
// are false.
rich_data.pinned = (data.no_clear || data.ongoing_event);
+ rich_data.priority = convertAndroidPriority(data.priority);
+
// The identifier of the notifier, which is used to distinguish the notifiers
// in the message center.
message_center::NotifierId notifier_id(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698