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

Unified Diff: chrome/browser/notifications/notification_platform_bridge_linux.cc

Issue 2794103002: Add initial support for native Linux desktop notifications (Closed)
Patch Set: Remove unused import Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_linux.h ('k') | chrome/common/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6a0f8974c804f7e3ef7e9dbbef6546c7fc14068c
--- /dev/null
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.cc
@@ -0,0 +1,67 @@
+// 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/memory/ptr_util.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";
+
+} // namespace
+
+// 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)
+ return nullptr;
+ return new NotificationPlatformBridgeLinux(notification_proxy);
+}
+
+NotificationPlatformBridgeLinux::NotificationPlatformBridgeLinux(
+ GDBusProxy* notification_proxy)
+ : notification_proxy_(notification_proxy) {}
+
+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 {
+ callback.Run(base::MakeUnique<std::set<std::string>>(), false);
+}
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_linux.h ('k') | chrome/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698