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

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

Issue 2794103002: Add initial support for native Linux desktop notifications (Closed)
Patch Set: Rebase, address peter@'s comments 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/notification_platform_bridge_linux.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/notifications/notification.h"
9
10 namespace {
11
12 const char kFreedesktopNotificationsName[] = "org.freedesktop.Notifications";
13 const char kFreedesktopNotificationsPath[] = "/org/freedesktop/Notifications";
14
15 } // anonymous namespace
Lei Zhang 2017/04/04 07:47:21 s/anonymous //
Tom (Use chromium acct) 2017/04/04 21:47:10 Done.
16
17 // static
18 NotificationPlatformBridge* NotificationPlatformBridge::Create() {
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)
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.
27 return new NotificationPlatformBridgeLinux(
28 message_center::MessageCenter::Get(), notification_proxy);
29 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
30 }
31
32 NotificationPlatformBridgeLinux::NotificationPlatformBridgeLinux(
33 message_center::MessageCenter* message_center,
34 GDBusProxy* notification_proxy)
35 : message_center_(message_center), notification_proxy_(notification_proxy) {
36 (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
37 }
38
39 NotificationPlatformBridgeLinux::~NotificationPlatformBridgeLinux() {
40 g_object_unref(notification_proxy_);
41 }
42
43 void NotificationPlatformBridgeLinux::Display(
44 NotificationCommon::Type notification_type,
45 const std::string& notification_id,
46 const std::string& profile_id,
47 bool is_incognito,
48 const Notification& notification) {
49 // TODO(thomasanderson): Add a complete implementation.
50 g_dbus_proxy_call(
51 notification_proxy_, "Notify",
52 g_variant_new("(susssasa{sv}i)", "", 0, "",
53 base::UTF16ToUTF8(notification.title()).c_str(),
54 base::UTF16ToUTF8(notification.message()).c_str(), nullptr,
55 nullptr, -1),
56 G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr, nullptr);
57 }
58
59 void NotificationPlatformBridgeLinux::Close(
60 const std::string& profile_id,
61 const std::string& notification_id) {
62 NOTIMPLEMENTED();
63 }
64
65 void NotificationPlatformBridgeLinux::GetDisplayed(
66 const std::string& profile_id,
67 bool incognito,
68 const DisplayedNotificationsCallback& callback) const {
69 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.
70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698