Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: components/mus/ws/window_manager_window_tree_factory_set.h

Issue 2072343002: Changes how window manager obtains WindowTree from mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 WindowManagerWindowTreeFactory;
23 class WindowManagerWindowTreeFactorySetObserver;
24 class WindowServer;
25 class WindowTree;
26
27 namespace test {
28 class WindowManagerWindowTreeFactorySetTestApi;
29 }
30
31 // WindowManagerWindowTreeFactorySet tracks the set of registered
32 // WindowManagerWindowTreeHostFactories.
33 class WindowManagerWindowTreeFactorySet : public UserIdTrackerObserver {
34 public:
35 WindowManagerWindowTreeFactorySet(WindowServer* window_server,
36 UserIdTracker* tracker);
37 ~WindowManagerWindowTreeFactorySet() override;
38
39 WindowServer* window_server() { return window_server_; }
40
41 // Creates a new WindowManagerWindowTreeFactory for the specified user,
42 // unless one has been set, in which case the call is ignored. The newly
43 // created WindowManagerWindowTreeFactory does not immediately have a
44 // WindowTree associated with it.
45 WindowManagerWindowTreeFactory* Add(
46 const UserId& user_id,
47 mojo::InterfaceRequest<mojom::WindowManagerWindowTreeFactory> request);
48
49 // Deletes the WindowManagerWindowTreeFactory associated with |tree|. Does
50 // nothing if there is no WindowManagerWindowTreeFactory associated with
51 // |tree|.
52 void DeleteFactoryAssociatedWithTree(WindowTree* tree);
53
54 // Returns all the factories, even those that may not have a WindowTree
55 // associated with them.
56 std::vector<WindowManagerWindowTreeFactory*> GetFactories();
57
58 void AddObserver(WindowManagerWindowTreeFactorySetObserver* observer);
59 void RemoveObserver(WindowManagerWindowTreeFactorySetObserver* observer);
60
61 private:
62 friend class WindowManagerWindowTreeFactory;
63 friend class test::WindowManagerWindowTreeFactorySetTestApi;
64
65 // Returns true if a factory has been created for the specified user.
66 bool ContainsFactoryForUser(const UserId& user_id) const;
67
68 // Called by WindowManagerWindowTreeFactory when CreateWindowTree() has
69 // been called.
70 void OnWindowManagerWindowTreeFactoryReady(
71 WindowManagerWindowTreeFactory* factory);
72
73 // UserIdTrackerObserver:
74 void OnActiveUserIdChanged(const UserId& previously_active_id,
75 const UserId& active_id) override;
76 void OnUserIdAdded(const UserId& id) override;
77 void OnUserIdRemoved(const UserId& id) override;
78
79 // Set to true the first time a valid factory has been found.
80 bool got_valid_factory_ = false;
81 UserIdTracker* id_tracker_;
82 WindowServer* window_server_;
83
84 std::vector<std::unique_ptr<WindowManagerWindowTreeFactory>> factories_;
85
86 base::ObserverList<WindowManagerWindowTreeFactorySetObserver> observers_;
87
88 DISALLOW_COPY_AND_ASSIGN(WindowManagerWindowTreeFactorySet);
89 };
90
91 } // namespace ws
92 } // namespace mus
93
94 #endif // COMPONENTS_MUS_WS_WINDOW_MANAGER_WINDOW_TREE_FACTORY_SET_H_
OLDNEW
« no previous file with comments | « components/mus/ws/window_manager_window_tree_factory.cc ('k') | components/mus/ws/window_manager_window_tree_factory_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698