Chromium Code Reviews| 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, "<", "<"); |
| + base::ReplaceSubstringsAfterOffset(&body, 0, ">", ">"); |
| + } |
| + } |
| + 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); |