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/task_viewer/task_viewer.h" | 5 #include "mash/task_viewer/task_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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 TaskViewer::~TaskViewer() {} | 282 TaskViewer::~TaskViewer() {} |
283 | 283 |
284 void TaskViewer::RemoveWindow(views::Widget* widget) { | 284 void TaskViewer::RemoveWindow(views::Widget* widget) { |
285 auto it = std::find(windows_.begin(), windows_.end(), widget); | 285 auto it = std::find(windows_.begin(), windows_.end(), widget); |
286 DCHECK(it != windows_.end()); | 286 DCHECK(it != windows_.end()); |
287 windows_.erase(it); | 287 windows_.erase(it); |
288 if (windows_.empty()) | 288 if (windows_.empty()) |
289 base::MessageLoop::current()->QuitWhenIdle(); | 289 base::MessageLoop::current()->QuitWhenIdle(); |
290 } | 290 } |
291 | 291 |
292 void TaskViewer::OnStart(service_manager::ServiceContext* context) { | 292 void TaskViewer::OnStart() { |
293 context_ = context; | 293 tracing_.Initialize(context()->connector(), context()->identity().name()); |
294 | |
295 tracing_.Initialize(context->connector(), context->identity().name()); | |
296 | 294 |
297 aura_init_ = base::MakeUnique<views::AuraInit>( | 295 aura_init_ = base::MakeUnique<views::AuraInit>( |
298 context->connector(), context->identity(), "views_mus_resources.pak"); | 296 context()->connector(), context()->identity(), "views_mus_resources.pak"); |
299 window_manager_connection_ = views::WindowManagerConnection::Create( | 297 window_manager_connection_ = views::WindowManagerConnection::Create( |
300 context->connector(), context->identity()); | 298 context()->connector(), context()->identity()); |
301 } | 299 } |
302 | 300 |
303 bool TaskViewer::OnConnect(const service_manager::ServiceInfo& remote_info, | 301 bool TaskViewer::OnConnect(const service_manager::ServiceInfo& remote_info, |
304 service_manager::InterfaceRegistry* registry) { | 302 service_manager::InterfaceRegistry* registry) { |
305 registry->AddInterface<mojom::Launchable>(this); | 303 registry->AddInterface<mojom::Launchable>(this); |
306 return true; | 304 return true; |
307 } | 305 } |
308 | 306 |
309 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) { | 307 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) { |
310 bool reuse = how == mojom::LaunchMode::REUSE || | 308 bool reuse = how == mojom::LaunchMode::REUSE || |
311 how == mojom::LaunchMode::DEFAULT; | 309 how == mojom::LaunchMode::DEFAULT; |
312 if (reuse && !windows_.empty()) { | 310 if (reuse && !windows_.empty()) { |
313 windows_.back()->Activate(); | 311 windows_.back()->Activate(); |
314 return; | 312 return; |
315 } | 313 } |
316 | 314 |
317 service_manager::mojom::ServiceManagerPtr service_manager; | 315 service_manager::mojom::ServiceManagerPtr service_manager; |
318 context_->connector()->ConnectToInterface( | 316 context()->connector()->ConnectToInterface( |
319 "service:service_manager", &service_manager); | 317 "service:service_manager", &service_manager); |
320 | 318 |
321 service_manager::mojom::ServiceManagerListenerPtr listener; | 319 service_manager::mojom::ServiceManagerListenerPtr listener; |
322 service_manager::mojom::ServiceManagerListenerRequest request = | 320 service_manager::mojom::ServiceManagerListenerRequest request = |
323 GetProxy(&listener); | 321 GetProxy(&listener); |
324 service_manager->AddListener(std::move(listener)); | 322 service_manager->AddListener(std::move(listener)); |
325 | 323 |
326 catalog::mojom::CatalogPtr catalog; | 324 catalog::mojom::CatalogPtr catalog; |
327 context_->connector()->ConnectToInterface("service:catalog", &catalog); | 325 context()->connector()->ConnectToInterface("service:catalog", &catalog); |
328 | 326 |
329 TaskViewerContents* task_viewer = new TaskViewerContents( | 327 TaskViewerContents* task_viewer = new TaskViewerContents( |
330 this, std::move(request), std::move(catalog)); | 328 this, std::move(request), std::move(catalog)); |
331 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 329 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
332 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500)); | 330 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500)); |
333 window->Show(); | 331 window->Show(); |
334 windows_.push_back(window); | 332 windows_.push_back(window); |
335 } | 333 } |
336 | 334 |
337 void TaskViewer::Create(const service_manager::Identity& remote_identity, | 335 void TaskViewer::Create(const service_manager::Identity& remote_identity, |
338 mojom::LaunchableRequest request) { | 336 mojom::LaunchableRequest request) { |
339 bindings_.AddBinding(this, std::move(request)); | 337 bindings_.AddBinding(this, std::move(request)); |
340 } | 338 } |
341 | 339 |
342 } // namespace task_viewer | 340 } // namespace task_viewer |
343 } // namespace main | 341 } // namespace main |
OLD | NEW |