| 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 "services/shell/public/c/main.h" | 5 #include "services/shell/public/c/main.h" |
| 6 #include "services/shell/public/cpp/connector.h" | 6 #include "services/shell/public/cpp/connector.h" |
| 7 #include "services/shell/public/cpp/service.h" | 7 #include "services/shell/public/cpp/service.h" |
| 8 #include "services/shell/public/cpp/service_runner.h" | 8 #include "services/shell/public/cpp/service_runner.h" |
| 9 #include "services/ui/test_ime/test_ime_driver.h" | 9 #include "services/ui/test_ime/test_ime_driver.h" |
| 10 | 10 |
| 11 namespace ui { | 11 namespace ui { |
| 12 namespace test { | 12 namespace test { |
| 13 | 13 |
| 14 class TestIME : public shell::Service, | 14 class TestIME : public shell::Service, |
| 15 public shell::InterfaceFactory<mojom::IMEDriver> { | 15 public shell::InterfaceFactory<mojom::IMEDriver> { |
| 16 public: | 16 public: |
| 17 TestIME() {} | 17 TestIME() {} |
| 18 ~TestIME() override {} | 18 ~TestIME() override {} |
| 19 | 19 |
| 20 private: | 20 private: |
| 21 // shell::Service: | 21 // shell::Service: |
| 22 void OnStart(const shell::Identity& identity) override {} | 22 void OnStart(const shell::Identity& identity) override {} |
| 23 bool OnConnect(shell::Connection* connection) override { | 23 bool OnConnect(const shell::Identity& remote_identity, |
| 24 connection->AddInterface<mojom::IMEDriver>(this); | 24 shell::InterfaceRegistry* registry) override { |
| 25 registry->AddInterface<mojom::IMEDriver>(this); |
| 25 return true; | 26 return true; |
| 26 } | 27 } |
| 27 | 28 |
| 28 // shell::InterfaceFactory<mojom::IMEDriver>: | 29 // shell::InterfaceFactory<mojom::IMEDriver>: |
| 29 void Create(const shell::Identity& remote_identity, | 30 void Create(const shell::Identity& remote_identity, |
| 30 mojom::IMEDriverRequest request) override { | 31 mojom::IMEDriverRequest request) override { |
| 31 ime_driver_.reset(new TestIMEDriver(std::move(request))); | 32 ime_driver_.reset(new TestIMEDriver(std::move(request))); |
| 32 } | 33 } |
| 33 | 34 |
| 34 std::unique_ptr<TestIMEDriver> ime_driver_; | 35 std::unique_ptr<TestIMEDriver> ime_driver_; |
| 35 | 36 |
| 36 DISALLOW_COPY_AND_ASSIGN(TestIME); | 37 DISALLOW_COPY_AND_ASSIGN(TestIME); |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 } // namespace test | 40 } // namespace test |
| 40 } // namespace ui | 41 } // namespace ui |
| 41 | 42 |
| 42 MojoResult ServiceMain(MojoHandle service_request_handle) { | 43 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 43 shell::ServiceRunner runner(new ui::test::TestIME); | 44 shell::ServiceRunner runner(new ui::test::TestIME); |
| 44 return runner.Run(service_request_handle); | 45 return runner.Run(service_request_handle); |
| 45 } | 46 } |
| OLD | NEW |