| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_SURFACE_MANAGER_ | 5 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_SURFACE_MANAGER_H_ |
| 6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_SURFACE_MANAGER_ | 6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_SURFACE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "components/exo/notification_surface_manager.h" | 13 #include "components/exo/notification_surface_manager.h" |
| 14 | 14 |
| 15 namespace arc { | 15 namespace arc { |
| 16 | 16 |
| 17 class ArcNotificationSurface; |
| 18 |
| 17 // Keeps track of NotificationSurface. | 19 // Keeps track of NotificationSurface. |
| 18 class ArcNotificationSurfaceManager : public exo::NotificationSurfaceManager { | 20 class ArcNotificationSurfaceManager { |
| 19 public: | 21 public: |
| 20 class Observer { | 22 class Observer { |
| 21 public: | 23 public: |
| 22 // Invoked when a notification surface is added to the registry. | 24 // Invoked when a notification surface is added to the registry. |
| 23 virtual void OnNotificationSurfaceAdded( | 25 virtual void OnNotificationSurfaceAdded( |
| 24 exo::NotificationSurface* surface) = 0; | 26 ArcNotificationSurface* surface) = 0; |
| 25 | 27 |
| 26 // Invoked when a notification surface is removed from the registry. | 28 // Invoked when a notification surface is removed from the registry. |
| 27 virtual void OnNotificationSurfaceRemoved( | 29 virtual void OnNotificationSurfaceRemoved( |
| 28 exo::NotificationSurface* surface) = 0; | 30 ArcNotificationSurface* surface) = 0; |
| 29 | 31 |
| 30 protected: | 32 protected: |
| 31 virtual ~Observer() = default; | 33 virtual ~Observer() = default; |
| 32 }; | 34 }; |
| 33 | 35 |
| 34 ArcNotificationSurfaceManager(); | 36 ArcNotificationSurfaceManager(); |
| 35 ~ArcNotificationSurfaceManager() override; | 37 ~ArcNotificationSurfaceManager(); |
| 36 | 38 |
| 37 static ArcNotificationSurfaceManager* Get(); | 39 static ArcNotificationSurfaceManager* Get(); |
| 38 | 40 |
| 39 // exo::NotificationSurfaceManager: | 41 virtual ArcNotificationSurface* GetArcSurface( |
| 40 exo::NotificationSurface* GetSurface( | 42 const std::string& notification_id) const = 0; |
| 41 const std::string& notification_id) const override; | |
| 42 void AddSurface(exo::NotificationSurface* surface) override; | |
| 43 void RemoveSurface(exo::NotificationSurface* surface) override; | |
| 44 | 43 |
| 45 void AddObserver(Observer* observer); | 44 virtual void AddObserver(Observer* observer) = 0; |
| 46 void RemoveObserver(Observer* observer); | 45 virtual void RemoveObserver(Observer* observer) = 0; |
| 47 | 46 |
| 48 private: | 47 private: |
| 49 using NotificationSurfaceMap = | 48 static ArcNotificationSurfaceManager* instance_; |
| 50 std::map<std::string, exo::NotificationSurface*>; | |
| 51 NotificationSurfaceMap notification_surface_map_; | |
| 52 | |
| 53 base::ObserverList<Observer> observers_; | |
| 54 | 49 |
| 55 DISALLOW_COPY_AND_ASSIGN(ArcNotificationSurfaceManager); | 50 DISALLOW_COPY_AND_ASSIGN(ArcNotificationSurfaceManager); |
| 56 }; | 51 }; |
| 57 | 52 |
| 58 } // namespace arc | 53 } // namespace arc |
| 59 | 54 |
| 60 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_SURFACE_MANAGER_ | 55 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_SURFACE_MANAGER_H_ |
| OLD | NEW |