| 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 #include "mash/wm/window_manager_application.h" | 5 #include "mash/wm/window_manager_application.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "components/mus/public/cpp/event_matcher.h" | 10 #include "components/mus/public/cpp/event_matcher.h" |
| 11 #include "components/mus/public/cpp/window.h" | 11 #include "components/mus/public/cpp/window.h" |
| 12 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" | 12 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" |
| 13 #include "mash/wm/accelerator_registrar_impl.h" | 13 #include "mash/wm/accelerator_registrar_impl.h" |
| 14 #include "mash/wm/root_window_controller.h" | 14 #include "mash/wm/root_window_controller.h" |
| 15 #include "mash/wm/root_windows_observer.h" | 15 #include "mash/wm/root_windows_observer.h" |
| 16 #include "mash/wm/user_window_controller_impl.h" | 16 #include "mash/wm/user_window_controller_impl.h" |
| 17 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 17 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
| 18 #include "mojo/shell/public/cpp/application_connection.h" | 18 #include "mojo/shell/public/cpp/application_connection.h" |
| 19 #include "mojo/shell/public/cpp/application_impl.h" | 19 #include "mojo/shell/public/cpp/shell.h" |
| 20 #include "ui/mojo/init/ui_init.h" | 20 #include "ui/mojo/init/ui_init.h" |
| 21 #include "ui/views/mus/aura_init.h" | 21 #include "ui/views/mus/aura_init.h" |
| 22 #include "ui/views/mus/display_converter.h" | 22 #include "ui/views/mus/display_converter.h" |
| 23 | 23 |
| 24 namespace mash { | 24 namespace mash { |
| 25 namespace wm { | 25 namespace wm { |
| 26 | 26 |
| 27 WindowManagerApplication::WindowManagerApplication() | 27 WindowManagerApplication::WindowManagerApplication() |
| 28 : app_(nullptr), window_manager_factory_binding_(this) {} | 28 : shell_(nullptr), window_manager_factory_binding_(this) {} |
| 29 | 29 |
| 30 WindowManagerApplication::~WindowManagerApplication() { | 30 WindowManagerApplication::~WindowManagerApplication() { |
| 31 // AcceleratorRegistrarImpl removes an observer in its destructor. Destroy | 31 // AcceleratorRegistrarImpl removes an observer in its destructor. Destroy |
| 32 // it early on. | 32 // it early on. |
| 33 std::set<AcceleratorRegistrarImpl*> accelerator_registrars( | 33 std::set<AcceleratorRegistrarImpl*> accelerator_registrars( |
| 34 accelerator_registrars_); | 34 accelerator_registrars_); |
| 35 for (AcceleratorRegistrarImpl* registrar : accelerator_registrars) | 35 for (AcceleratorRegistrarImpl* registrar : accelerator_registrars) |
| 36 registrar->Destroy(); | 36 registrar->Destroy(); |
| 37 | 37 |
| 38 std::set<RootWindowController*> controllers(root_controllers_); | 38 std::set<RootWindowController*> controllers(root_controllers_); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 49 return root_controllers; | 49 return root_controllers; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void WindowManagerApplication::OnRootWindowControllerGotRoot( | 52 void WindowManagerApplication::OnRootWindowControllerGotRoot( |
| 53 RootWindowController* root_controller) { | 53 RootWindowController* root_controller) { |
| 54 if (ui_init_.get()) | 54 if (ui_init_.get()) |
| 55 return; | 55 return; |
| 56 | 56 |
| 57 ui_init_.reset(new ui::mojo::UIInit( | 57 ui_init_.reset(new ui::mojo::UIInit( |
| 58 views::GetDisplaysFromWindow(root_controller->root()))); | 58 views::GetDisplaysFromWindow(root_controller->root()))); |
| 59 aura_init_.reset(new views::AuraInit(app_, "mash_wm_resources.pak")); | 59 aura_init_.reset(new views::AuraInit(shell_, "mash_wm_resources.pak")); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void WindowManagerApplication::OnRootWindowControllerDoneInit( | 62 void WindowManagerApplication::OnRootWindowControllerDoneInit( |
| 63 RootWindowController* root_controller) { | 63 RootWindowController* root_controller) { |
| 64 // TODO(msw): figure out if this should be per display, or global. | 64 // TODO(msw): figure out if this should be per display, or global. |
| 65 user_window_controller_->Initialize(root_controller); | 65 user_window_controller_->Initialize(root_controller); |
| 66 for (auto& request : user_window_controller_requests_) | 66 for (auto& request : user_window_controller_requests_) |
| 67 user_window_controller_binding_.AddBinding(user_window_controller_.get(), | 67 user_window_controller_binding_.AddBinding(user_window_controller_.get(), |
| 68 std::move(*request)); | 68 std::move(*request)); |
| 69 user_window_controller_requests_.clear(); | 69 user_window_controller_requests_.clear(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 96 void WindowManagerApplication::RemoveRootWindowsObserver( | 96 void WindowManagerApplication::RemoveRootWindowsObserver( |
| 97 RootWindowsObserver* observer) { | 97 RootWindowsObserver* observer) { |
| 98 root_windows_observers_.RemoveObserver(observer); | 98 root_windows_observers_.RemoveObserver(observer); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( | 101 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( |
| 102 AcceleratorRegistrarImpl* registrar) { | 102 AcceleratorRegistrarImpl* registrar) { |
| 103 accelerator_registrars_.erase(registrar); | 103 accelerator_registrars_.erase(registrar); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) { | 106 void WindowManagerApplication::Initialize(mojo::Shell* shell, |
| 107 app_ = app; | 107 const std::string& url, |
| 108 tracing_.Initialize(app); | 108 uint32_t id) { |
| 109 shell_ = shell; |
| 110 tracing_.Initialize(shell, url); |
| 109 | 111 |
| 110 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; | 112 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; |
| 111 app_->ConnectToService("mojo:mus", &wm_factory_service); | 113 shell_->ConnectToService("mojo:mus", &wm_factory_service); |
| 112 wm_factory_service->SetWindowManagerFactory( | 114 wm_factory_service->SetWindowManagerFactory( |
| 113 window_manager_factory_binding_.CreateInterfacePtrAndBind()); | 115 window_manager_factory_binding_.CreateInterfacePtrAndBind()); |
| 114 | 116 |
| 115 user_window_controller_.reset(new UserWindowControllerImpl()); | 117 user_window_controller_.reset(new UserWindowControllerImpl()); |
| 116 | 118 |
| 117 root_controllers_.insert( | 119 root_controllers_.insert( |
| 118 RootWindowController::CreateUsingWindowTreeHost(this)); | 120 RootWindowController::CreateUsingWindowTreeHost(this)); |
| 119 } | 121 } |
| 120 | 122 |
| 121 bool WindowManagerApplication::AcceptConnection( | 123 bool WindowManagerApplication::AcceptConnection( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 160 |
| 159 void WindowManagerApplication::CreateWindowManager( | 161 void WindowManagerApplication::CreateWindowManager( |
| 160 mus::mojom::DisplayPtr display, | 162 mus::mojom::DisplayPtr display, |
| 161 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { | 163 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { |
| 162 root_controllers_.insert(RootWindowController::CreateFromDisplay( | 164 root_controllers_.insert(RootWindowController::CreateFromDisplay( |
| 163 this, std::move(display), std::move(client_request))); | 165 this, std::move(display), std::move(client_request))); |
| 164 } | 166 } |
| 165 | 167 |
| 166 } // namespace wm | 168 } // namespace wm |
| 167 } // namespace mash | 169 } // namespace mash |
| OLD | NEW |