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

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

Issue 2806203003: Linux native notifications: Support icons (Closed)
Patch Set: Address thestig'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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/notification_platform_bridge_linux.h
diff --git a/chrome/browser/notifications/notification_platform_bridge_linux.h b/chrome/browser/notifications/notification_platform_bridge_linux.h
index af0b9ee3629f1967a4fd32e24ccf7598a2391ca0..c63e1db1c42e9cd9d2ac62998dc3ba410d261c41 100644
--- a/chrome/browser/notifications/notification_platform_bridge_linux.h
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.h
@@ -10,11 +10,15 @@
#include <unordered_map>
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "chrome/browser/notifications/notification_platform_bridge.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
#include "ui/base/glib/glib_signal.h"
#include "ui/base/glib/scoped_gobject.h"
-class NotificationPlatformBridgeLinux : public NotificationPlatformBridge {
+class NotificationPlatformBridgeLinux : public NotificationPlatformBridge,
+ public content::NotificationObserver {
public:
explicit NotificationPlatformBridgeLinux(GDBusProxy* notification_proxy);
@@ -38,27 +42,26 @@ class NotificationPlatformBridgeLinux : public NotificationPlatformBridge {
private:
struct NotificationData;
-
- ScopedGObject<GDBusProxy> notification_proxy_;
-
- // Used to disconnect from "g-signal" during destruction.
- gulong proxy_signal_handler_ = 0;
-
- // A std::set<std::unique_ptr<T>> doesn't work well because
- // eg. std::set::erase(T) would require a std::unique_ptr<T>
- // argument, so the data would get double-destructed.
- template <typename T>
- using UnorderedUniqueSet = std::unordered_map<T*, std::unique_ptr<T>>;
-
- UnorderedUniqueSet<NotificationData> notifications_;
+ struct ResourceFiles;
+
+ // content::NotificationObserver:
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
+
+ // Sets up a task to call NotifyNow() after an IO thread writes the
+ // necessary resource files.
+ void Notify(const Notification& notification,
+ NotificationData* data,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
// Makes the "Notify" call to D-Bus.
- void NotifyNow(uint32_t dbus_id,
- NotificationCommon::Type notification_type,
- const Notification& notification,
- GCancellable* cancellable,
+ void NotifyNow(const Notification& notification,
+ base::WeakPtr<NotificationData> data,
GAsyncReadyCallback callback,
- gpointer user_data);
+ gpointer user_data,
+ std::unique_ptr<ResourceFiles> resource_files);
// Makes the "CloseNotification" call to D-Bus.
void CloseNow(uint32_t dbus_id);
@@ -83,6 +86,23 @@ class NotificationPlatformBridgeLinux : public NotificationPlatformBridge {
NotificationData* FindNotificationData(uint32_t dbus_id);
+ ScopedGObject<GDBusProxy> notification_proxy_;
+
+ // Used to disconnect from "g-signal" during destruction.
+ gulong proxy_signal_handler_ = 0;
+
+ // A std::set<std::unique_ptr<T>> doesn't work well because
+ // eg. std::set::erase(T) would require a std::unique_ptr<T>
+ // argument, so the data would get double-destructed.
+ template <typename T>
+ using UnorderedUniqueSet = std::unordered_map<T*, std::unique_ptr<T>>;
+
+ UnorderedUniqueSet<NotificationData> notifications_;
+
+ content::NotificationRegistrar registrar_;
+
+ base::WeakPtrFactory<NotificationPlatformBridgeLinux> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinux);
};

Powered by Google App Engine
This is Rietveld 408576698