| 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_WINDOW_TREE_FACTORY_SET_H_ | |
| 6 #define COMPONENTS_MUS_WS_WINDOW_MANAGER_WINDOW_TREE_FACTORY_SET_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_window_tree_factory.mo
jom.h" | |
| 16 #include "components/mus/ws/user_id_tracker_observer.h" | |
| 17 | |
| 18 namespace mus { | |
| 19 namespace ws { | |
| 20 | |
| 21 class UserIdTracker; | |
| 22 class WindowManagerState; | |
| 23 class WindowManagerWindowTreeFactory; | |
| 24 class WindowManagerWindowTreeFactorySetObserver; | |
| 25 class WindowServer; | |
| 26 class WindowTree; | |
| 27 | |
| 28 namespace test { | |
| 29 class WindowManagerWindowTreeFactorySetTestApi; | |
| 30 } | |
| 31 | |
| 32 // WindowManagerWindowTreeFactorySet tracks the set of registered | |
| 33 // WindowManagerWindowTreeHostFactories. | |
| 34 class WindowManagerWindowTreeFactorySet : public UserIdTrackerObserver { | |
| 35 public: | |
| 36 WindowManagerWindowTreeFactorySet(WindowServer* window_server, | |
| 37 UserIdTracker* tracker); | |
| 38 ~WindowManagerWindowTreeFactorySet() override; | |
| 39 | |
| 40 WindowServer* window_server() { return window_server_; } | |
| 41 | |
| 42 // Creates a new WindowManagerWindowTreeFactory for the specified user, | |
| 43 // unless one has been set, in which case the call is ignored. The newly | |
| 44 // created WindowManagerWindowTreeFactory does not immediately have a | |
| 45 // WindowTree associated with it. | |
| 46 WindowManagerWindowTreeFactory* Add( | |
| 47 const UserId& user_id, | |
| 48 mojo::InterfaceRequest<mojom::WindowManagerWindowTreeFactory> request); | |
| 49 | |
| 50 // Returns the WindowManagerState for the specified user, or null if | |
| 51 // not yet set. | |
| 52 WindowManagerState* GetWindowManagerStateForUser(const UserId& user_id); | |
| 53 | |
| 54 // Deletes the WindowManagerWindowTreeFactory associated with |tree|. Does | |
| 55 // nothing if there is no WindowManagerWindowTreeFactory associated with | |
| 56 // |tree|. | |
| 57 void DeleteFactoryAssociatedWithTree(WindowTree* tree); | |
| 58 | |
| 59 // Returns all the factories, even those that may not have a WindowTree | |
| 60 // associated with them. | |
| 61 std::vector<WindowManagerWindowTreeFactory*> GetFactories(); | |
| 62 | |
| 63 void AddObserver(WindowManagerWindowTreeFactorySetObserver* observer); | |
| 64 void RemoveObserver(WindowManagerWindowTreeFactorySetObserver* observer); | |
| 65 | |
| 66 private: | |
| 67 friend class WindowManagerWindowTreeFactory; | |
| 68 friend class test::WindowManagerWindowTreeFactorySetTestApi; | |
| 69 | |
| 70 // Called by WindowManagerWindowTreeFactory when CreateWindowTree() has | |
| 71 // been called. | |
| 72 void OnWindowManagerWindowTreeFactoryReady( | |
| 73 WindowManagerWindowTreeFactory* factory); | |
| 74 | |
| 75 // UserIdTrackerObserver: | |
| 76 void OnUserIdRemoved(const UserId& id) override; | |
| 77 | |
| 78 // Set to true the first time a valid factory has been found. | |
| 79 bool got_valid_factory_ = false; | |
| 80 UserIdTracker* id_tracker_; | |
| 81 WindowServer* window_server_; | |
| 82 | |
| 83 std::map<UserId, std::unique_ptr<WindowManagerWindowTreeFactory>> factories_; | |
| 84 | |
| 85 base::ObserverList<WindowManagerWindowTreeFactorySetObserver> observers_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(WindowManagerWindowTreeFactorySet); | |
| 88 }; | |
| 89 | |
| 90 } // namespace ws | |
| 91 } // namespace mus | |
| 92 | |
| 93 #endif // COMPONENTS_MUS_WS_WINDOW_MANAGER_WINDOW_TREE_FACTORY_SET_H_ | |
| OLD | NEW |