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

Unified Diff: ui/arc/notification/arc_notification_surface_manager.cc

Issue 2066853002: arc: Show custom notification via notification surface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification-exo
Patch Set: rebase 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
« no previous file with comments | « ui/arc/notification/arc_notification_surface_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/arc/notification/arc_notification_surface_manager.cc
diff --git a/ui/arc/notification/arc_notification_surface_manager.cc b/ui/arc/notification/arc_notification_surface_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d816da8a234891c50acc7f88446cccabfb03685f
--- /dev/null
+++ b/ui/arc/notification/arc_notification_surface_manager.cc
@@ -0,0 +1,72 @@
+// 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 "ui/arc/notification/arc_notification_surface_manager.h"
+
+#include <algorithm>
+
+#include "components/exo/notification_surface.h"
+
+namespace arc {
+
+namespace {
+
+ArcNotificationSurfaceManager* instance = nullptr;
+
+} // namespace
+
+ArcNotificationSurfaceManager::ArcNotificationSurfaceManager() {
+ DCHECK(!instance);
+ instance = this;
+}
+
+ArcNotificationSurfaceManager::~ArcNotificationSurfaceManager() {
+ DCHECK_EQ(this, instance);
+ instance = nullptr;
+}
+
+// static
+ArcNotificationSurfaceManager* ArcNotificationSurfaceManager::Get() {
+ return instance;
+}
+
+exo::NotificationSurface* ArcNotificationSurfaceManager::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 ArcNotificationSurfaceManager::AddSurface(
+ exo::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 ArcNotificationSurfaceManager::RemoveSurface(
+ exo::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 ArcNotificationSurfaceManager::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void ArcNotificationSurfaceManager::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+} // namespace arc
« no previous file with comments | « ui/arc/notification/arc_notification_surface_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698