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

Unified Diff: components/exo/notification_surface_registry.cc

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.cc
diff --git a/components/exo/notification_surface_registry.cc b/components/exo/notification_surface_registry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b26bc22ed272d2050a69b0fbe475278e88898855
--- /dev/null
+++ b/components/exo/notification_surface_registry.cc
@@ -0,0 +1,53 @@
+// 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.
+
+#include "components/exo/notification_surface_registry.h"
+
+#include <algorithm>
+
+#include "components/exo/notification_surface.h"
+
+namespace exo {
+
+NotificationSurfaceRegistry::NotificationSurfaceRegistry() {}
+
+NotificationSurfaceRegistry::~NotificationSurfaceRegistry() {}
+
+NotificationSurface* NotificationSurfaceRegistry::GetSurface(
+ const std::string& notification_key) const {
+ auto it = notification_surface_map_.find(notification_key);
+ return it == notification_surface_map_.end() ? nullptr : it->second;
+}
+
+void NotificationSurfaceRegistry::AddSurface(NotificationSurface* surface) {
+ if (notification_surface_map_.find(surface->notification_id()) !=
+ notification_surface_map_.end()) {
+ NOTREACHED();
+ return;
+ }
+
+ notification_surface_map_[surface->notification_id()] = surface;
+
+ FOR_EACH_OBSERVER(Observer, observers_, OnNotificationSurfaceAdded(surface));
+}
+
+void NotificationSurfaceRegistry::RemoveSurface(NotificationSurface* surface) {
+ auto it = notification_surface_map_.find(surface->notification_id());
+ if (it == notification_surface_map_.end())
+ return;
+
+ notification_surface_map_.erase(it);
+ FOR_EACH_OBSERVER(Observer, observers_,
+ OnNotificationSurfaceRemoved(surface));
+}
+
+void NotificationSurfaceRegistry::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void NotificationSurfaceRegistry::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+} // namespace exo

Powered by Google App Engine
This is Rietveld 408576698