| 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 "content/shell/utility/shell_content_utility_client.h" | 5 #include "content/shell/utility/shell_content_utility_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/process/process.h" |
| 11 #include "content/public/common/service_registry.h" | 13 #include "content/public/common/service_registry.h" |
| 12 #include "content/public/test/test_mojo_app.h" | 14 #include "content/public/test/test_mojo_app.h" |
| 15 #include "content/public/test/test_mojo_service.mojom.h" |
| 13 #include "mojo/public/cpp/bindings/strong_binding.h" | 16 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 14 | 17 |
| 15 namespace content { | 18 namespace content { |
| 16 | 19 |
| 17 namespace { | 20 namespace { |
| 18 | 21 |
| 19 class TestMojoServiceImpl : public mojom::TestMojoService { | 22 class TestMojoServiceImpl : public mojom::TestMojoService { |
| 20 public: | 23 public: |
| 21 static void Create(mojo::InterfaceRequest<mojom::TestMojoService> request) { | 24 static void Create(mojo::InterfaceRequest<mojom::TestMojoService> request) { |
| 22 new TestMojoServiceImpl(std::move(request)); | 25 new TestMojoServiceImpl(std::move(request)); |
| 23 } | 26 } |
| 24 | 27 |
| 25 // mojom::TestMojoService implementation: | 28 // mojom::TestMojoService implementation: |
| 26 void DoSomething(const DoSomethingCallback& callback) override { | 29 void DoSomething(const DoSomethingCallback& callback) override { |
| 27 callback.Run(); | 30 callback.Run(); |
| 28 } | 31 } |
| 29 | 32 |
| 33 void DoTerminateProcess(const DoTerminateProcessCallback& callback) override { |
| 34 base::Process::Current().Terminate(0, false); |
| 35 } |
| 36 |
| 37 void CreateFolder(const CreateFolderCallback& callback) override { |
| 38 // Note: This is used to check if the sandbox is disabled or not since |
| 39 // creating a folder is forbidden when it is enabled. |
| 40 callback.Run(base::ScopedTempDir().CreateUniqueTempDir()); |
| 41 } |
| 42 |
| 30 void GetRequestorName(const GetRequestorNameCallback& callback) override { | 43 void GetRequestorName(const GetRequestorNameCallback& callback) override { |
| 31 NOTREACHED(); | 44 NOTREACHED(); |
| 32 } | 45 } |
| 33 | 46 |
| 34 private: | 47 private: |
| 35 explicit TestMojoServiceImpl( | 48 explicit TestMojoServiceImpl( |
| 36 mojo::InterfaceRequest<mojom::TestMojoService> request) | 49 mojo::InterfaceRequest<mojom::TestMojoService> request) |
| 37 : binding_(this, std::move(request)) {} | 50 : binding_(this, std::move(request)) {} |
| 38 | 51 |
| 39 mojo::StrongBinding<mojom::TestMojoService> binding_; | 52 mojo::StrongBinding<mojom::TestMojoService> binding_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 app_info.application_factory = base::Bind(&CreateTestApp); | 70 app_info.application_factory = base::Bind(&CreateTestApp); |
| 58 apps->insert(std::make_pair(kTestMojoAppUrl, app_info)); | 71 apps->insert(std::make_pair(kTestMojoAppUrl, app_info)); |
| 59 } | 72 } |
| 60 | 73 |
| 61 void ShellContentUtilityClient::RegisterMojoServices( | 74 void ShellContentUtilityClient::RegisterMojoServices( |
| 62 ServiceRegistry* registry) { | 75 ServiceRegistry* registry) { |
| 63 registry->AddService(base::Bind(&TestMojoServiceImpl::Create)); | 76 registry->AddService(base::Bind(&TestMojoServiceImpl::Create)); |
| 64 } | 77 } |
| 65 | 78 |
| 66 } // namespace content | 79 } // namespace content |
| OLD | NEW |