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 260d97802b3f5444150a6f842a10df7d2133b88d..b81a1372c60bb15ee949593803d41b4eec313895 100644 |
--- a/chrome/browser/notifications/notification_platform_bridge_linux.cc |
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.cc |
@@ -32,6 +32,7 @@ |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/shell_integration_linux.h" |
#include "chrome/grit/generated_resources.h" |
+#include "components/url_formatter/elide_url.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/notification_service.h" |
#include "dbus/bus.h" |
@@ -136,6 +137,7 @@ int NotificationPriorityToFdoUrgency(int priority) { |
// the image does not need to be resized, or the image is empty, |
// returns |image| directly. |
gfx::Image ResizeImageToFdoMaxSize(const gfx::Image& image) { |
+ DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
if (image.IsEmpty()) |
return image; |
int width = image.Width(); |
@@ -519,12 +521,32 @@ class NotificationPlatformBridgeLinuxImpl |
if (base::ContainsKey(capabilities_, kCapabilityBody)) { |
const bool body_markup = |
base::ContainsKey(capabilities_, kCapabilityBodyMarkup); |
+ |
+ if (notification->UseOriginAsContextMessage()) { |
+ std::string url_display_text = net::EscapeForHTML( |
+ base::UTF16ToUTF8(url_formatter::FormatUrlForSecurityDisplay( |
+ notification->origin_url(), |
+ url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS))); |
+ if (base::ContainsKey(capabilities_, kCapabilityBodyHyperlinks)) { |
+ body << "<a href=\"" |
+ << net::EscapePath(notification->origin_url().spec()) << "\">" |
+ << url_display_text << "</a>"; |
+ } else { |
+ body << url_display_text; |
+ } |
+ } else if (!notification->context_message().empty()) { |
+ std::string context = |
+ base::UTF16ToUTF8(notification->context_message()); |
+ if (body_markup) |
+ context = net::EscapeForHTML(context); |
+ body << context; |
+ } |
+ |
std::string message = base::UTF16ToUTF8(notification->message()); |
- if (body_markup) { |
- base::ReplaceSubstringsAfterOffset(&message, 0, "&", "&"); |
- base::ReplaceSubstringsAfterOffset(&message, 0, "<", "<"); |
- base::ReplaceSubstringsAfterOffset(&message, 0, ">", ">"); |
- } |
+ if (body_markup) |
+ message = net::EscapeForHTML(message); |
+ if (body.tellp()) |
+ body << "\n"; |
body << message; |
if (notification->type() == message_center::NOTIFICATION_TYPE_MULTIPLE) { |