OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/notifications/notification_platform_bridge_linux.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/notifications/notification.h" |
| 10 |
| 11 namespace { |
| 12 |
| 13 const char kFreedesktopNotificationsName[] = "org.freedesktop.Notifications"; |
| 14 const char kFreedesktopNotificationsPath[] = "/org/freedesktop/Notifications"; |
| 15 |
| 16 } // namespace |
| 17 |
| 18 // static |
| 19 NotificationPlatformBridge* NotificationPlatformBridge::Create() { |
| 20 GDBusProxy* notification_proxy = g_dbus_proxy_new_for_bus_sync( |
| 21 G_BUS_TYPE_SESSION, |
| 22 static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | |
| 23 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | |
| 24 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START), |
| 25 nullptr, kFreedesktopNotificationsName, kFreedesktopNotificationsPath, |
| 26 kFreedesktopNotificationsName, nullptr, nullptr); |
| 27 if (!notification_proxy) |
| 28 return nullptr; |
| 29 return new NotificationPlatformBridgeLinux(notification_proxy); |
| 30 } |
| 31 |
| 32 NotificationPlatformBridgeLinux::NotificationPlatformBridgeLinux( |
| 33 GDBusProxy* notification_proxy) |
| 34 : notification_proxy_(notification_proxy) {} |
| 35 |
| 36 NotificationPlatformBridgeLinux::~NotificationPlatformBridgeLinux() { |
| 37 g_object_unref(notification_proxy_); |
| 38 } |
| 39 |
| 40 void NotificationPlatformBridgeLinux::Display( |
| 41 NotificationCommon::Type notification_type, |
| 42 const std::string& notification_id, |
| 43 const std::string& profile_id, |
| 44 bool is_incognito, |
| 45 const Notification& notification) { |
| 46 // TODO(thomasanderson): Add a complete implementation. |
| 47 g_dbus_proxy_call( |
| 48 notification_proxy_, "Notify", |
| 49 g_variant_new("(susssasa{sv}i)", "", 0, "", |
| 50 base::UTF16ToUTF8(notification.title()).c_str(), |
| 51 base::UTF16ToUTF8(notification.message()).c_str(), nullptr, |
| 52 nullptr, -1), |
| 53 G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr, nullptr); |
| 54 } |
| 55 |
| 56 void NotificationPlatformBridgeLinux::Close( |
| 57 const std::string& profile_id, |
| 58 const std::string& notification_id) { |
| 59 NOTIMPLEMENTED(); |
| 60 } |
| 61 |
| 62 void NotificationPlatformBridgeLinux::GetDisplayed( |
| 63 const std::string& profile_id, |
| 64 bool incognito, |
| 65 const DisplayedNotificationsCallback& callback) const { |
| 66 callback.Run(base::MakeUnique<std::set<std::string>>(), false); |
| 67 } |
OLD | NEW |