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 11 matching lines...) Expand all Loading... |
22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
23 #include "base/task_scheduler/post_task.h" | 23 #include "base/task_scheduler/post_task.h" |
24 #include "base/version.h" | 24 #include "base/version.h" |
25 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
26 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
27 #include "chrome/browser/notifications/native_notification_display_service.h" | 27 #include "chrome/browser/notifications/native_notification_display_service.h" |
28 #include "chrome/browser/notifications/notification.h" | 28 #include "chrome/browser/notifications/notification.h" |
29 #include "chrome/browser/notifications/notification_display_service_factory.h" | 29 #include "chrome/browser/notifications/notification_display_service_factory.h" |
30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
31 #include "chrome/browser/shell_integration_linux.h" | 31 #include "chrome/browser/shell_integration_linux.h" |
| 32 #include "chrome/grit/generated_resources.h" |
32 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
33 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
34 #include "dbus/bus.h" | 35 #include "dbus/bus.h" |
35 #include "dbus/message.h" | 36 #include "dbus/message.h" |
36 #include "dbus/object_proxy.h" | 37 #include "dbus/object_proxy.h" |
| 38 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/gfx/image/image_skia.h" | 39 #include "ui/gfx/image/image_skia.h" |
38 | 40 |
39 namespace { | 41 namespace { |
40 | 42 |
41 const char kFreedesktopNotificationsName[] = "org.freedesktop.Notifications"; | 43 const char kFreedesktopNotificationsName[] = "org.freedesktop.Notifications"; |
42 const char kFreedesktopNotificationsPath[] = "/org/freedesktop/Notifications"; | 44 const char kFreedesktopNotificationsPath[] = "/org/freedesktop/Notifications"; |
43 | 45 |
44 const char kDefaultButtonId[] = "default"; | 46 const char kDefaultButtonId[] = "default"; |
45 const char kSettingsButtonId[] = "settings"; | 47 const char kSettingsButtonId[] = "settings"; |
46 | 48 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 actions.push_back(label); | 462 actions.push_back(label); |
461 } | 463 } |
462 if (notification->clickable()) { | 464 if (notification->clickable()) { |
463 // Special case: the pair ("default", "") will not add a button, | 465 // Special case: the pair ("default", "") will not add a button, |
464 // but instead makes the entire notification clickable. | 466 // but instead makes the entire notification clickable. |
465 actions.push_back(kDefaultButtonId); | 467 actions.push_back(kDefaultButtonId); |
466 actions.push_back(""); | 468 actions.push_back(""); |
467 } | 469 } |
468 // Always add a settings button. | 470 // Always add a settings button. |
469 actions.push_back(kSettingsButtonId); | 471 actions.push_back(kSettingsButtonId); |
470 // TODO(thomasanderson): Localize this string. | 472 actions.push_back( |
471 actions.push_back("Settings"); | 473 l10n_util::GetStringUTF8(IDS_NOTIFICATION_BUTTON_SETTINGS)); |
472 } | 474 } |
473 writer.AppendArrayOfStrings(actions); | 475 writer.AppendArrayOfStrings(actions); |
474 | 476 |
475 dbus::MessageWriter hints_writer(nullptr); | 477 dbus::MessageWriter hints_writer(nullptr); |
476 writer.OpenArray("{sv}", &hints_writer); | 478 writer.OpenArray("{sv}", &hints_writer); |
477 dbus::MessageWriter urgency_writer(nullptr); | 479 dbus::MessageWriter urgency_writer(nullptr); |
478 hints_writer.OpenDictEntry(&urgency_writer); | 480 hints_writer.OpenDictEntry(&urgency_writer); |
479 urgency_writer.AppendString("urgency"); | 481 urgency_writer.AppendString("urgency"); |
480 urgency_writer.AppendVariantOfUint32( | 482 urgency_writer.AppendVariantOfUint32( |
481 NotificationPriorityToFdoUrgency(notification->priority())); | 483 NotificationPriorityToFdoUrgency(notification->priority())); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 } | 782 } |
781 | 783 |
782 void NotificationPlatformBridgeLinux::SetReadyCallback( | 784 void NotificationPlatformBridgeLinux::SetReadyCallback( |
783 NotificationBridgeReadyCallback callback) { | 785 NotificationBridgeReadyCallback callback) { |
784 impl_->SetReadyCallback(std::move(callback)); | 786 impl_->SetReadyCallback(std::move(callback)); |
785 } | 787 } |
786 | 788 |
787 void NotificationPlatformBridgeLinux::CleanUp() { | 789 void NotificationPlatformBridgeLinux::CleanUp() { |
788 impl_->CleanUp(); | 790 impl_->CleanUp(); |
789 } | 791 } |
OLD | NEW |