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

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

Issue 2875443002: Linux native notifications: Support list notifications (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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 writer.AppendString(""); 433 writer.AppendString("");
434 434
435 std::string summary = base::UTF16ToUTF8(notification->title()); 435 std::string summary = base::UTF16ToUTF8(notification->title());
436 if (notification->type() == message_center::NOTIFICATION_TYPE_PROGRESS) 436 if (notification->type() == message_center::NOTIFICATION_TYPE_PROGRESS)
437 summary = base::IntToString(notification->progress()) + "% - " + summary; 437 summary = base::IntToString(notification->progress()) + "% - " + summary;
438 writer.AppendString(summary); 438 writer.AppendString(summary);
439 439
440 std::string body; 440 std::string body;
441 if (base::ContainsKey(capabilities_, "body")) { 441 if (base::ContainsKey(capabilities_, "body")) {
442 body = base::UTF16ToUTF8(notification->message()); 442 body = base::UTF16ToUTF8(notification->message());
443 if (base::ContainsKey(capabilities_, "body-markup")) { 443 const bool body_markup = base::ContainsKey(capabilities_, "body-markup");
444 if (body_markup) {
444 base::ReplaceSubstringsAfterOffset(&body, 0, "&", "&amp;"); 445 base::ReplaceSubstringsAfterOffset(&body, 0, "&", "&amp;");
445 base::ReplaceSubstringsAfterOffset(&body, 0, "<", "&lt;"); 446 base::ReplaceSubstringsAfterOffset(&body, 0, "<", "&lt;");
446 base::ReplaceSubstringsAfterOffset(&body, 0, ">", "&gt;"); 447 base::ReplaceSubstringsAfterOffset(&body, 0, ">", "&gt;");
447 } 448 }
449 if (notification->type() == message_center::NOTIFICATION_TYPE_MULTIPLE) {
450 for (const auto& item : notification->items()) {
451 if (!body.empty())
452 body += "\n";
453 const std::string title = base::UTF16ToUTF8(item.title);
454 const std::string message = base::UTF16ToUTF8(item.message);
455 if (body_markup)
456 body += "<b>" + title + "</b> " + message;
Peter Beverloo 2017/05/09 22:52:04 Could you add a TODO (in my name if you prefer) to
Tom (Use chromium acct) 2017/05/10 20:41:31 Done.
457 else
458 body += title + " - " + message;
Peter Beverloo 2017/05/09 22:52:04 Does the newline (:452) work even for notification
Tom (Use chromium acct) 2017/05/10 20:41:31 Yes
459 }
460 }
448 } 461 }
449 writer.AppendString(body); 462 writer.AppendString(body);
450 463
451 // Even-indexed elements in this vector are action IDs passed back to 464 // Even-indexed elements in this vector are action IDs passed back to
452 // us in OnActionInvoked(). Odd-indexed ones contain the button text. 465 // us in OnActionInvoked(). Odd-indexed ones contain the button text.
453 std::vector<std::string> actions; 466 std::vector<std::string> actions;
454 if (base::ContainsKey(capabilities_, "actions")) { 467 if (base::ContainsKey(capabilities_, "actions")) {
455 data->action_start = data->action_end; 468 data->action_start = data->action_end;
456 for (const auto& button_info : notification->buttons()) { 469 for (const auto& button_info : notification->buttons()) {
457 // FDO notification buttons can contain either an icon or a label, 470 // FDO notification buttons can contain either an icon or a label,
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 804 }
792 805
793 void NotificationPlatformBridgeLinux::SetReadyCallback( 806 void NotificationPlatformBridgeLinux::SetReadyCallback(
794 NotificationBridgeReadyCallback callback) { 807 NotificationBridgeReadyCallback callback) {
795 impl_->SetReadyCallback(std::move(callback)); 808 impl_->SetReadyCallback(std::move(callback));
796 } 809 }
797 810
798 void NotificationPlatformBridgeLinux::CleanUp() { 811 void NotificationPlatformBridgeLinux::CleanUp() {
799 impl_->CleanUp(); 812 impl_->CleanUp();
800 } 813 }
OLDNEW
« 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