| Index: ui/arc/notification/arc_notification_surface_manager_impl.cc
|
| diff --git a/ui/arc/notification/arc_notification_surface_manager_impl.cc b/ui/arc/notification/arc_notification_surface_manager_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..908e1fc5f3277b51b6b19d360feb79ca4c35bb53
|
| --- /dev/null
|
| +++ b/ui/arc/notification/arc_notification_surface_manager_impl.cc
|
| @@ -0,0 +1,69 @@
|
| +// 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_impl.h"
|
| +
|
| +#include <algorithm>
|
| +
|
| +#include "base/memory/ptr_util.h"
|
| +#include "components/exo/notification_surface.h"
|
| +#include "ui/arc/notification/arc_notification_surface_impl.h"
|
| +
|
| +namespace arc {
|
| +
|
| +ArcNotificationSurfaceManagerImpl::ArcNotificationSurfaceManagerImpl() {}
|
| +
|
| +ArcNotificationSurfaceManagerImpl::~ArcNotificationSurfaceManagerImpl() {}
|
| +
|
| +ArcNotificationSurface* ArcNotificationSurfaceManagerImpl::GetArcSurface(
|
| + const std::string& notification_key) const {
|
| + auto it = notification_surface_map_.find(notification_key);
|
| + return it == notification_surface_map_.end() ? nullptr : it->second.get();
|
| +}
|
| +
|
| +void ArcNotificationSurfaceManagerImpl::AddObserver(Observer* observer) {
|
| + observers_.AddObserver(observer);
|
| +}
|
| +
|
| +void ArcNotificationSurfaceManagerImpl::RemoveObserver(Observer* observer) {
|
| + observers_.RemoveObserver(observer);
|
| +}
|
| +
|
| +exo::NotificationSurface* ArcNotificationSurfaceManagerImpl::GetSurface(
|
| + const std::string& notification_key) const {
|
| + auto it = notification_surface_map_.find(notification_key);
|
| + return it == notification_surface_map_.end() ? nullptr
|
| + : it->second->surface();
|
| +}
|
| +
|
| +void ArcNotificationSurfaceManagerImpl::AddSurface(
|
| + exo::NotificationSurface* surface) {
|
| + if (notification_surface_map_.find(surface->notification_id()) !=
|
| + notification_surface_map_.end()) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| +
|
| + notification_surface_map_[surface->notification_id()] =
|
| + base::MakeUnique<ArcNotificationSurfaceImpl>(surface);
|
| +
|
| + for (auto& observer : observers_) {
|
| + observer.OnNotificationSurfaceAdded(
|
| + notification_surface_map_[surface->notification_id()].get());
|
| + }
|
| +}
|
| +
|
| +void ArcNotificationSurfaceManagerImpl::RemoveSurface(
|
| + exo::NotificationSurface* surface) {
|
| + auto it = notification_surface_map_.find(surface->notification_id());
|
| + if (it == notification_surface_map_.end())
|
| + return;
|
| +
|
| + auto arc_surface = std::move(it->second);
|
| + notification_surface_map_.erase(it);
|
| + for (auto& observer : observers_)
|
| + observer.OnNotificationSurfaceRemoved(arc_surface.get());
|
| +}
|
| +
|
| +} // namespace arc
|
|
|