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" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void WindowManagerApplication::RemoveRootWindowsObserver( | 99 void WindowManagerApplication::RemoveRootWindowsObserver( |
100 RootWindowsObserver* observer) { | 100 RootWindowsObserver* observer) { |
101 root_windows_observers_.RemoveObserver(observer); | 101 root_windows_observers_.RemoveObserver(observer); |
102 } | 102 } |
103 | 103 |
104 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( | 104 void WindowManagerApplication::OnAcceleratorRegistrarDestroyed( |
105 AcceleratorRegistrarImpl* registrar) { | 105 AcceleratorRegistrarImpl* registrar) { |
106 accelerator_registrars_.erase(registrar); | 106 accelerator_registrars_.erase(registrar); |
107 } | 107 } |
108 | 108 |
109 void WindowManagerApplication::Initialize(mojo::Connector* connector, | 109 void WindowManagerApplication::Initialize(shell::Connector* connector, |
110 const mojo::Identity& identity, | 110 const shell::Identity& identity, |
111 uint32_t id) { | 111 uint32_t id) { |
112 connector_ = connector; | 112 connector_ = connector; |
113 tracing_.Initialize(connector, identity.name()); | 113 tracing_.Initialize(connector, identity.name()); |
114 | 114 |
115 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; | 115 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; |
116 connector_->ConnectToInterface("mojo:mus", &wm_factory_service); | 116 connector_->ConnectToInterface("mojo:mus", &wm_factory_service); |
117 wm_factory_service->SetWindowManagerFactory( | 117 wm_factory_service->SetWindowManagerFactory( |
118 window_manager_factory_binding_.CreateInterfacePtrAndBind()); | 118 window_manager_factory_binding_.CreateInterfacePtrAndBind()); |
119 | 119 |
120 user_window_controller_.reset(new UserWindowControllerImpl()); | 120 user_window_controller_.reset(new UserWindowControllerImpl()); |
121 } | 121 } |
122 | 122 |
123 bool WindowManagerApplication::AcceptConnection(mojo::Connection* connection) { | 123 bool WindowManagerApplication::AcceptConnection(shell::Connection* connection) { |
124 connection->AddInterface<mash::wm::mojom::UserWindowController>(this); | 124 connection->AddInterface<mash::wm::mojom::UserWindowController>(this); |
125 connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); | 125 connection->AddInterface<mus::mojom::AcceleratorRegistrar>(this); |
126 if (connection->GetRemoteIdentity().name() == "mojo:mash_session") | 126 if (connection->GetRemoteIdentity().name() == "mojo:mash_session") |
127 connection->GetInterface(&session_); | 127 connection->GetInterface(&session_); |
128 return true; | 128 return true; |
129 } | 129 } |
130 | 130 |
131 void WindowManagerApplication::Create( | 131 void WindowManagerApplication::Create( |
132 mojo::Connection* connection, | 132 shell::Connection* connection, |
133 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) { | 133 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> request) { |
134 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { | 134 if (!root_controllers_.empty() && (*root_controllers_.begin())->root()) { |
135 user_window_controller_binding_.AddBinding(user_window_controller_.get(), | 135 user_window_controller_binding_.AddBinding(user_window_controller_.get(), |
136 std::move(request)); | 136 std::move(request)); |
137 } else { | 137 } else { |
138 user_window_controller_requests_.push_back(base::WrapUnique( | 138 user_window_controller_requests_.push_back(base::WrapUnique( |
139 new mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>( | 139 new mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>( |
140 std::move(request)))); | 140 std::move(request)))); |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 void WindowManagerApplication::Create( | 144 void WindowManagerApplication::Create( |
145 mojo::Connection* connection, | 145 shell::Connection* connection, |
146 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { | 146 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) { |
147 static int accelerator_registrar_count = 0; | 147 static int accelerator_registrar_count = 0; |
148 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { | 148 if (accelerator_registrar_count == std::numeric_limits<int>::max()) { |
149 // Restart from zero if we have reached the limit. It is technically | 149 // Restart from zero if we have reached the limit. It is technically |
150 // possible to end up with multiple active registrars with the same | 150 // possible to end up with multiple active registrars with the same |
151 // namespace, but it is highly unlikely. In the event that multiple | 151 // namespace, but it is highly unlikely. In the event that multiple |
152 // registrars have the same namespace, this new registrar will be unable to | 152 // registrars have the same namespace, this new registrar will be unable to |
153 // install accelerators. | 153 // install accelerators. |
154 accelerator_registrar_count = 0; | 154 accelerator_registrar_count = 0; |
155 } | 155 } |
156 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( | 156 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( |
157 this, ++accelerator_registrar_count, std::move(request), | 157 this, ++accelerator_registrar_count, std::move(request), |
158 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, | 158 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, |
159 base::Unretained(this)))); | 159 base::Unretained(this)))); |
160 } | 160 } |
161 | 161 |
162 void WindowManagerApplication::CreateWindowManager( | 162 void WindowManagerApplication::CreateWindowManager( |
163 mus::mojom::DisplayPtr display, | 163 mus::mojom::DisplayPtr display, |
164 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { | 164 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request) { |
165 root_controllers_.insert(RootWindowController::CreateFromDisplay( | 165 root_controllers_.insert(RootWindowController::CreateFromDisplay( |
166 this, std::move(display), std::move(client_request))); | 166 this, std::move(display), std::move(client_request))); |
167 } | 167 } |
168 | 168 |
169 } // namespace wm | 169 } // namespace wm |
170 } // namespace mash | 170 } // namespace mash |
OLD | NEW |