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

Unified Diff: chrome/browser/notifications/notification_platform_bridge_linux.cc

Issue 2866333002: Linux native notifications: Add percentage to title for progress notifications (Closed)
Patch Set: Add unit test Created 3 years, 7 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
Index: chrome/browser/notifications/notification_platform_bridge_linux.cc
diff --git a/chrome/browser/notifications/notification_platform_bridge_linux.cc b/chrome/browser/notifications/notification_platform_bridge_linux.cc
index aa3a6efc57271c5443f25d7acfd1bbb44f051a31..bcb2e3a551ef3b152ff3e2a262939da66a79085d 100644
--- a/chrome/browser/notifications/notification_platform_bridge_linux.cc
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.cc
@@ -14,6 +14,7 @@
#include "base/barrier_closure.h"
#include "base/files/file_util.h"
+#include "base/i18n/number_formatting.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/nullable_string16.h"
#include "base/strings/string_number_conversions.h"
@@ -57,6 +58,16 @@ enum class ConnectionInitializationStatusCode {
NUM_ITEMS
};
+base::string16 CreateNotificationTitle(const Notification& notification) {
+ base::string16 title;
+ if (notification.type() == message_center::NOTIFICATION_TYPE_PROGRESS) {
+ title += base::FormatPercent(notification.progress());
+ title += base::UTF8ToUTF16(" - ");
+ }
+ title += notification.title();
+ return title;
+}
+
gfx::Image DeepCopyImage(const gfx::Image& image) {
if (image.IsEmpty())
return gfx::Image();
@@ -432,7 +443,8 @@ class NotificationPlatformBridgeLinuxImpl
// app_icon passed implicitly via desktop-entry.
writer.AppendString("");
- writer.AppendString(base::UTF16ToUTF8(notification->title()));
+ writer.AppendString(
+ base::UTF16ToUTF8(CreateNotificationTitle(*notification)));
std::string body;
if (base::ContainsKey(capabilities_, "body")) {

Powered by Google App Engine
This is Rietveld 408576698