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

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

Issue 2794103002: Add initial support for native Linux desktop notifications (Closed)
Patch Set: Refactor, move impl to chrome/browser/notifications 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 unified diff | Download patch
OLDNEW
(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/dbus_notification_manager.h"
6
7 #include "base/strings/utf_string_conversions.h"
8
9 namespace {
10
11 const char kFreedesktopNotificationsName[] = "org.freedesktop.Notifications";
12 const char kFreedesktopNotificationsPath[] = "/org/freedesktop/Notifications";
13
14 } // anonymous namespace
15
16 // static
17 DbusNotificationManager* DbusNotificationManager::CreateDbusNotificationManager(
18 message_center::MessageCenter* message_center) {
19 GDBusProxy* notification_proxy = g_dbus_proxy_new_for_bus_sync(
20 G_BUS_TYPE_SESSION,
21 static_cast<GDBusProxyFlags>(G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
22 G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS |
23 G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START),
24 nullptr, kFreedesktopNotificationsName, kFreedesktopNotificationsPath,
25 kFreedesktopNotificationsName, nullptr, nullptr);
26 if (notification_proxy)
27 return new DbusNotificationManager(message_center, notification_proxy);
28 return nullptr;
29 }
30
31 DbusNotificationManager::DbusNotificationManager(
32 message_center::MessageCenter* message_center,
33 GDBusProxy* notification_proxy)
34 : message_center_(message_center), notification_proxy_(notification_proxy) {
35 message_center_->AddObserver(this);
36 }
37
38 DbusNotificationManager::~DbusNotificationManager() {
39 g_object_unref(notification_proxy_);
40 }
41
42 void DbusNotificationManager::OnNotificationAdded(
43 const std::string& notification_id) {
44 // TODO(thomasanderson): Add a complete implemenatation.
Peter Beverloo 2017/04/03 23:39:29 What's the best documentation I can read on the av
Tom (Use chromium acct) 2017/04/04 02:43:17 The Freedesktop notifications spec: https://develo
45 message_center::Notification* notification =
46 message_center_->FindVisibleNotificationById(notification_id);
47 if (!notification)
48 return;
49 g_dbus_proxy_call(
50 notification_proxy_, "Notify",
51 g_variant_new("(susssasa{sv}i)", "", 0, "",
52 base::UTF16ToUTF8(notification->title()).c_str(),
53 base::UTF16ToUTF8(notification->message()).c_str(), nullptr,
54 nullptr, -1),
55 G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr, nullptr);
56 }
57
58 void DbusNotificationManager::OnNotificationRemoved(
59 const std::string& notification_id,
60 bool by_user) {
61 NOTIMPLEMENTED();
62 }
63
64 void DbusNotificationManager::OnNotificationUpdated(
65 const std::string& notification_id) {
66 NOTIMPLEMENTED();
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698