Chromium Code Reviews| 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 "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "components/mus/common/event_matcher_util.h" | 11 #include "components/mus/common/event_matcher_util.h" |
| 12 #include "components/mus/public/cpp/window.h" | 12 #include "components/mus/public/cpp/window.h" |
| 13 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" | 13 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" |
| 14 #include "mash/wm/accelerator_registrar_impl.h" | 14 #include "mash/wm/accelerator_registrar_impl.h" |
| 15 #include "mash/wm/bridge/wm_globals_mus.h" | |
| 16 #include "mash/wm/bridge/wm_lookup_mus.h" | |
| 15 #include "mash/wm/root_window_controller.h" | 17 #include "mash/wm/root_window_controller.h" |
| 16 #include "mash/wm/root_windows_observer.h" | 18 #include "mash/wm/root_windows_observer.h" |
| 17 #include "mash/wm/shelf_layout_impl.h" | 19 #include "mash/wm/shelf_layout_impl.h" |
| 18 #include "mash/wm/user_window_controller_impl.h" | 20 #include "mash/wm/user_window_controller_impl.h" |
| 19 #include "mojo/converters/input_events/input_events_type_converters.h" | 21 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 20 #include "services/shell/public/cpp/connection.h" | 22 #include "services/shell/public/cpp/connection.h" |
| 21 #include "services/shell/public/cpp/connector.h" | 23 #include "services/shell/public/cpp/connector.h" |
| 22 #include "services/tracing/public/cpp/tracing_impl.h" | 24 #include "services/tracing/public/cpp/tracing_impl.h" |
| 23 #include "ui/events/event.h" | 25 #include "ui/events/event.h" |
| 24 #include "ui/views/mus/aura_init.h" | 26 #include "ui/views/mus/aura_init.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 48 std::set<RootWindowController*> root_controllers; | 50 std::set<RootWindowController*> root_controllers; |
| 49 for (RootWindowController* controller : root_controllers_) { | 51 for (RootWindowController* controller : root_controllers_) { |
| 50 if (controller->root()) | 52 if (controller->root()) |
| 51 root_controllers.insert(controller); | 53 root_controllers.insert(controller); |
| 52 } | 54 } |
| 53 return root_controllers; | 55 return root_controllers; |
| 54 } | 56 } |
| 55 | 57 |
| 56 void WindowManagerApplication::OnRootWindowControllerGotRoot( | 58 void WindowManagerApplication::OnRootWindowControllerGotRoot( |
| 57 RootWindowController* root_controller) { | 59 RootWindowController* root_controller) { |
| 58 aura_init_.reset(new views::AuraInit(connector_, "mash_wm_resources.pak")); | 60 if (connector_) |
| 61 aura_init_.reset(new views::AuraInit(connector_, "mash_wm_resources.pak")); | |
| 62 | |
| 63 globals_.reset(new WmGlobalsMus(root_controller->root()->connection())); | |
| 64 lookup_.reset(new WmLookupMus); | |
| 59 } | 65 } |
| 60 | 66 |
| 61 void WindowManagerApplication::OnRootWindowControllerDoneInit( | 67 void WindowManagerApplication::OnRootWindowControllerDoneInit( |
| 62 RootWindowController* root_controller) { | 68 RootWindowController* root_controller) { |
| 63 screen_.reset(new views::ScreenMus(nullptr)); | 69 if (!screen_) { |
|
James Cook
2016/05/19 05:08:22
I'm a little confused here. This if() implies to m
sky
2016/05/19 15:14:24
Good catch. I made OnRootWindowControllerGotRoot e
| |
| 64 screen_->Init(connector_); | 70 std::unique_ptr<views::ScreenMus> screen(new views::ScreenMus(nullptr)); |
| 71 screen->Init(connector_); | |
| 72 screen_ = std::move(screen); | |
| 73 } | |
| 65 | 74 |
| 66 // TODO(msw): figure out if this should be per display, or global. | 75 // TODO(msw): figure out if this should be per display, or global. |
| 67 user_window_controller_->Initialize(root_controller); | 76 user_window_controller_->Initialize(root_controller); |
| 68 for (auto& request : user_window_controller_requests_) | 77 for (auto& request : user_window_controller_requests_) |
| 69 user_window_controller_bindings_.AddBinding(user_window_controller_.get(), | 78 user_window_controller_bindings_.AddBinding(user_window_controller_.get(), |
| 70 std::move(*request)); | 79 std::move(*request)); |
| 71 user_window_controller_requests_.clear(); | 80 user_window_controller_requests_.clear(); |
| 72 | 81 |
| 73 // TODO(msw): figure out if this should be per display, or global. | 82 // TODO(msw): figure out if this should be per display, or global. |
| 74 shelf_layout_->Initialize(root_controller); | 83 shelf_layout_->Initialize(root_controller); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 104 void WindowManagerApplication::RemoveRootWindowsObserver( | 113 void WindowManagerApplication::RemoveRootWindowsObserver( |
| 105 RootWindowsObserver* observer) { | 114 RootWindowsObserver* observer) { |
| 106 root_windows_observers_.RemoveObserver(observer); | 115 root_windows_observers_.RemoveObserver(observer); |
| 107 } | 116 } |
| 108 | 117 |
| 109 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( | 118 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( |
| 110 AcceleratorRegistrarImpl* registrar) { | 119 AcceleratorRegistrarImpl* registrar) { |
| 111 accelerator_registrars_.erase(registrar); | 120 accelerator_registrars_.erase(registrar); |
| 112 } | 121 } |
| 113 | 122 |
| 123 void WindowManagerApplication::AddRootWindowController( | |
| 124 RootWindowController* root_window_controller) { | |
| 125 root_controllers_.insert(root_window_controller); | |
| 126 } | |
| 127 | |
| 114 void WindowManagerApplication::Initialize(shell::Connector* connector, | 128 void WindowManagerApplication::Initialize(shell::Connector* connector, |
| 115 const shell::Identity& identity, | 129 const shell::Identity& identity, |
| 116 uint32_t id) { | 130 uint32_t id) { |
| 117 connector_ = connector; | 131 connector_ = connector; |
| 118 tracing_.Initialize(connector, identity.name()); | 132 if (connector) { |
| 133 tracing_.Initialize(connector, identity.name()); | |
| 119 | 134 |
| 120 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; | 135 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; |
| 121 connector_->ConnectToInterface("mojo:mus", &wm_factory_service); | 136 connector_->ConnectToInterface("mojo:mus", &wm_factory_service); |
| 122 wm_factory_service->SetWindowManagerFactory( | 137 wm_factory_service->SetWindowManagerFactory( |
| 123 window_manager_factory_binding_.CreateInterfacePtrAndBind()); | 138 window_manager_factory_binding_.CreateInterfacePtrAndBind()); |
| 139 } | |
| 124 | 140 |
| 125 shelf_layout_.reset(new ShelfLayoutImpl); | 141 shelf_layout_.reset(new ShelfLayoutImpl); |
| 126 user_window_controller_.reset(new UserWindowControllerImpl()); | 142 user_window_controller_.reset(new UserWindowControllerImpl()); |
| 127 } | 143 } |
| 128 | 144 |
| 129 bool WindowManagerApplication::AcceptConnection(shell::Connection* connection) { | 145 bool WindowManagerApplication::AcceptConnection(shell::Connection* connection) { |
| 130 connection->AddInterface<mojom::ShelfLayout>(this); | 146 connection->AddInterface<mojom::ShelfLayout>(this); |
| 131 connection->AddInterface<mojom::UserWindowController>(this); | 147 connection->AddInterface<mojom::UserWindowController>(this); |
| 132 connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); | 148 connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); |
| 133 if (connection->GetRemoteIdentity().name() == "mojo:mash_session") | 149 if (connection->GetRemoteIdentity().name() == "mojo:mash_session") |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 } | 190 } |
| 175 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( | 191 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( |
| 176 this, ++accelerator_registrar_count, std::move(request), | 192 this, ++accelerator_registrar_count, std::move(request), |
| 177 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, | 193 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, |
| 178 base::Unretained(this)))); | 194 base::Unretained(this)))); |
| 179 } | 195 } |
| 180 | 196 |
| 181 void WindowManagerApplication::CreateWindowManager( | 197 void WindowManagerApplication::CreateWindowManager( |
| 182 mus::mojom::DisplayPtr display, | 198 mus::mojom::DisplayPtr display, |
| 183 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { | 199 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { |
| 184 root_controllers_.insert(RootWindowController::CreateFromDisplay( | 200 AddRootWindowController(RootWindowController::CreateFromDisplay( |
| 185 this, std::move(display), std::move(client_request))); | 201 this, std::move(display), std::move(client_request))); |
| 186 } | 202 } |
| 187 | 203 |
| 188 } // namespace wm | 204 } // namespace wm |
| 189 } // namespace mash | 205 } // namespace mash |
| OLD | NEW |