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

Side by Side 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, 5 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
« no previous file with comments | « ui/arc/notification/arc_notification_surface_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h"
6
7 #include <algorithm>
8
9 #include "components/exo/notification_surface.h"
10
11 namespace arc {
12
13 namespace {
14
15 ArcNotificationSurfaceManager* instance = nullptr;
16
17 } // namespace
18
19 ArcNotificationSurfaceManager::ArcNotificationSurfaceManager() {
20 DCHECK(!instance);
21 instance = this;
22 }
23
24 ArcNotificationSurfaceManager::~ArcNotificationSurfaceManager() {
25 DCHECK_EQ(this, instance);
26 instance = nullptr;
27 }
28
29 // static
30 ArcNotificationSurfaceManager* ArcNotificationSurfaceManager::Get() {
31 return instance;
32 }
33
34 exo::NotificationSurface* ArcNotificationSurfaceManager::GetSurface(
35 const std::string& notification_key) const {
36 auto it = notification_surface_map_.find(notification_key);
37 return it == notification_surface_map_.end() ? nullptr : it->second;
38 }
39
40 void ArcNotificationSurfaceManager::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()] = surface;
49
50 FOR_EACH_OBSERVER(Observer, observers_, OnNotificationSurfaceAdded(surface));
51 }
52
53 void ArcNotificationSurfaceManager::RemoveSurface(
54 exo::NotificationSurface* surface) {
55 auto it = notification_surface_map_.find(surface->notification_id());
56 if (it == notification_surface_map_.end())
57 return;
58
59 notification_surface_map_.erase(it);
60 FOR_EACH_OBSERVER(Observer, observers_,
61 OnNotificationSurfaceRemoved(surface));
62 }
63
64 void ArcNotificationSurfaceManager::AddObserver(Observer* observer) {
65 observers_.AddObserver(observer);
66 }
67
68 void ArcNotificationSurfaceManager::RemoveObserver(Observer* observer) {
69 observers_.RemoveObserver(observer);
70 }
71
72 } // namespace arc
OLDNEW
« 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