Notifications: Use correct DBus type for urgency
According to the freedesktop notification specification, the urgency
hint should have a type BYTE, while currently it uses UINT32. This
causes some notification daemons to ignore notifications from chrome.
To fix this, we just use DbusByte for urgency.
Relevant section of the specification:
https://specifications.freedesktop.org/notification-spec/latest/hints.html
It is also worth noting that this is not a recent change in the
specification, so it was just a mistake in the initial implementation,
as can be seen in older versions of the specification:
https://galago-project.org/specs/notification/0.9/x344.html
Bug: 41494195
Change-Id: Ibc71c9f30e85579d0c5d377e5972a1b8e4e99d20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6481253
Reviewed-by: Finnur Thorarinsson <finnur@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Auto-Submit: Omar Emara <mail@OmarEmara.dev>
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1450438}
diff --git a/AUTHORS b/AUTHORS
index 3f45774d..370c0fd3 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1104,6 +1104,7 @@
Oliver Dunk <oliver@oliverdunk.com>
Olivier Tilloy <olivier+chromium@tilloy.net>
Olli Raula (Old name Olli Syrjälä) <olli.raula@intel.com>
+Omar Emara <mail@OmarEmara.dev>
Omar Sandoval <osandov@osandov.com>
Omar Shawky <omarmshawky11@gmail.com>
Orko Garai <orko.garai@gmail.com>
diff --git a/chrome/browser/notifications/notification_platform_bridge_linux.cc b/chrome/browser/notifications/notification_platform_bridge_linux.cc
index 4f7132a..3c31ef81 100644
--- a/chrome/browser/notifications/notification_platform_bridge_linux.cc
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.cc
@@ -159,7 +159,7 @@
base::ReplaceChars(*message, ">", ">", message);
}
-int NotificationPriorityToFdoUrgency(int priority) {
+uint8_t NotificationPriorityToFdoUrgency(int priority) {
switch (priority) {
case message_center::MIN_PRIORITY:
case message_center::LOW_PRIORITY:
@@ -802,12 +802,12 @@
DbusDictionary hints;
- uint32_t urgency =
+ uint8_t urgency =
notification->never_timeout() &&
ShouldMarkPersistentNotificationsAsCritical(server_name_)
? URGENCY_CRITICAL
: NotificationPriorityToFdoUrgency(notification->priority());
- hints.PutAs("urgency", DbusUint32(urgency));
+ hints.PutAs("urgency", DbusByte(urgency));
if (notification->silent()) {
hints.PutAs("suppress-sound", DbusBoolean(true));