Chromium Code Reviews| Index: chrome/browser/notifications/notification_platform_bridge_linux.cc |
| diff --git a/chrome/browser/notifications/notification_platform_bridge_linux.cc b/chrome/browser/notifications/notification_platform_bridge_linux.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fab7916cd5b40e572d249d04171db782ce483444 |
| --- /dev/null |
| +++ b/chrome/browser/notifications/notification_platform_bridge_linux.cc |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/notifications/notification_platform_bridge_linux.h" |
| + |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/notifications/notification.h" |
| + |
| +namespace { |
| + |
| +const char kFreedesktopNotificationsName[] = "org.freedesktop.Notifications"; |
| +const char kFreedesktopNotificationsPath[] = "/org/freedesktop/Notifications"; |
| + |
| +} // anonymous namespace |
|
Lei Zhang
2017/04/04 07:47:21
s/anonymous //
Tom (Use chromium acct)
2017/04/04 21:47:10
Done.
|
| + |
| +// static |
| +NotificationPlatformBridge* NotificationPlatformBridge::Create() { |
| + GDBusProxy* notification_proxy = g_dbus_proxy_new_for_bus_sync( |
| + G_BUS_TYPE_SESSION, |
| + static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | |
| + G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | |
| + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START), |
| + nullptr, kFreedesktopNotificationsName, kFreedesktopNotificationsPath, |
| + kFreedesktopNotificationsName, nullptr, nullptr); |
| + if (notification_proxy) |
|
Lei Zhang
2017/04/04 07:47:21
braces, or
if (!notification_proxy)
return null
Tom (Use chromium acct)
2017/04/04 21:47:10
Done.
|
| + return new NotificationPlatformBridgeLinux( |
| + message_center::MessageCenter::Get(), notification_proxy); |
| + return nullptr; |
|
Peter Beverloo
2017/04/04 13:34:46
If my understanding is correct, this means that No
Tom (Use chromium acct)
2017/04/04 21:47:10
Yes
Peter Beverloo
2017/04/04 21:55:09
It's still a bit cumbersome, but following Chromiu
|
| +} |
| + |
| +NotificationPlatformBridgeLinux::NotificationPlatformBridgeLinux( |
| + message_center::MessageCenter* message_center, |
| + GDBusProxy* notification_proxy) |
| + : message_center_(message_center), notification_proxy_(notification_proxy) { |
| + (void)message_center_; // Silence the unused warning. |
|
Lei Zhang
2017/04/04 07:47:21
Is this because we plan to use |message_center_| i
Tom (Use chromium acct)
2017/04/04 21:47:10
Yes, but I think my understanding of MessageCenter
|
| +} |
| + |
| +NotificationPlatformBridgeLinux::~NotificationPlatformBridgeLinux() { |
| + g_object_unref(notification_proxy_); |
| +} |
| + |
| +void NotificationPlatformBridgeLinux::Display( |
| + NotificationCommon::Type notification_type, |
| + const std::string& notification_id, |
| + const std::string& profile_id, |
| + bool is_incognito, |
| + const Notification& notification) { |
| + // TODO(thomasanderson): Add a complete implementation. |
| + g_dbus_proxy_call( |
| + notification_proxy_, "Notify", |
| + g_variant_new("(susssasa{sv}i)", "", 0, "", |
| + base::UTF16ToUTF8(notification.title()).c_str(), |
| + base::UTF16ToUTF8(notification.message()).c_str(), nullptr, |
| + nullptr, -1), |
| + G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr, nullptr); |
| +} |
| + |
| +void NotificationPlatformBridgeLinux::Close( |
| + const std::string& profile_id, |
| + const std::string& notification_id) { |
| + NOTIMPLEMENTED(); |
| +} |
| + |
| +void NotificationPlatformBridgeLinux::GetDisplayed( |
| + const std::string& profile_id, |
| + bool incognito, |
| + const DisplayedNotificationsCallback& callback) const { |
| + NOTIMPLEMENTED(); |
|
Peter Beverloo
2017/04/04 13:34:46
nit: the |callback| has an argument to indicate wh
Tom (Use chromium acct)
2017/04/04 21:47:10
Done.
|
| +} |