OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | 5 #ifndef MASH_WM_WINDOW_MANAGER_APPLICATION_H_ |
6 #define MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | 6 #define MASH_WM_WINDOW_MANAGER_APPLICATION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/observer_list.h" |
14 #include "components/mus/common/types.h" | 15 #include "components/mus/common/types.h" |
15 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" | 16 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" |
16 #include "components/mus/public/interfaces/window_manager.mojom.h" | 17 #include "components/mus/public/interfaces/window_manager.mojom.h" |
17 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" | 18 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" |
18 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 19 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
19 #include "mash/wm/public/interfaces/user_window_controller.mojom.h" | 20 #include "mash/wm/public/interfaces/user_window_controller.mojom.h" |
20 #include "mojo/common/weak_binding_set.h" | 21 #include "mojo/common/weak_binding_set.h" |
21 #include "mojo/public/cpp/bindings/binding.h" | 22 #include "mojo/public/cpp/bindings/binding.h" |
22 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 23 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
23 #include "mojo/shell/public/cpp/application_delegate.h" | 24 #include "mojo/shell/public/cpp/application_delegate.h" |
24 #include "mojo/shell/public/cpp/interface_factory_impl.h" | 25 #include "mojo/shell/public/cpp/interface_factory_impl.h" |
25 | 26 |
26 namespace ui { | 27 namespace ui { |
27 namespace mojo { | 28 namespace mojo { |
28 class UIInit; | 29 class UIInit; |
29 } | 30 } |
30 } | 31 } |
31 | 32 |
32 namespace views { | 33 namespace views { |
33 class AuraInit; | 34 class AuraInit; |
34 } | 35 } |
35 | 36 |
36 namespace mash { | 37 namespace mash { |
37 namespace wm { | 38 namespace wm { |
38 | 39 |
39 class AcceleratorRegistrarImpl; | 40 class AcceleratorRegistrarImpl; |
40 class RootWindowController; | 41 class RootWindowController; |
| 42 class RootWindowsObserver; |
41 class UserWindowControllerImpl; | 43 class UserWindowControllerImpl; |
42 | 44 |
43 class WindowManagerApplication | 45 class WindowManagerApplication |
44 : public mojo::ApplicationDelegate, | 46 : public mojo::ApplicationDelegate, |
45 public mus::mojom::WindowManagerFactory, | 47 public mus::mojom::WindowManagerFactory, |
46 public mojo::InterfaceFactory<mash::wm::mojom::UserWindowController>, | 48 public mojo::InterfaceFactory<mash::wm::mojom::UserWindowController>, |
47 public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { | 49 public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { |
48 public: | 50 public: |
49 WindowManagerApplication(); | 51 WindowManagerApplication(); |
50 ~WindowManagerApplication() override; | 52 ~WindowManagerApplication() override; |
51 | 53 |
52 mojo::ApplicationImpl* app() { return app_; } | 54 mojo::ApplicationImpl* app() { return app_; } |
53 | 55 |
| 56 // Returns the RootWindowControllers that have valid roots. |
| 57 // |
| 58 // NOTE: this does not return |controllers_| as most clients want a |
| 59 // RootWindowController that has a valid root window. |
| 60 std::set<RootWindowController*> GetRootControllers(); |
| 61 |
54 // Called when the root window of |root_controller| is obtained. | 62 // Called when the root window of |root_controller| is obtained. |
55 void OnRootWindowControllerGotRoot(RootWindowController* root_controller); | 63 void OnRootWindowControllerGotRoot(RootWindowController* root_controller); |
56 | 64 |
57 // Called after RootWindowController creates the necessary resources. | 65 // Called after RootWindowController creates the necessary resources. |
58 void OnRootWindowControllerDoneInit(RootWindowController* root_controller); | 66 void OnRootWindowControllerDoneInit(RootWindowController* root_controller); |
59 | 67 |
60 // Called when the root mus::Window of RootWindowController is destroyed. | 68 // Called when the root mus::Window of RootWindowController is destroyed. |
61 // |root_controller| is destroyed after this call. | 69 // |root_controller| is destroyed after this call. |
62 void OnRootWindowDestroyed(RootWindowController* root_controller); | 70 void OnRootWindowDestroyed(RootWindowController* root_controller); |
63 | 71 |
64 // TODO(sky): figure out right place for this code. | 72 // TODO(sky): figure out right place for this code. |
65 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event); | 73 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event); |
66 | 74 |
| 75 void AddRootWindowsObserver(RootWindowsObserver* observer); |
| 76 void RemoveRootWindowsObserver(RootWindowsObserver* observer); |
| 77 |
67 private: | 78 private: |
68 void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar); | 79 void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar); |
69 | 80 |
70 // ApplicationDelegate: | 81 // ApplicationDelegate: |
71 void Initialize(mojo::ApplicationImpl* app) override; | 82 void Initialize(mojo::ApplicationImpl* app) override; |
72 bool ConfigureIncomingConnection( | 83 bool ConfigureIncomingConnection( |
73 mojo::ApplicationConnection* connection) override; | 84 mojo::ApplicationConnection* connection) override; |
74 | 85 |
75 // InterfaceFactory<mash::wm::mojom::UserWindowController>: | 86 // InterfaceFactory<mash::wm::mojom::UserWindowController>: |
76 void Create(mojo::ApplicationConnection* connection, | 87 void Create(mojo::ApplicationConnection* connection, |
(...skipping 25 matching lines...) Expand all Loading... |
102 std::vector< | 113 std::vector< |
103 scoped_ptr<mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>>> | 114 scoped_ptr<mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>>> |
104 user_window_controller_requests_; | 115 user_window_controller_requests_; |
105 | 116 |
106 std::set<AcceleratorRegistrarImpl*> accelerator_registrars_; | 117 std::set<AcceleratorRegistrarImpl*> accelerator_registrars_; |
107 std::set<RootWindowController*> root_controllers_; | 118 std::set<RootWindowController*> root_controllers_; |
108 | 119 |
109 mojo::Binding<mus::mojom::WindowManagerFactory> | 120 mojo::Binding<mus::mojom::WindowManagerFactory> |
110 window_manager_factory_binding_; | 121 window_manager_factory_binding_; |
111 | 122 |
| 123 base::ObserverList<RootWindowsObserver> root_windows_observers_; |
| 124 |
112 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); | 125 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); |
113 }; | 126 }; |
114 | 127 |
115 } // namespace wm | 128 } // namespace wm |
116 } // namespace mash | 129 } // namespace mash |
117 | 130 |
118 #endif // MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | 131 #endif // MASH_WM_WINDOW_MANAGER_APPLICATION_H_ |
OLD | NEW |