OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/quick_launch/quick_launch.h" | 5 #include "mash/quick_launch/quick_launch.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 QuickLaunch::~QuickLaunch() {} | 159 QuickLaunch::~QuickLaunch() {} |
160 | 160 |
161 void QuickLaunch::RemoveWindow(views::Widget* window) { | 161 void QuickLaunch::RemoveWindow(views::Widget* window) { |
162 auto it = std::find(windows_.begin(), windows_.end(), window); | 162 auto it = std::find(windows_.begin(), windows_.end(), window); |
163 DCHECK(it != windows_.end()); | 163 DCHECK(it != windows_.end()); |
164 windows_.erase(it); | 164 windows_.erase(it); |
165 if (windows_.empty() && base::MessageLoop::current()->is_running()) | 165 if (windows_.empty() && base::MessageLoop::current()->is_running()) |
166 base::MessageLoop::current()->QuitWhenIdle(); | 166 base::MessageLoop::current()->QuitWhenIdle(); |
167 } | 167 } |
168 | 168 |
169 void QuickLaunch::OnStart() { | 169 void QuickLaunch::OnStart(service_manager::ServiceContext* context) { |
170 tracing_.Initialize(context()->connector(), context()->identity().name()); | 170 context_ = context; |
| 171 tracing_.Initialize(context->connector(), context->identity().name()); |
171 | 172 |
172 aura_init_ = base::MakeUnique<views::AuraInit>( | 173 aura_init_ = base::MakeUnique<views::AuraInit>( |
173 context()->connector(), context()->identity(), "views_mus_resources.pak"); | 174 context->connector(), context->identity(), "views_mus_resources.pak"); |
174 window_manager_connection_ = views::WindowManagerConnection::Create( | 175 window_manager_connection_ = views::WindowManagerConnection::Create( |
175 context()->connector(), context()->identity()); | 176 context->connector(), context->identity()); |
176 | 177 |
177 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); | 178 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); |
178 } | 179 } |
179 | 180 |
180 bool QuickLaunch::OnConnect(const service_manager::ServiceInfo& remote_info, | 181 bool QuickLaunch::OnConnect(const service_manager::ServiceInfo& remote_info, |
181 service_manager::InterfaceRegistry* registry) { | 182 service_manager::InterfaceRegistry* registry) { |
182 registry->AddInterface<mojom::Launchable>(this); | 183 registry->AddInterface<mojom::Launchable>(this); |
183 return true; | 184 return true; |
184 } | 185 } |
185 | 186 |
186 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) { | 187 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) { |
187 bool reuse = how == mojom::LaunchMode::REUSE || | 188 bool reuse = how == mojom::LaunchMode::REUSE || |
188 how == mojom::LaunchMode::DEFAULT; | 189 how == mojom::LaunchMode::DEFAULT; |
189 if (reuse && !windows_.empty()) { | 190 if (reuse && !windows_.empty()) { |
190 windows_.back()->Activate(); | 191 windows_.back()->Activate(); |
191 return; | 192 return; |
192 } | 193 } |
193 catalog::mojom::CatalogPtr catalog; | 194 catalog::mojom::CatalogPtr catalog; |
194 context()->connector()->ConnectToInterface("service:catalog", &catalog); | 195 context_->connector()->ConnectToInterface("service:catalog", &catalog); |
195 | 196 |
196 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 197 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
197 new QuickLaunchUI(this, context()->connector(), std::move(catalog)), | 198 new QuickLaunchUI(this, context_->connector(), std::move(catalog)), |
198 nullptr, gfx::Rect(10, 640, 0, 0)); | 199 nullptr, gfx::Rect(10, 640, 0, 0)); |
199 window->Show(); | 200 window->Show(); |
200 windows_.push_back(window); | 201 windows_.push_back(window); |
201 } | 202 } |
202 | 203 |
203 void QuickLaunch::Create(const service_manager::Identity& remote_identity, | 204 void QuickLaunch::Create(const service_manager::Identity& remote_identity, |
204 mojom::LaunchableRequest request) { | 205 mojom::LaunchableRequest request) { |
205 bindings_.AddBinding(this, std::move(request)); | 206 bindings_.AddBinding(this, std::move(request)); |
206 } | 207 } |
207 | 208 |
208 } // namespace quick_launch | 209 } // namespace quick_launch |
209 } // namespace mash | 210 } // namespace mash |
OLD | NEW |