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

Unified Diff: components/exo/notification_surface_registry.h

Issue 2065133002: exo: Implement notification surface support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification-wayland-protocol
Patch Set: for comments in #2 Created 4 years, 6 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: components/exo/notification_surface_registry.h
diff --git a/components/exo/notification_surface_registry.h b/components/exo/notification_surface_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..2ddfb95450b517a5e3aa01ae04cd0d4105ef8762
--- /dev/null
+++ b/components/exo/notification_surface_registry.h
@@ -0,0 +1,56 @@
+// Copyright 2016 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.
+
+#ifndef COMPONENTS_EXO_NOTIFICATION_SURFACE_REGISTRY_H_
+#define COMPONENTS_EXO_NOTIFICATION_SURFACE_REGISTRY_H_
+
+#include <map>
+#include <string>
+
+#include "base/macros.h"
+#include "base/observer_list.h"
+
+namespace exo {
+
+class NotificationSurface;
+
+// Keeps track of NotificationSurface.
+class NotificationSurfaceRegistry {
reveman 2016/06/22 16:44:30 There seems to be multiple levels of indirection h
xiyuan 2016/06/23 14:46:43 Okay. I moved this into ui/arc. However, I did not
+ public:
+ class Observer {
+ public:
+ // Invoked when a notification surface is added to the registry.
+ virtual void OnNotificationSurfaceAdded(NotificationSurface* surface) = 0;
+
+ // Invoked when a notification surface is removed from the registry.
+ virtual void OnNotificationSurfaceRemoved(NotificationSurface* surface) = 0;
+
+ protected:
+ virtual ~Observer() = default;
+ };
+
+ NotificationSurfaceRegistry();
+ ~NotificationSurfaceRegistry();
+
+ NotificationSurface* GetSurface(const std::string& notification_key) const;
+
+ void AddSurface(NotificationSurface* surface);
+ void RemoveSurface(NotificationSurface* surface);
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ private:
+ using NotificationSurfaceMap =
+ std::map<std::string, exo::NotificationSurface*>;
+ NotificationSurfaceMap notification_surface_map_;
+
+ base::ObserverList<Observer> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationSurfaceRegistry);
+};
+
+} // namespace exo
+
+#endif // COMPONENTS_EXO_NOTIFICATION_SURFACE_REGISTRY_H_

Powered by Google App Engine
This is Rietveld 408576698