| 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() { | 220 void CatalogViewer::OnStart(service_manager::ServiceContext* context) { |
| 221 tracing_.Initialize(context()->connector(), context()->identity().name()); | 221 context_ = context; |
| 222 tracing_.Initialize(context->connector(), context->identity().name()); |
| 222 | 223 |
| 223 aura_init_ = base::MakeUnique<views::AuraInit>( | 224 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 224 context()->connector(), context()->identity(), "views_mus_resources.pak"); | 225 context->connector(), context->identity(), "views_mus_resources.pak"); |
| 225 window_manager_connection_ = views::WindowManagerConnection::Create( | 226 window_manager_connection_ = views::WindowManagerConnection::Create( |
| 226 context()->connector(), context()->identity()); | 227 context->connector(), context->identity()); |
| 227 } | 228 } |
| 228 | 229 |
| 229 bool CatalogViewer::OnConnect(const service_manager::ServiceInfo& remote_info, | 230 bool CatalogViewer::OnConnect(const service_manager::ServiceInfo& remote_info, |
| 230 service_manager::InterfaceRegistry* registry) { | 231 service_manager::InterfaceRegistry* registry) { |
| 231 registry->AddInterface<mojom::Launchable>(this); | 232 registry->AddInterface<mojom::Launchable>(this); |
| 232 return true; | 233 return true; |
| 233 } | 234 } |
| 234 | 235 |
| 235 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { | 236 void CatalogViewer::Launch(uint32_t what, mojom::LaunchMode how) { |
| 236 bool reuse = how == mojom::LaunchMode::REUSE || | 237 bool reuse = how == mojom::LaunchMode::REUSE || |
| 237 how == mojom::LaunchMode::DEFAULT; | 238 how == mojom::LaunchMode::DEFAULT; |
| 238 if (reuse && !windows_.empty()) { | 239 if (reuse && !windows_.empty()) { |
| 239 windows_.back()->Activate(); | 240 windows_.back()->Activate(); |
| 240 return; | 241 return; |
| 241 } | 242 } |
| 242 catalog::mojom::CatalogPtr catalog; | 243 catalog::mojom::CatalogPtr catalog; |
| 243 context()->connector()->ConnectToInterface("service:catalog", &catalog); | 244 context_->connector()->ConnectToInterface("service:catalog", &catalog); |
| 244 | 245 |
| 245 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 246 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 246 new CatalogViewerContents(this, std::move(catalog)), nullptr, | 247 new CatalogViewerContents(this, std::move(catalog)), nullptr, |
| 247 gfx::Rect(25, 25, 500, 600)); | 248 gfx::Rect(25, 25, 500, 600)); |
| 248 window->Show(); | 249 window->Show(); |
| 249 windows_.push_back(window); | 250 windows_.push_back(window); |
| 250 } | 251 } |
| 251 | 252 |
| 252 void CatalogViewer::Create(const service_manager::Identity& remote_identity, | 253 void CatalogViewer::Create(const service_manager::Identity& remote_identity, |
| 253 mojom::LaunchableRequest request) { | 254 mojom::LaunchableRequest request) { |
| 254 bindings_.AddBinding(this, std::move(request)); | 255 bindings_.AddBinding(this, std::move(request)); |
| 255 } | 256 } |
| 256 | 257 |
| 257 } // namespace catalog_viewer | 258 } // namespace catalog_viewer |
| 258 } // namespace mash | 259 } // namespace mash |
| OLD | NEW |