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 COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ | 5 #ifndef COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ |
6 #define COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ | 6 #define COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "components/mus/example/wm/public/interfaces/container.mojom.h" | 11 #include "components/mus/example/wm/public/interfaces/container.mojom.h" |
12 #include "components/mus/public/cpp/types.h" | 12 #include "components/mus/public/cpp/types.h" |
13 #include "components/mus/public/cpp/window_observer.h" | 13 #include "components/mus/public/cpp/window_observer.h" |
14 #include "components/mus/public/cpp/window_tree_delegate.h" | 14 #include "components/mus/public/cpp/window_tree_delegate.h" |
15 #include "components/mus/public/interfaces/window_manager.mojom.h" | 15 #include "components/mus/public/interfaces/window_manager.mojom.h" |
16 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 16 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
17 #include "mojo/application/public/cpp/application_delegate.h" | 17 #include "mojo/application/public/cpp/application_delegate.h" |
18 #include "mojo/application/public/cpp/interface_factory_impl.h" | 18 #include "mojo/application/public/cpp/interface_factory_impl.h" |
19 #include "mojo/common/weak_binding_set.h" | 19 #include "mojo/common/weak_binding_set.h" |
20 | 20 |
21 class BackgroundLayout; | 21 class BackgroundLayout; |
22 class ShelfLayout; | 22 class ShelfLayout; |
23 class WindowLayout; | 23 class WindowLayout; |
| 24 class WindowManagerImpl; |
24 | 25 |
25 class WindowManagerImpl; | 26 namespace ui { |
| 27 namespace mojo { |
| 28 class UIInit; |
| 29 } |
| 30 } |
| 31 |
| 32 namespace views { |
| 33 class AuraInit; |
| 34 } |
26 | 35 |
27 class WindowManagerApplication | 36 class WindowManagerApplication |
28 : public mojo::ApplicationDelegate, | 37 : public mojo::ApplicationDelegate, |
29 public mus::WindowObserver, | 38 public mus::WindowObserver, |
30 public mus::WindowTreeDelegate, | 39 public mus::WindowTreeDelegate, |
31 public mojo::InterfaceFactory<mus::mojom::WindowManager> { | 40 public mojo::InterfaceFactory<mus::mojom::WindowManager> { |
32 public: | 41 public: |
33 WindowManagerApplication(); | 42 WindowManagerApplication(); |
34 ~WindowManagerApplication() override; | 43 ~WindowManagerApplication() override; |
35 | 44 |
36 mus::Window* root() { return root_; } | 45 mus::Window* root() { return root_; } |
37 | 46 |
38 int window_count() { return window_count_; } | 47 int window_count() { return window_count_; } |
39 void IncrementWindowCount() { ++window_count_; } | 48 void IncrementWindowCount() { ++window_count_; } |
40 | 49 |
41 mus::Window* GetWindowForContainer(ash::mojom::Container container); | 50 mus::Window* GetWindowForContainer(ash::mojom::Container container); |
42 mus::Window* GetWindowById(mus::Id id); | 51 mus::Window* GetWindowById(mus::Id id); |
43 | 52 |
| 53 mojo::ApplicationImpl* app() { return app_; } |
| 54 |
44 private: | 55 private: |
45 // ApplicationDelegate: | 56 // ApplicationDelegate: |
46 void Initialize(mojo::ApplicationImpl* app) override; | 57 void Initialize(mojo::ApplicationImpl* app) override; |
47 bool ConfigureIncomingConnection( | 58 bool ConfigureIncomingConnection( |
48 mojo::ApplicationConnection* connection) override; | 59 mojo::ApplicationConnection* connection) override; |
49 | 60 |
50 // WindowTreeDelegate: | 61 // WindowTreeDelegate: |
51 void OnEmbed(mus::Window* root) override; | 62 void OnEmbed(mus::Window* root) override; |
52 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 63 void OnConnectionLost(mus::WindowTreeConnection* connection) override; |
53 | 64 |
54 // InterfaceFactory<mus::mojom::WindowManager>: | 65 // InterfaceFactory<mus::mojom::WindowManager>: |
55 void Create( | 66 void Create( |
56 mojo::ApplicationConnection* connection, | 67 mojo::ApplicationConnection* connection, |
57 mojo::InterfaceRequest<mus::mojom::WindowManager> request) override; | 68 mojo::InterfaceRequest<mus::mojom::WindowManager> request) override; |
58 | 69 |
59 // mus::WindowObserver: | 70 // mus::WindowObserver: |
60 void OnWindowDestroyed(mus::Window* window) override; | 71 void OnWindowDestroyed(mus::Window* window) override; |
61 | 72 |
62 // Sets up the window containers used for z-space management. | 73 // Sets up the window containers used for z-space management. |
63 void CreateContainers(); | 74 void CreateContainers(); |
64 | 75 |
65 // nullptr until the Mus connection is established via OnEmbed(). | 76 // nullptr until the Mus connection is established via OnEmbed(). |
66 mus::Window* root_; | 77 mus::Window* root_; |
67 int window_count_; | 78 int window_count_; |
68 | 79 |
| 80 mojo::ApplicationImpl* app_; |
| 81 |
69 mus::mojom::WindowTreeHostPtr host_; | 82 mus::mojom::WindowTreeHostPtr host_; |
70 | 83 |
| 84 scoped_ptr<ui::mojo::UIInit> ui_init_; |
| 85 scoped_ptr<views::AuraInit> aura_init_; |
| 86 |
71 // |window_manager_| is created once OnEmbed() is called. Until that time | 87 // |window_manager_| is created once OnEmbed() is called. Until that time |
72 // |requests_| stores any pending WindowManager interface requests. | 88 // |requests_| stores any pending WindowManager interface requests. |
73 scoped_ptr<WindowManagerImpl> window_manager_; | 89 scoped_ptr<WindowManagerImpl> window_manager_; |
74 mojo::WeakBindingSet<mus::mojom::WindowManager> window_manager_binding_; | 90 mojo::WeakBindingSet<mus::mojom::WindowManager> window_manager_binding_; |
75 ScopedVector<mojo::InterfaceRequest<mus::mojom::WindowManager>> requests_; | 91 ScopedVector<mojo::InterfaceRequest<mus::mojom::WindowManager>> requests_; |
76 | 92 |
77 scoped_ptr<BackgroundLayout> background_layout_; | 93 scoped_ptr<BackgroundLayout> background_layout_; |
78 scoped_ptr<ShelfLayout> shelf_layout_; | 94 scoped_ptr<ShelfLayout> shelf_layout_; |
79 scoped_ptr<WindowLayout> window_layout_; | 95 scoped_ptr<WindowLayout> window_layout_; |
80 | 96 |
81 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); | 97 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); |
82 }; | 98 }; |
83 | 99 |
84 #endif // COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ | 100 #endif // COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ |
OLD | NEW |