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/catalog_viewer/catalog_viewer.h" | 5 #include "mash/catalog_viewer/catalog_viewer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 CatalogViewer::~CatalogViewer() {} | 210 CatalogViewer::~CatalogViewer() {} |
211 | 211 |
212 void CatalogViewer::RemoveWindow(views::Widget* window) { | 212 void CatalogViewer::RemoveWindow(views::Widget* window) { |
213 auto it = std::find(windows_.begin(), windows_.end(), window); | 213 auto it = std::find(windows_.begin(), windows_.end(), window); |
214 DCHECK(it != windows_.end()); | 214 DCHECK(it != windows_.end()); |
215 windows_.erase(it); | 215 windows_.erase(it); |
216 if (windows_.empty()) | 216 if (windows_.empty()) |
217 base::MessageLoop::current()->QuitWhenIdle(); | 217 base::MessageLoop::current()->QuitWhenIdle(); |
218 } | 218 } |
219 | 219 |
220 void CatalogViewer::OnStart(service_manager::ServiceContext* context) { | 220 void CatalogViewer::OnStart() { |
221 context_ = context; | 221 tracing_.Initialize(context()->connector(), context()->identity().name()); |
222 tracing_.Initialize(context->connector(), context->identity().name()); | |
223 | 222 |
224 aura_init_ = base::MakeUnique<views::AuraInit>( | 223 aura_init_ = base::MakeUnique<views::AuraInit>( |
225 context->connector(), context->identity(), "views_mus_resources.pak"); | 224 context()->connector(), context()->identity(), "views_mus_resources.pak"); |
226 window_manager_connection_ = views::WindowManagerConnection::Create( | 225 window_manager_connection_ = views::WindowManagerConnection::Create( |
227 context->connector(), context->identity()); | 226 context()->connector(), context()->identity()); |
228 } | 227 } |
229 | 228 |
230 bool CatalogViewer::OnConnect(const service_manager::ServiceInfo& remote_info, | 229 bool CatalogViewer::OnConnect(const service_manager::ServiceInfo& remote_info, |
231 service_manager::InterfaceRegistry* registry) { | 230 service_manager::InterfaceRegistry* registry) { |
232 registry->AddInterface<mojom::Launchable>(this); | 231 registry->AddInterface<mojom::Launchable>(this); |
233 return true; | 232 return true; |
234 } | 233 } |
235 | 234 |
236 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { | 235 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { |
237 bool reuse = how == mojom::LaunchMode::REUSE || | 236 bool reuse = how == mojom::LaunchMode::REUSE || |
238 how == mojom::LaunchMode::DEFAULT; | 237 how == mojom::LaunchMode::DEFAULT; |
239 if (reuse && !windows_.empty()) { | 238 if (reuse && !windows_.empty()) { |
240 windows_.back()->Activate(); | 239 windows_.back()->Activate(); |
241 return; | 240 return; |
242 } | 241 } |
243 catalog::mojom::CatalogPtr catalog; | 242 catalog::mojom::CatalogPtr catalog; |
244 context_->connector()->ConnectToInterface("service:catalog", &catalog); | 243 context()->connector()->ConnectToInterface("service:catalog", &catalog); |
245 | 244 |
246 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 245 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
247 new CatalogViewerContents(this, std::move(catalog)), nullptr, | 246 new CatalogViewerContents(this, std::move(catalog)), nullptr, |
248 gfx::Rect(25, 25, 500, 600)); | 247 gfx::Rect(25, 25, 500, 600)); |
249 window->Show(); | 248 window->Show(); |
250 windows_.push_back(window); | 249 windows_.push_back(window); |
251 } | 250 } |
252 | 251 |
253 void CatalogViewer::Create(const service_manager::Identity& remote_identity, | 252 void CatalogViewer::Create(const service_manager::Identity& remote_identity, |
254 mojom::LaunchableRequest request) { | 253 mojom::LaunchableRequest request) { |
255 bindings_.AddBinding(this, std::move(request)); | 254 bindings_.AddBinding(this, std::move(request)); |
256 } | 255 } |
257 | 256 |
258 } // namespace catalog_viewer | 257 } // namespace catalog_viewer |
259 } // namespace mash | 258 } // namespace mash |
OLD | NEW |