sandbox_policy_fuchsia.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2017 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. #ifndef SANDBOX_POLICY_FUCHSIA_SANDBOX_POLICY_FUCHSIA_H_
  5. #define SANDBOX_POLICY_FUCHSIA_SANDBOX_POLICY_FUCHSIA_H_
  6. #include <fuchsia/io/cpp/fidl.h>
  7. #include <lib/fidl/cpp/interface_handle.h>
  8. #include <lib/zx/job.h>
  9. #include "base/memory/ref_counted.h"
  10. #include "base/threading/sequence_bound.h"
  11. #include "sandbox/policy/export.h"
  12. #include "sandbox/policy/mojom/sandbox.mojom.h"
  13. namespace base {
  14. class FilteredServiceDirectory;
  15. struct LaunchOptions;
  16. } // namespace base
  17. namespace sandbox {
  18. namespace policy {
  19. class SANDBOX_POLICY_EXPORT SandboxPolicyFuchsia {
  20. public:
  21. // Must be called on the IO thread.
  22. explicit SandboxPolicyFuchsia(sandbox::mojom::Sandbox type);
  23. ~SandboxPolicyFuchsia();
  24. SandboxPolicyFuchsia(const SandboxPolicyFuchsia&) = delete;
  25. SandboxPolicyFuchsia& operator=(const SandboxPolicyFuchsia&) = delete;
  26. // Modifies the process launch |options| to achieve the level of
  27. // isolation appropriate for current the sandbox type. The caller may then add
  28. // any descriptors or handles afterward to grant additional capabilities
  29. // to the new process.
  30. void UpdateLaunchOptionsForSandbox(base::LaunchOptions* options);
  31. private:
  32. sandbox::mojom::Sandbox type_;
  33. // Services directory used for the /svc namespace of the child process.
  34. base::SequenceBound<base::FilteredServiceDirectory>
  35. filtered_service_directory_;
  36. fidl::InterfaceHandle<::fuchsia::io::Directory> service_directory_client_;
  37. // Job in which the child process is launched.
  38. zx::job job_;
  39. };
  40. } // namespace policy
  41. } // namespace sandbox
  42. #endif // SANDBOX_POLICY_FUCHSIA_SANDBOX_POLICY_FUCHSIA_H_