| Index: components/exo/notification_surface_registry.cc
|
| diff --git a/components/exo/notification_surface_registry.cc b/components/exo/notification_surface_registry.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b26bc22ed272d2050a69b0fbe475278e88898855
|
| --- /dev/null
|
| +++ b/components/exo/notification_surface_registry.cc
|
| @@ -0,0 +1,53 @@
|
| +// 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 "components/exo/notification_surface_registry.h"
|
| +
|
| +#include <algorithm>
|
| +
|
| +#include "components/exo/notification_surface.h"
|
| +
|
| +namespace exo {
|
| +
|
| +NotificationSurfaceRegistry::NotificationSurfaceRegistry() {}
|
| +
|
| +NotificationSurfaceRegistry::~NotificationSurfaceRegistry() {}
|
| +
|
| +NotificationSurface* NotificationSurfaceRegistry::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 NotificationSurfaceRegistry::AddSurface(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 NotificationSurfaceRegistry::RemoveSurface(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 NotificationSurfaceRegistry::AddObserver(Observer* observer) {
|
| + observers_.AddObserver(observer);
|
| +}
|
| +
|
| +void NotificationSurfaceRegistry::RemoveObserver(Observer* observer) {
|
| + observers_.RemoveObserver(observer);
|
| +}
|
| +
|
| +} // namespace exo
|
|
|