OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/notifications/notification_platform_bridge_linux.h" | 5 #include "chrome/browser/notifications/notification_platform_bridge_linux.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <unordered_map> | 10 #include <unordered_map> |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 468 |
469 // app_icon passed implicitly via desktop-entry. | 469 // app_icon passed implicitly via desktop-entry. |
470 writer.AppendString(""); | 470 writer.AppendString(""); |
471 | 471 |
472 writer.AppendString( | 472 writer.AppendString( |
473 base::UTF16ToUTF8(CreateNotificationTitle(*notification))); | 473 base::UTF16ToUTF8(CreateNotificationTitle(*notification))); |
474 | 474 |
475 std::string body; | 475 std::string body; |
476 if (base::ContainsKey(capabilities_, kCapabilityBody)) { | 476 if (base::ContainsKey(capabilities_, kCapabilityBody)) { |
477 body = base::UTF16ToUTF8(notification->message()); | 477 body = base::UTF16ToUTF8(notification->message()); |
478 if (base::ContainsKey(capabilities_, kCapabilityBodyMarkup)) { | 478 const bool body_markup = |
| 479 base::ContainsKey(capabilities_, kCapabilityBodyMarkup); |
| 480 if (body_markup) { |
479 base::ReplaceSubstringsAfterOffset(&body, 0, "&", "&"); | 481 base::ReplaceSubstringsAfterOffset(&body, 0, "&", "&"); |
480 base::ReplaceSubstringsAfterOffset(&body, 0, "<", "<"); | 482 base::ReplaceSubstringsAfterOffset(&body, 0, "<", "<"); |
481 base::ReplaceSubstringsAfterOffset(&body, 0, ">", ">"); | 483 base::ReplaceSubstringsAfterOffset(&body, 0, ">", ">"); |
482 } | 484 } |
| 485 if (notification->type() == message_center::NOTIFICATION_TYPE_MULTIPLE) { |
| 486 for (const auto& item : notification->items()) { |
| 487 if (!body.empty()) |
| 488 body += "\n"; |
| 489 const std::string title = base::UTF16ToUTF8(item.title); |
| 490 const std::string message = base::UTF16ToUTF8(item.message); |
| 491 // TODO(peter): Figure out the right way to internationalize |
| 492 // this for RTL languages. |
| 493 if (body_markup) |
| 494 body += "<b>" + title + "</b> " + message; |
| 495 else |
| 496 body += title + " - " + message; |
| 497 } |
| 498 } |
483 } | 499 } |
484 writer.AppendString(body); | 500 writer.AppendString(body); |
485 | 501 |
486 // Even-indexed elements in this vector are action IDs passed back to | 502 // Even-indexed elements in this vector are action IDs passed back to |
487 // us in OnActionInvoked(). Odd-indexed ones contain the button text. | 503 // us in OnActionInvoked(). Odd-indexed ones contain the button text. |
488 std::vector<std::string> actions; | 504 std::vector<std::string> actions; |
489 if (base::ContainsKey(capabilities_, kCapabilityActions)) { | 505 if (base::ContainsKey(capabilities_, kCapabilityActions)) { |
490 data->action_start = data->action_end; | 506 data->action_start = data->action_end; |
491 for (const auto& button_info : notification->buttons()) { | 507 for (const auto& button_info : notification->buttons()) { |
492 // FDO notification buttons can contain either an icon or a label, | 508 // FDO notification buttons can contain either an icon or a label, |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 } | 840 } |
825 | 841 |
826 void NotificationPlatformBridgeLinux::SetReadyCallback( | 842 void NotificationPlatformBridgeLinux::SetReadyCallback( |
827 NotificationBridgeReadyCallback callback) { | 843 NotificationBridgeReadyCallback callback) { |
828 impl_->SetReadyCallback(std::move(callback)); | 844 impl_->SetReadyCallback(std::move(callback)); |
829 } | 845 } |
830 | 846 |
831 void NotificationPlatformBridgeLinux::CleanUp() { | 847 void NotificationPlatformBridgeLinux::CleanUp() { |
832 impl_->CleanUp(); | 848 impl_->CleanUp(); |
833 } | 849 } |
OLD | NEW |