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 "base/observer_list.h" |
15 #include "components/mus/common/types.h" | 15 #include "components/mus/common/types.h" |
16 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" | 16 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" |
17 #include "components/mus/public/interfaces/window_manager.mojom.h" | 17 #include "components/mus/public/interfaces/window_manager.mojom.h" |
18 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" | 18 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" |
19 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 19 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
20 #include "mash/wm/public/interfaces/user_window_controller.mojom.h" | 20 #include "mash/wm/public/interfaces/user_window_controller.mojom.h" |
21 #include "mojo/common/weak_binding_set.h" | 21 #include "mojo/common/weak_binding_set.h" |
22 #include "mojo/public/cpp/bindings/binding.h" | 22 #include "mojo/public/cpp/bindings/binding.h" |
23 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 23 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
24 #include "mojo/shell/public/cpp/application_delegate.h" | 24 #include "mojo/shell/public/cpp/application_delegate.h" |
25 #include "mojo/shell/public/cpp/interface_factory_impl.h" | |
26 | 25 |
27 namespace ui { | 26 namespace ui { |
28 namespace mojo { | 27 namespace mojo { |
29 class UIInit; | 28 class UIInit; |
30 } | 29 } |
31 } | 30 } |
32 | 31 |
33 namespace views { | 32 namespace views { |
34 class AuraInit; | 33 class AuraInit; |
35 } | 34 } |
36 | 35 |
37 namespace mash { | 36 namespace mash { |
38 namespace wm { | 37 namespace wm { |
39 | 38 |
40 class AcceleratorRegistrarImpl; | 39 class AcceleratorRegistrarImpl; |
41 class RootWindowController; | 40 class RootWindowController; |
42 class RootWindowsObserver; | 41 class RootWindowsObserver; |
43 class UserWindowControllerImpl; | 42 class UserWindowControllerImpl; |
44 | 43 |
45 class WindowManagerApplication | 44 class WindowManagerApplication |
46 : public mojo::ApplicationDelegate, | 45 : public mojo::ApplicationDelegate, |
47 public mus::mojom::WindowManagerFactory, | 46 public mus::mojom::WindowManagerFactory, |
48 public mojo::InterfaceFactory<mash::wm::mojom::UserWindowController>, | 47 public mojo::InterfaceFactory<mash::wm::mojom::UserWindowController>, |
49 public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { | 48 public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { |
50 public: | 49 public: |
51 WindowManagerApplication(); | 50 WindowManagerApplication(); |
52 ~WindowManagerApplication() override; | 51 ~WindowManagerApplication() override; |
53 | 52 |
54 mojo::ApplicationImpl* app() { return app_; } | 53 mojo::Shell* shell() { return shell_; } |
55 | 54 |
56 // Returns the RootWindowControllers that have valid roots. | 55 // Returns the RootWindowControllers that have valid roots. |
57 // | 56 // |
58 // NOTE: this does not return |controllers_| as most clients want a | 57 // NOTE: this does not return |controllers_| as most clients want a |
59 // RootWindowController that has a valid root window. | 58 // RootWindowController that has a valid root window. |
60 std::set<RootWindowController*> GetRootControllers(); | 59 std::set<RootWindowController*> GetRootControllers(); |
61 | 60 |
62 // Called when the root window of |root_controller| is obtained. | 61 // Called when the root window of |root_controller| is obtained. |
63 void OnRootWindowControllerGotRoot(RootWindowController* root_controller); | 62 void OnRootWindowControllerGotRoot(RootWindowController* root_controller); |
64 | 63 |
65 // Called after RootWindowController creates the necessary resources. | 64 // Called after RootWindowController creates the necessary resources. |
66 void OnRootWindowControllerDoneInit(RootWindowController* root_controller); | 65 void OnRootWindowControllerDoneInit(RootWindowController* root_controller); |
67 | 66 |
68 // Called when the root mus::Window of RootWindowController is destroyed. | 67 // Called when the root mus::Window of RootWindowController is destroyed. |
69 // |root_controller| is destroyed after this call. | 68 // |root_controller| is destroyed after this call. |
70 void OnRootWindowDestroyed(RootWindowController* root_controller); | 69 void OnRootWindowDestroyed(RootWindowController* root_controller); |
71 | 70 |
72 // TODO(sky): figure out right place for this code. | 71 // TODO(sky): figure out right place for this code. |
73 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event); | 72 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event); |
74 | 73 |
75 void AddRootWindowsObserver(RootWindowsObserver* observer); | 74 void AddRootWindowsObserver(RootWindowsObserver* observer); |
76 void RemoveRootWindowsObserver(RootWindowsObserver* observer); | 75 void RemoveRootWindowsObserver(RootWindowsObserver* observer); |
77 | 76 |
78 private: | 77 private: |
79 void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar); | 78 void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar); |
80 | 79 |
81 // ApplicationDelegate: | 80 // ApplicationDelegate: |
82 void Initialize(mojo::ApplicationImpl* app) override; | 81 void Initialize(mojo::Shell* shell, const std::string& url, |
| 82 uint32_t id) override; |
83 bool AcceptConnection( | 83 bool AcceptConnection( |
84 mojo::ApplicationConnection* connection) override; | 84 mojo::ApplicationConnection* connection) override; |
85 | 85 |
86 // InterfaceFactory<mash::wm::mojom::UserWindowController>: | 86 // InterfaceFactory<mash::wm::mojom::UserWindowController>: |
87 void Create(mojo::ApplicationConnection* connection, | 87 void Create(mojo::ApplicationConnection* connection, |
88 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> | 88 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> |
89 request) override; | 89 request) override; |
90 | 90 |
91 // InterfaceFactory<mus::mojom::AcceleratorRegistrar>: | 91 // InterfaceFactory<mus::mojom::AcceleratorRegistrar>: |
92 void Create(mojo::ApplicationConnection* connection, | 92 void Create(mojo::ApplicationConnection* connection, |
93 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) | 93 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) |
94 override; | 94 override; |
95 | 95 |
96 // mus::mojom::WindowManagerFactory: | 96 // mus::mojom::WindowManagerFactory: |
97 void CreateWindowManager(mus::mojom::DisplayPtr display, | 97 void CreateWindowManager(mus::mojom::DisplayPtr display, |
98 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> | 98 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> |
99 client_request) override; | 99 client_request) override; |
100 | 100 |
101 mojo::ApplicationImpl* app_; | 101 mojo::Shell* shell_; |
102 | 102 |
103 mojo::TracingImpl tracing_; | 103 mojo::TracingImpl tracing_; |
104 | 104 |
105 scoped_ptr<ui::mojo::UIInit> ui_init_; | 105 scoped_ptr<ui::mojo::UIInit> ui_init_; |
106 scoped_ptr<views::AuraInit> aura_init_; | 106 scoped_ptr<views::AuraInit> aura_init_; |
107 | 107 |
108 // |user_window_controller_| is created once OnEmbed() is called. Until that | 108 // |user_window_controller_| is created once OnEmbed() is called. Until that |
109 // time |user_window_controller_requests_| stores pending interface requests. | 109 // time |user_window_controller_requests_| stores pending interface requests. |
110 scoped_ptr<UserWindowControllerImpl> user_window_controller_; | 110 scoped_ptr<UserWindowControllerImpl> user_window_controller_; |
111 mojo::WeakBindingSet<mash::wm::mojom::UserWindowController> | 111 mojo::WeakBindingSet<mash::wm::mojom::UserWindowController> |
(...skipping 10 matching lines...) Expand all Loading... |
122 | 122 |
123 base::ObserverList<RootWindowsObserver> root_windows_observers_; | 123 base::ObserverList<RootWindowsObserver> root_windows_observers_; |
124 | 124 |
125 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); | 125 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); |
126 }; | 126 }; |
127 | 127 |
128 } // namespace wm | 128 } // namespace wm |
129 } // namespace mash | 129 } // namespace mash |
130 | 130 |
131 #endif // MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | 131 #endif // MASH_WM_WINDOW_MANAGER_APPLICATION_H_ |
OLD | NEW |