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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/exo/notification_surface_registry.h"
6
7 #include <algorithm>
8
9 #include "components/exo/notification_surface.h"
10
11 namespace exo {
12
13 NotificationSurfaceRegistry::NotificationSurfaceRegistry() {}
14
15 NotificationSurfaceRegistry::~NotificationSurfaceRegistry() {}
16
17 NotificationSurface* NotificationSurfaceRegistry::GetSurface(
18 const std::string& notification_key) const {
19 auto it = notification_surface_map_.find(notification_key);
20 return it == notification_surface_map_.end() ? nullptr : it->second;
21 }
22
23 void NotificationSurfaceRegistry::AddSurface(NotificationSurface* surface) {
24 if (notification_surface_map_.find(surface->notification_id()) !=
25 notification_surface_map_.end()) {
26 NOTREACHED();
27 return;
28 }
29
30 notification_surface_map_[surface->notification_id()] = surface;
31
32 FOR_EACH_OBSERVER(Observer, observers_, OnNotificationSurfaceAdded(surface));
33 }
34
35 void NotificationSurfaceRegistry::RemoveSurface(NotificationSurface* surface) {
36 auto it = notification_surface_map_.find(surface->notification_id());
37 if (it == notification_surface_map_.end())
38 return;
39
40 notification_surface_map_.erase(it);
41 FOR_EACH_OBSERVER(Observer, observers_,
42 OnNotificationSurfaceRemoved(surface));
43 }
44
45 void NotificationSurfaceRegistry::AddObserver(Observer* observer) {
46 observers_.AddObserver(observer);
47 }
48
49 void NotificationSurfaceRegistry::RemoveObserver(Observer* observer) {
50 observers_.RemoveObserver(observer);
51 }
52
53 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698