summaryrefslogtreecommitdiffstats
path: root/chromium/content/browser/utility_sandbox_delegate.h
blob: 13a23f33f472f2ff258553c3fb686701f911a0e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_UTILITY_SANDBOX_DELEGATE_H_
#define CONTENT_BROWSER_UTILITY_SANDBOX_DELEGATE_H_

#include "base/command_line.h"
#include "base/environment.h"
#include "build/build_config.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "content/public/common/zygote/zygote_buildflags.h"
#include "sandbox/policy/sandbox_type.h"

#if BUILDFLAG(USE_ZYGOTE_HANDLE)
#include "content/common/zygote/zygote_handle_impl_linux.h"
#endif  // BUILDFLAG(USE_ZYGOTE_HANDLE)

#if defined(OS_WIN)
#include "sandbox/win/src/sandbox_policy.h"
#endif  // OS_WIN

namespace content {
class UtilitySandboxedProcessLauncherDelegate
    : public SandboxedProcessLauncherDelegate {
 public:
  UtilitySandboxedProcessLauncherDelegate(
      sandbox::policy::SandboxType sandbox_type,
      const base::EnvironmentMap& env,
      const base::CommandLine& cmd_line);
  ~UtilitySandboxedProcessLauncherDelegate() override;

  sandbox::policy::SandboxType GetSandboxType() override;

#if defined(OS_WIN)
  bool GetAppContainerId(std::string* appcontainer_id) override;
  bool DisableDefaultPolicy() override;
  bool ShouldLaunchElevated() override;
  bool PreSpawnTarget(sandbox::TargetPolicy* policy) override;
#endif  // OS_WIN

#if BUILDFLAG(USE_ZYGOTE_HANDLE)
  ZygoteHandle GetZygote() override;
#endif  // BUILDFLAG(USE_ZYGOTE_HANDLE)

#if defined(OS_POSIX)
  base::EnvironmentMap GetEnvironment() override;
#endif  // OS_POSIX

#if defined(OS_MAC) && defined(ARCH_CPU_ARM64)
  // If true, the child process will be launched as x86_64 code under Rosetta
  // translation.
  void set_launch_x86_64(bool launch_x86_64) { launch_x86_64_ = launch_x86_64; }
  bool LaunchX86_64() override;
#endif  // OS_MAC && ARCH_CPU_ARM64

 private:
#if defined(OS_POSIX)
  base::EnvironmentMap env_;
#endif  // OS_POSIX
  sandbox::policy::SandboxType sandbox_type_;
  base::CommandLine cmd_line_;
#if defined(OS_MAC) && defined(ARCH_CPU_ARM64)
  bool launch_x86_64_ = false;
#endif  // OS_MAC && ARCH_CPU_ARM64
};
}  // namespace content

#endif  // CONTENT_BROWSER_UTILITY_SANDBOX_DELEGATE_H_