| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/example/window_type_launcher/window_type_launcher.h" | 5 #include "mash/example/window_type_launcher/window_type_launcher.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 WindowTypeLauncher::~WindowTypeLauncher() {} | 466 WindowTypeLauncher::~WindowTypeLauncher() {} |
| 467 | 467 |
| 468 void WindowTypeLauncher::RemoveWindow(views::Widget* window) { | 468 void WindowTypeLauncher::RemoveWindow(views::Widget* window) { |
| 469 auto it = std::find(windows_.begin(), windows_.end(), window); | 469 auto it = std::find(windows_.begin(), windows_.end(), window); |
| 470 DCHECK(it != windows_.end()); | 470 DCHECK(it != windows_.end()); |
| 471 windows_.erase(it); | 471 windows_.erase(it); |
| 472 if (windows_.empty()) | 472 if (windows_.empty()) |
| 473 base::MessageLoop::current()->QuitWhenIdle(); | 473 base::MessageLoop::current()->QuitWhenIdle(); |
| 474 } | 474 } |
| 475 | 475 |
| 476 void WindowTypeLauncher::OnStart(service_manager::ServiceContext* context) { | 476 void WindowTypeLauncher::OnStart() { |
| 477 context_ = context; | |
| 478 aura_init_ = base::MakeUnique<views::AuraInit>( | 477 aura_init_ = base::MakeUnique<views::AuraInit>( |
| 479 context->connector(), context->identity(), "views_mus_resources.pak", | 478 context()->connector(), context()->identity(), "views_mus_resources.pak", |
| 480 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); | 479 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); |
| 481 } | 480 } |
| 482 | 481 |
| 483 bool WindowTypeLauncher::OnConnect( | 482 bool WindowTypeLauncher::OnConnect( |
| 484 const service_manager::ServiceInfo& remote_info, | 483 const service_manager::ServiceInfo& remote_info, |
| 485 service_manager::InterfaceRegistry* registry) { | 484 service_manager::InterfaceRegistry* registry) { |
| 486 registry->AddInterface<mash::mojom::Launchable>(this); | 485 registry->AddInterface<mash::mojom::Launchable>(this); |
| 487 return true; | 486 return true; |
| 488 } | 487 } |
| 489 | 488 |
| 490 void WindowTypeLauncher::Launch(uint32_t what, mash::mojom::LaunchMode how) { | 489 void WindowTypeLauncher::Launch(uint32_t what, mash::mojom::LaunchMode how) { |
| 491 bool reuse = how == mash::mojom::LaunchMode::REUSE || | 490 bool reuse = how == mash::mojom::LaunchMode::REUSE || |
| 492 how == mash::mojom::LaunchMode::DEFAULT; | 491 how == mash::mojom::LaunchMode::DEFAULT; |
| 493 if (reuse && !windows_.empty()) { | 492 if (reuse && !windows_.empty()) { |
| 494 windows_.back()->Activate(); | 493 windows_.back()->Activate(); |
| 495 return; | 494 return; |
| 496 } | 495 } |
| 497 views::Widget* window = new views::Widget; | 496 views::Widget* window = new views::Widget; |
| 498 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 497 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 499 params.delegate = new WindowTypeLauncherView(this, context_->connector()); | 498 params.delegate = new WindowTypeLauncherView(this, context()->connector()); |
| 500 window->Init(params); | 499 window->Init(params); |
| 501 window->Show(); | 500 window->Show(); |
| 502 windows_.push_back(window); | 501 windows_.push_back(window); |
| 503 } | 502 } |
| 504 | 503 |
| 505 void WindowTypeLauncher::Create( | 504 void WindowTypeLauncher::Create( |
| 506 const service_manager::Identity& remote_identity, | 505 const service_manager::Identity& remote_identity, |
| 507 mash::mojom::LaunchableRequest request) { | 506 mash::mojom::LaunchableRequest request) { |
| 508 bindings_.AddBinding(this, std::move(request)); | 507 bindings_.AddBinding(this, std::move(request)); |
| 509 } | 508 } |
| 510 | 509 |
| 511 MojoResult ServiceMain(MojoHandle service_request_handle) { | 510 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 512 return service_manager::ServiceRunner(new WindowTypeLauncher) | 511 return service_manager::ServiceRunner(new WindowTypeLauncher) |
| 513 .Run(service_request_handle); | 512 .Run(service_request_handle); |
| 514 } | 513 } |
| OLD | NEW |