OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_LINUX_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_LINUX_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_LINUX_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_LINUX_H_ |
7 | 7 |
8 #include <gio/gio.h> | 8 #include <gio/gio.h> |
9 | 9 |
| 10 #include <unordered_map> |
| 11 |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "chrome/browser/notifications/notification_platform_bridge.h" | 13 #include "chrome/browser/notifications/notification_platform_bridge.h" |
| 14 #include "ui/base/glib/scoped_gobject.h" |
12 | 15 |
13 class NotificationPlatformBridgeLinux : public NotificationPlatformBridge { | 16 class NotificationPlatformBridgeLinux : public NotificationPlatformBridge { |
14 public: | 17 public: |
15 explicit NotificationPlatformBridgeLinux(GDBusProxy* notification_proxy); | 18 explicit NotificationPlatformBridgeLinux(GDBusProxy* notification_proxy); |
16 | 19 |
17 ~NotificationPlatformBridgeLinux() override; | 20 ~NotificationPlatformBridgeLinux() override; |
18 | 21 |
19 // NotificationPlatformBridge: | 22 // NotificationPlatformBridge: |
20 void Display(NotificationCommon::Type notification_type, | 23 void Display(NotificationCommon::Type notification_type, |
21 const std::string& notification_id, | 24 const std::string& notification_id, |
22 const std::string& profile_id, | 25 const std::string& profile_id, |
23 bool is_incognito, | 26 bool is_incognito, |
24 const Notification& notification) override; | 27 const Notification& notification) override; |
25 void Close(const std::string& profile_id, | 28 void Close(const std::string& profile_id, |
26 const std::string& notification_id) override; | 29 const std::string& notification_id) override; |
27 void GetDisplayed( | 30 void GetDisplayed( |
28 const std::string& profile_id, | 31 const std::string& profile_id, |
29 bool incognito, | 32 bool incognito, |
30 const DisplayedNotificationsCallback& callback) const override; | 33 const DisplayedNotificationsCallback& callback) const override; |
31 | 34 |
| 35 // Called from NotifyCompleteReceiver(). |
| 36 void NotifyCompleteInternal(gpointer user_data, GVariant* value); |
| 37 |
32 private: | 38 private: |
33 GDBusProxy* const notification_proxy_; | 39 struct NotificationData; |
| 40 |
| 41 ScopedGObject<GDBusProxy> notification_proxy_; |
| 42 |
| 43 // A std::set<std::unique_ptr<T>> doesn't work well because |
| 44 // eg. std::set::erase(T) would require a std::unique_ptr<T> |
| 45 // argument, so the data would get double-destructed. |
| 46 template <typename T> |
| 47 using UnorderedUniqueSet = std::unordered_map<T*, std::unique_ptr<T>>; |
| 48 |
| 49 UnorderedUniqueSet<NotificationData> notifications_; |
| 50 |
| 51 // Makes the "Notify" call to D-Bus. |
| 52 void NotifyNow(uint32_t dbus_id, |
| 53 NotificationCommon::Type notification_type, |
| 54 const Notification& notification, |
| 55 GCancellable* cancellable, |
| 56 GAsyncReadyCallback callback, |
| 57 gpointer user_data); |
| 58 |
| 59 // Makes the "CloseNotification" call to D-Bus. |
| 60 void CloseNow(uint32_t dbus_id); |
| 61 |
| 62 NotificationData* FindNotificationData(const std::string& notification_id, |
| 63 const std::string& profile_id); |
34 | 64 |
35 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinux); | 65 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinux); |
36 }; | 66 }; |
37 | 67 |
38 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_LINUX_H_ | 68 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_LINUX_H_ |
OLD | NEW |