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

Side by Side Diff: ui/arc/notification/arc_notification_surface_manager_impl.cc

Issue 2723143002: Add unittests of ArcCustomNotificationView (Closed)
Patch Set: wip Created 3 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 "ui/arc/notification/arc_notification_surface_manager_impl.h"
6
7 #include <algorithm>
8
9 #include "base/memory/ptr_util.h"
10 #include "components/exo/notification_surface.h"
11 #include "ui/arc/notification/arc_notification_surface_impl.h"
12
13 namespace arc {
14
15 ArcNotificationSurfaceManagerImpl::ArcNotificationSurfaceManagerImpl() {}
16
17 ArcNotificationSurfaceManagerImpl::~ArcNotificationSurfaceManagerImpl() {}
18
19 ArcNotificationSurface* ArcNotificationSurfaceManagerImpl::GetArcSurface(
20 const std::string& notification_key) const {
21 auto it = notification_surface_map_.find(notification_key);
22 return it == notification_surface_map_.end() ? nullptr : it->second.get();
23 }
24
25 void ArcNotificationSurfaceManagerImpl::AddObserver(Observer* observer) {
26 observers_.AddObserver(observer);
27 }
28
29 void ArcNotificationSurfaceManagerImpl::RemoveObserver(Observer* observer) {
30 observers_.RemoveObserver(observer);
31 }
32
33 exo::NotificationSurface* ArcNotificationSurfaceManagerImpl::GetSurface(
34 const std::string& notification_key) const {
35 auto it = notification_surface_map_.find(notification_key);
36 return it == notification_surface_map_.end() ? nullptr
37 : it->second->surface();
38 }
39
40 void ArcNotificationSurfaceManagerImpl::AddSurface(
41 exo::NotificationSurface* surface) {
42 if (notification_surface_map_.find(surface->notification_id()) !=
43 notification_surface_map_.end()) {
44 NOTREACHED();
45 return;
46 }
47
48 notification_surface_map_[surface->notification_id()] =
49 base::MakeUnique<ArcNotificationSurfaceImpl>(surface);
50
51 for (auto& observer : observers_) {
52 observer.OnNotificationSurfaceAdded(
53 notification_surface_map_[surface->notification_id()].get());
54 }
55 }
56
57 void ArcNotificationSurfaceManagerImpl::RemoveSurface(
58 exo::NotificationSurface* surface) {
59 auto it = notification_surface_map_.find(surface->notification_id());
60 if (it == notification_surface_map_.end())
61 return;
62
63 auto arc_surface = std::move(it->second);
64 notification_surface_map_.erase(it);
65 for (auto& observer : observers_)
66 observer.OnNotificationSurfaceRemoved(arc_surface.get());
67 }
68
69 } // namespace arc
OLDNEW
« no previous file with comments | « ui/arc/notification/arc_notification_surface_manager_impl.h ('k') | ui/arc/notification/arc_notification_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698