OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mash/package/mash_packaged_service.h" |
| 6 |
| 7 #include "ash/mus/window_manager_application.h" |
| 8 #include "ash/touch_hud/mus/touch_hud_application.h" |
| 9 #include "mash/app_driver/app_driver.h" |
| 10 #include "mash/quick_launch/quick_launch.h" |
| 11 #include "mash/session/session.h" |
| 12 #include "mash/task_viewer/task_viewer.h" |
| 13 #include "services/shell/public/cpp/service_context.h" |
| 14 #include "services/ui/service.h" |
| 15 |
| 16 #if defined(OS_LINUX) |
| 17 #include "components/font_service/font_service_app.h" |
| 18 #endif |
| 19 |
| 20 namespace mash { |
| 21 |
| 22 MashPackagedService::MashPackagedService() {} |
| 23 |
| 24 MashPackagedService::~MashPackagedService() {} |
| 25 |
| 26 bool MashPackagedService::OnConnect(const shell::Identity& remote_identity, |
| 27 shell::InterfaceRegistry* registry) { |
| 28 registry->AddInterface<ServiceFactory>(this); |
| 29 return true; |
| 30 } |
| 31 |
| 32 void MashPackagedService::Create( |
| 33 const shell::Identity& remote_identity, |
| 34 mojo::InterfaceRequest<ServiceFactory> request) { |
| 35 service_factory_bindings_.AddBinding(this, std::move(request)); |
| 36 } |
| 37 |
| 38 void MashPackagedService::CreateService(shell::mojom::ServiceRequest request, |
| 39 const std::string& mojo_name) { |
| 40 if (service_) { |
| 41 LOG(ERROR) << "request to create additional service " << mojo_name; |
| 42 return; |
| 43 } |
| 44 service_ = CreateService(mojo_name); |
| 45 if (service_) { |
| 46 service_->set_context(base::MakeUnique<shell::ServiceContext>( |
| 47 service_.get(), std::move(request))); |
| 48 return; |
| 49 } |
| 50 LOG(ERROR) << "unknown name " << mojo_name; |
| 51 NOTREACHED(); |
| 52 } |
| 53 |
| 54 std::unique_ptr<shell::Service> MashPackagedService::CreateService( |
| 55 const std::string& name) { |
| 56 if (name == "mojo:ash") |
| 57 return base::WrapUnique(new ash::mus::WindowManagerApplication); |
| 58 if (name == "mojo:touch_hud") |
| 59 return base::WrapUnique(new ash::touch_hud::TouchHudApplication); |
| 60 if (name == "mojo:mash_session") |
| 61 return base::WrapUnique(new mash::session::Session); |
| 62 if (name == "mojo:ui") |
| 63 return base::WrapUnique(new ui::Service); |
| 64 if (name == "mojo:quick_launch") |
| 65 return base::WrapUnique(new mash::quick_launch::QuickLaunch); |
| 66 if (name == "mojo:task_viewer") |
| 67 return base::WrapUnique(new mash::task_viewer::TaskViewer); |
| 68 #if defined(OS_LINUX) |
| 69 if (name == "mojo:font_service") |
| 70 return base::WrapUnique(new font_service::FontServiceApp); |
| 71 #endif |
| 72 if (name == "mojo:app_driver") |
| 73 return base::WrapUnique(new mash::app_driver::AppDriver); |
| 74 return nullptr; |
| 75 } |
| 76 |
| 77 } // namespace mash |
OLD | NEW |