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

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

Issue 2868613002: Linux native notifications: Escape body text if body-markup is supported (Closed)
Patch Set: 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
« 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: 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 e813db39afc646517996587f4b02653110940900..2ae59a5adbd0d941615918f5fe05bff88a4eae3f 100644
--- a/chrome/browser/notifications/notification_platform_bridge_linux.cc
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.cc
@@ -407,30 +407,41 @@ class NotificationPlatformBridgeLinuxImpl
writer.AppendString(base::UTF16ToUTF8(notification->title()));
- writer.AppendString(base::UTF16ToUTF8(notification->message()));
+ std::string body;
+ if (capabilities_.count("body")) {
Lei Zhang 2017/05/06 00:29:34 base::ContainsKey(capabilities_, key) here and bel
Tom (Use chromium acct) 2017/05/08 21:12:39 Done.
+ body = base::UTF16ToUTF8(notification->message());
+ if (capabilities_.count("body-markup")) {
+ base::ReplaceSubstringsAfterOffset(&body, 0, "&", "&");
+ base::ReplaceSubstringsAfterOffset(&body, 0, "<", "&lt;");
+ base::ReplaceSubstringsAfterOffset(&body, 0, ">", "&gt;");
+ }
+ }
+ writer.AppendString(body);
// Even-indexed elements in this vector are action IDs passed back to
// us in OnActionInvoked(). Odd-indexed ones contain the button text.
std::vector<std::string> actions;
- data->action_start = data->action_end;
- for (const auto& button_info : notification->buttons()) {
- // FDO notification buttons can contain either an icon or a label,
- // but not both, and the type of all buttons must be the same (all
- // labels or all icons), so always use labels.
- const std::string id = base::SizeTToString(data->action_end++);
- const std::string label = base::UTF16ToUTF8(button_info.title);
- actions.push_back(id);
- actions.push_back(label);
+ if (capabilities_.count("actions")) {
+ data->action_start = data->action_end;
+ for (const auto& button_info : notification->buttons()) {
+ // FDO notification buttons can contain either an icon or a label,
+ // but not both, and the type of all buttons must be the same (all
+ // labels or all icons), so always use labels.
+ const std::string id = base::SizeTToString(data->action_end++);
+ const std::string label = base::UTF16ToUTF8(button_info.title);
+ actions.push_back(id);
+ actions.push_back(label);
+ }
+ if (notification->clickable()) {
+ // Special case: the pair ("default", "") will not add a button,
+ // but instead makes the entire notification clickable.
+ actions.push_back(kDefaultButtonId);
+ actions.push_back("");
+ }
+ // Always add a settings button.
+ actions.push_back(kSettingsButtonId);
+ actions.push_back("Settings");
Lei Zhang 2017/05/06 00:29:34 Was this the one where I was asking about localiza
Tom (Use chromium acct) 2017/05/08 21:12:39 Done.
}
- if (notification->clickable()) {
- // Special case: the pair ("default", "") will not add a button,
- // but instead makes the entire notification clickable.
- actions.push_back(kDefaultButtonId);
- actions.push_back("");
- }
- // Always add a settings button.
- actions.push_back(kSettingsButtonId);
- actions.push_back("Settings");
writer.AppendArrayOfStrings(actions);
dbus::MessageWriter hints_writer(nullptr);
« 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