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

Side by Side Diff: chrome/browser/notifications/notification_platform_bridge_linux.cc

Issue 2875443002: Linux native notifications: Support list notifications (Closed)
Patch Set: Rebase 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, "&", "&amp;"); 481 base::ReplaceSubstringsAfterOffset(&body, 0, "&", "&amp;");
480 base::ReplaceSubstringsAfterOffset(&body, 0, "<", "&lt;"); 482 base::ReplaceSubstringsAfterOffset(&body, 0, "<", "&lt;");
481 base::ReplaceSubstringsAfterOffset(&body, 0, ">", "&gt;"); 483 base::ReplaceSubstringsAfterOffset(&body, 0, ">", "&gt;");
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
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/notifications/notification_platform_bridge_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698