| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/process/process.h" | 14 #include "base/process/process.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "mojo/public/cpp/bindings/binding.h" | 17 #include "mojo/public/cpp/bindings/binding.h" |
| 18 #include "services/catalog/public/interfaces/catalog.mojom.h" | 18 #include "services/catalog/public/interfaces/catalog.mojom.h" |
| 19 #include "services/service_manager/public/cpp/connection.h" | 19 #include "services/service_manager/public/cpp/connection.h" |
| 20 #include "services/service_manager/public/cpp/connector.h" | 20 #include "services/service_manager/public/cpp/connector.h" |
| 21 #include "services/service_manager/public/cpp/interface_registry.h" |
| 22 #include "services/service_manager/public/cpp/service_context.h" |
| 21 #include "services/service_manager/public/interfaces/service_manager.mojom.h" | 23 #include "services/service_manager/public/interfaces/service_manager.mojom.h" |
| 22 #include "ui/base/models/table_model.h" | 24 #include "ui/base/models/table_model.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/resources/grit/ui_resources.h" | 26 #include "ui/resources/grit/ui_resources.h" |
| 25 #include "ui/views/background.h" | 27 #include "ui/views/background.h" |
| 26 #include "ui/views/controls/button/md_text_button.h" | 28 #include "ui/views/controls/button/md_text_button.h" |
| 27 #include "ui/views/controls/table/table_view.h" | 29 #include "ui/views/controls/table/table_view.h" |
| 28 #include "ui/views/controls/table/table_view_observer.h" | 30 #include "ui/views/controls/table/table_view_observer.h" |
| 29 #include "ui/views/mus/aura_init.h" | 31 #include "ui/views/mus/aura_init.h" |
| 30 #include "ui/views/mus/window_manager_connection.h" | 32 #include "ui/views/mus/window_manager_connection.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 TaskViewer::~TaskViewer() {} | 282 TaskViewer::~TaskViewer() {} |
| 281 | 283 |
| 282 void TaskViewer::RemoveWindow(views::Widget* widget) { | 284 void TaskViewer::RemoveWindow(views::Widget* widget) { |
| 283 auto it = std::find(windows_.begin(), windows_.end(), widget); | 285 auto it = std::find(windows_.begin(), windows_.end(), widget); |
| 284 DCHECK(it != windows_.end()); | 286 DCHECK(it != windows_.end()); |
| 285 windows_.erase(it); | 287 windows_.erase(it); |
| 286 if (windows_.empty()) | 288 if (windows_.empty()) |
| 287 base::MessageLoop::current()->QuitWhenIdle(); | 289 base::MessageLoop::current()->QuitWhenIdle(); |
| 288 } | 290 } |
| 289 | 291 |
| 290 void TaskViewer::OnStart(const service_manager::ServiceInfo& info) { | 292 void TaskViewer::OnStart(service_manager::ServiceContext* context) { |
| 291 tracing_.Initialize(connector(), info.identity.name()); | 293 context_ = context; |
| 292 | 294 |
| 293 aura_init_ = base::MakeUnique<views::AuraInit>(connector(), info.identity, | 295 tracing_.Initialize(context->connector(), context->identity().name()); |
| 294 "views_mus_resources.pak"); | 296 |
| 295 window_manager_connection_ = | 297 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 296 views::WindowManagerConnection::Create(connector(), info.identity); | 298 context->connector(), context->identity(), "views_mus_resources.pak"); |
| 299 window_manager_connection_ = views::WindowManagerConnection::Create( |
| 300 context->connector(), context->identity()); |
| 297 } | 301 } |
| 298 | 302 |
| 299 bool TaskViewer::OnConnect(const service_manager::ServiceInfo& remote_info, | 303 bool TaskViewer::OnConnect(const service_manager::ServiceInfo& remote_info, |
| 300 service_manager::InterfaceRegistry* registry) { | 304 service_manager::InterfaceRegistry* registry) { |
| 301 registry->AddInterface<mojom::Launchable>(this); | 305 registry->AddInterface<mojom::Launchable>(this); |
| 302 return true; | 306 return true; |
| 303 } | 307 } |
| 304 | 308 |
| 305 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) { | 309 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) { |
| 306 bool reuse = how == mojom::LaunchMode::REUSE || | 310 bool reuse = how == mojom::LaunchMode::REUSE || |
| 307 how == mojom::LaunchMode::DEFAULT; | 311 how == mojom::LaunchMode::DEFAULT; |
| 308 if (reuse && !windows_.empty()) { | 312 if (reuse && !windows_.empty()) { |
| 309 windows_.back()->Activate(); | 313 windows_.back()->Activate(); |
| 310 return; | 314 return; |
| 311 } | 315 } |
| 312 | 316 |
| 313 service_manager::mojom::ServiceManagerPtr service_manager; | 317 service_manager::mojom::ServiceManagerPtr service_manager; |
| 314 connector()->ConnectToInterface("service:service_manager", &service_manager); | 318 context_->connector()->ConnectToInterface( |
| 319 "service:service_manager", &service_manager); |
| 315 | 320 |
| 316 service_manager::mojom::ServiceManagerListenerPtr listener; | 321 service_manager::mojom::ServiceManagerListenerPtr listener; |
| 317 service_manager::mojom::ServiceManagerListenerRequest request = | 322 service_manager::mojom::ServiceManagerListenerRequest request = |
| 318 GetProxy(&listener); | 323 GetProxy(&listener); |
| 319 service_manager->AddListener(std::move(listener)); | 324 service_manager->AddListener(std::move(listener)); |
| 320 | 325 |
| 321 catalog::mojom::CatalogPtr catalog; | 326 catalog::mojom::CatalogPtr catalog; |
| 322 connector()->ConnectToInterface("service:catalog", &catalog); | 327 context_->connector()->ConnectToInterface("service:catalog", &catalog); |
| 323 | 328 |
| 324 TaskViewerContents* task_viewer = new TaskViewerContents( | 329 TaskViewerContents* task_viewer = new TaskViewerContents( |
| 325 this, std::move(request), std::move(catalog)); | 330 this, std::move(request), std::move(catalog)); |
| 326 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( | 331 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( |
| 327 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500)); | 332 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500)); |
| 328 window->Show(); | 333 window->Show(); |
| 329 windows_.push_back(window); | 334 windows_.push_back(window); |
| 330 } | 335 } |
| 331 | 336 |
| 332 void TaskViewer::Create(const service_manager::Identity& remote_identity, | 337 void TaskViewer::Create(const service_manager::Identity& remote_identity, |
| 333 mojom::LaunchableRequest request) { | 338 mojom::LaunchableRequest request) { |
| 334 bindings_.AddBinding(this, std::move(request)); | 339 bindings_.AddBinding(this, std::move(request)); |
| 335 } | 340 } |
| 336 | 341 |
| 337 } // namespace task_viewer | 342 } // namespace task_viewer |
| 338 } // namespace main | 343 } // namespace main |
| OLD | NEW |