| OLD | NEW |
| (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 #ifndef COMPONENTS_MUS_WS_WINDOW_MANAGER_FACTORY_REGISTRY_H_ | |
| 6 #define COMPONENTS_MUS_WS_WINDOW_MANAGER_FACTORY_REGISTRY_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/macros.h" | |
| 14 #include "base/observer_list.h" | |
| 15 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" | |
| 16 #include "components/mus/ws/user_id_tracker_observer.h" | |
| 17 | |
| 18 namespace mus { | |
| 19 namespace ws { | |
| 20 | |
| 21 class UserIdTracker; | |
| 22 class WindowManagerFactoryRegistryObserver; | |
| 23 class WindowManagerFactoryService; | |
| 24 class WindowServer; | |
| 25 | |
| 26 namespace test { | |
| 27 class WindowManagerFactoryRegistryTestApi; | |
| 28 } | |
| 29 | |
| 30 // WindowManagerFactoryRegistry tracks the set of registered | |
| 31 // WindowManagerFactoryServices. | |
| 32 class WindowManagerFactoryRegistry : public UserIdTrackerObserver { | |
| 33 public: | |
| 34 WindowManagerFactoryRegistry(WindowServer* window_server, | |
| 35 UserIdTracker* tracker); | |
| 36 ~WindowManagerFactoryRegistry() override; | |
| 37 | |
| 38 void Register( | |
| 39 const UserId& user_id, | |
| 40 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request); | |
| 41 | |
| 42 std::vector<WindowManagerFactoryService*> GetServices(); | |
| 43 | |
| 44 void AddObserver(WindowManagerFactoryRegistryObserver* observer); | |
| 45 void RemoveObserver(WindowManagerFactoryRegistryObserver* observer); | |
| 46 | |
| 47 private: | |
| 48 friend class WindowManagerFactoryService; | |
| 49 friend class test::WindowManagerFactoryRegistryTestApi; | |
| 50 | |
| 51 void AddServiceImpl(std::unique_ptr<WindowManagerFactoryService> service); | |
| 52 | |
| 53 bool ContainsServiceForUser(const UserId& user_id) const; | |
| 54 void OnWindowManagerFactoryConnectionLost( | |
| 55 WindowManagerFactoryService* service); | |
| 56 void OnWindowManagerFactorySet(WindowManagerFactoryService* service); | |
| 57 | |
| 58 // UserIdTrackerObserver: | |
| 59 void OnActiveUserIdChanged(const UserId& previously_active_id, | |
| 60 const UserId& active_id) override; | |
| 61 void OnUserIdAdded(const UserId& id) override; | |
| 62 void OnUserIdRemoved(const UserId& id) override; | |
| 63 | |
| 64 // Set to true the first time a valid factory has been found. | |
| 65 bool got_valid_factory_ = false; | |
| 66 UserIdTracker* id_tracker_; | |
| 67 WindowServer* window_server_; | |
| 68 | |
| 69 std::vector<std::unique_ptr<WindowManagerFactoryService>> services_; | |
| 70 | |
| 71 base::ObserverList<WindowManagerFactoryRegistryObserver> observers_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(WindowManagerFactoryRegistry); | |
| 74 }; | |
| 75 | |
| 76 } // namespace ws | |
| 77 } // namespace mus | |
| 78 | |
| 79 #endif // COMPONENTS_MUS_WS_WINDOW_MANAGER_FACTORY_REGISTRY_H_ | |
| OLD | NEW |