| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | |
| 6 #define MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <set> | |
| 12 | |
| 13 #include "ash/public/interfaces/shelf_layout.mojom.h" | |
| 14 #include "ash/public/interfaces/user_window_controller.mojom.h" | |
| 15 #include "base/macros.h" | |
| 16 #include "base/observer_list.h" | |
| 17 #include "components/mus/common/types.h" | |
| 18 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" | |
| 19 #include "components/mus/public/interfaces/window_manager.mojom.h" | |
| 20 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" | |
| 21 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | |
| 22 #include "mash/session/public/interfaces/session.mojom.h" | |
| 23 #include "mojo/public/cpp/bindings/binding.h" | |
| 24 #include "mojo/public/cpp/bindings/binding_set.h" | |
| 25 #include "services/shell/public/cpp/shell_client.h" | |
| 26 #include "services/tracing/public/cpp/tracing_impl.h" | |
| 27 | |
| 28 namespace display { | |
| 29 class Screen; | |
| 30 } | |
| 31 | |
| 32 namespace views { | |
| 33 class AuraInit; | |
| 34 } | |
| 35 | |
| 36 namespace ui { | |
| 37 class Event; | |
| 38 } | |
| 39 | |
| 40 namespace mash { | |
| 41 namespace wm { | |
| 42 | |
| 43 class AcceleratorRegistrarImpl; | |
| 44 class RootWindowController; | |
| 45 class RootWindowsObserver; | |
| 46 class ShelfLayoutImpl; | |
| 47 class UserWindowControllerImpl; | |
| 48 class WmGlobalsMus; | |
| 49 class WmLookupMus; | |
| 50 class WmScreen; | |
| 51 | |
| 52 class WindowManagerApplication | |
| 53 : public shell::ShellClient, | |
| 54 public mus::mojom::WindowManagerFactory, | |
| 55 public shell::InterfaceFactory<ash::mojom::ShelfLayout>, | |
| 56 public shell::InterfaceFactory<ash::mojom::UserWindowController>, | |
| 57 public shell::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { | |
| 58 public: | |
| 59 WindowManagerApplication(); | |
| 60 ~WindowManagerApplication() override; | |
| 61 | |
| 62 shell::Connector* connector() { return connector_; } | |
| 63 | |
| 64 // Returns the RootWindowControllers that have valid roots. | |
| 65 // | |
| 66 // NOTE: this does not return |controllers_| as most clients want a | |
| 67 // RootWindowController that has a valid root window. | |
| 68 std::set<RootWindowController*> GetRootControllers(); | |
| 69 | |
| 70 WmGlobalsMus* globals() { return globals_.get(); } | |
| 71 | |
| 72 // Called when the root window of |root_controller| is obtained. | |
| 73 void OnRootWindowControllerGotRoot(RootWindowController* root_controller); | |
| 74 | |
| 75 // Called after RootWindowController creates the necessary resources. | |
| 76 void OnRootWindowControllerDoneInit(RootWindowController* root_controller); | |
| 77 | |
| 78 // Called when the root mus::Window of RootWindowController is destroyed. | |
| 79 // |root_controller| is destroyed after this call. | |
| 80 void OnRootWindowDestroyed(RootWindowController* root_controller); | |
| 81 | |
| 82 // TODO(sky): figure out right place for this code. | |
| 83 void OnAccelerator(uint32_t id, const ui::Event& event); | |
| 84 | |
| 85 void AddRootWindowsObserver(RootWindowsObserver* observer); | |
| 86 void RemoveRootWindowsObserver(RootWindowsObserver* observer); | |
| 87 | |
| 88 session::mojom::Session* session() { | |
| 89 return session_.get(); | |
| 90 } | |
| 91 | |
| 92 private: | |
| 93 friend class WmTestBase; | |
| 94 friend class WmTestHelper; | |
| 95 | |
| 96 void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar); | |
| 97 | |
| 98 // Adds |root_window_controller| to the set of known roots. | |
| 99 void AddRootWindowController(RootWindowController* root_window_controller); | |
| 100 | |
| 101 // shell::ShellClient: | |
| 102 void Initialize(shell::Connector* connector, | |
| 103 const shell::Identity& identity, | |
| 104 uint32_t id) override; | |
| 105 bool AcceptConnection(shell::Connection* connection) override; | |
| 106 | |
| 107 // shell::InterfaceFactory<ash::mojom::ShelfLayout>: | |
| 108 void Create(shell::Connection* connection, | |
| 109 mojo::InterfaceRequest<ash::mojom::ShelfLayout> request) override; | |
| 110 | |
| 111 // shell::InterfaceFactory<ash::mojom::UserWindowController>: | |
| 112 void Create(shell::Connection* connection, | |
| 113 mojo::InterfaceRequest<ash::mojom::UserWindowController> request) | |
| 114 override; | |
| 115 | |
| 116 // shell::InterfaceFactory<mus::mojom::AcceleratorRegistrar>: | |
| 117 void Create(shell::Connection* connection, | |
| 118 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) | |
| 119 override; | |
| 120 | |
| 121 // mus::mojom::WindowManagerFactory: | |
| 122 void CreateWindowManager(mus::mojom::DisplayPtr display, | |
| 123 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> | |
| 124 client_request) override; | |
| 125 | |
| 126 shell::Connector* connector_; | |
| 127 | |
| 128 mojo::TracingImpl tracing_; | |
| 129 | |
| 130 std::unique_ptr<display::Screen> screen_; | |
| 131 std::unique_ptr<views::AuraInit> aura_init_; | |
| 132 | |
| 133 std::unique_ptr<WmGlobalsMus> globals_; | |
| 134 std::unique_ptr<WmLookupMus> lookup_; | |
| 135 | |
| 136 // The |shelf_layout_| object is created once OnEmbed() is called. Until that | |
| 137 // time |shelf_layout_requests_| stores pending interface requests. | |
| 138 std::unique_ptr<ShelfLayoutImpl> shelf_layout_; | |
| 139 mojo::BindingSet<ash::mojom::ShelfLayout> shelf_layout_bindings_; | |
| 140 std::vector<std::unique_ptr<mojo::InterfaceRequest<ash::mojom::ShelfLayout>>> | |
| 141 shelf_layout_requests_; | |
| 142 | |
| 143 // |user_window_controller_| is created once OnEmbed() is called. Until that | |
| 144 // time |user_window_controller_requests_| stores pending interface requests. | |
| 145 std::unique_ptr<UserWindowControllerImpl> user_window_controller_; | |
| 146 mojo::BindingSet<ash::mojom::UserWindowController> | |
| 147 user_window_controller_bindings_; | |
| 148 std::vector< | |
| 149 std::unique_ptr<mojo::InterfaceRequest<ash::mojom::UserWindowController>>> | |
| 150 user_window_controller_requests_; | |
| 151 | |
| 152 std::set<AcceleratorRegistrarImpl*> accelerator_registrars_; | |
| 153 std::set<RootWindowController*> root_controllers_; | |
| 154 | |
| 155 mojo::Binding<mus::mojom::WindowManagerFactory> | |
| 156 window_manager_factory_binding_; | |
| 157 | |
| 158 mash::session::mojom::SessionPtr session_; | |
| 159 | |
| 160 base::ObserverList<RootWindowsObserver> root_windows_observers_; | |
| 161 | |
| 162 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); | |
| 163 }; | |
| 164 | |
| 165 } // namespace wm | |
| 166 } // namespace mash | |
| 167 | |
| 168 #endif // MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | |
| OLD | NEW |