Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / public / common / sandboxed_process_launcher_delegate.h
blob05acf5a6eefbed8baabbc24af41e445ae5a15222
1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_
6 #define CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_
8 #include "base/environment.h"
9 #include "base/files/scoped_file.h"
10 #include "base/process/process.h"
11 #include "content/common/content_export.h"
12 #include "content/public/common/sandbox_type.h"
14 namespace base {
15 class FilePath;
18 namespace sandbox {
19 class TargetPolicy;
22 namespace content {
24 // Allows a caller of StartSandboxedProcess or
25 // BrowserChildProcessHost/ChildProcessLauncher to control the sandbox policy,
26 // i.e. to loosen it if needed.
27 // The methods below will be called on the PROCESS_LAUNCHER thread.
28 class CONTENT_EXPORT SandboxedProcessLauncherDelegate {
29 public:
30 virtual ~SandboxedProcessLauncherDelegate() {}
32 #if defined(OS_WIN)
33 // Override to return true if the process should be launched as an elevated
34 // process (which implies no sandbox).
35 virtual bool ShouldLaunchElevated();
37 // By default, the process is launched sandboxed. Override this method to
38 // return false if the process should be launched without a sandbox
39 // (i.e. through base::LaunchProcess directly).
40 virtual bool ShouldSandbox();
42 // Called before the default sandbox is applied. If the default policy is too
43 // restrictive, the caller should set |disable_default_policy| to true and
44 // apply their policy in PreSpawnTarget. |exposed_dir| is used to allow a
45 //directory through the sandbox.
46 virtual void PreSandbox(bool* disable_default_policy,
47 base::FilePath* exposed_dir) {}
49 // Called right before spawning the process.
50 virtual void PreSpawnTarget(sandbox::TargetPolicy* policy,
51 bool* success) {}
53 // Called right after the process is launched, but before its thread is run.
54 virtual void PostSpawnTarget(base::ProcessHandle process) {}
56 #elif defined(OS_POSIX)
57 // Override this to return true to use the setuid sandbox.
58 virtual bool ShouldUseZygote();
60 // Override this if the process needs a non-empty environment map.
61 virtual base::EnvironmentMap GetEnvironment();
63 // Return the file descriptor for the IPC channel.
64 virtual base::ScopedFD TakeIpcFd() = 0;
65 #endif
67 // Returns the SandboxType to enforce on the process, or SANDBOX_TYPE_INVALID
68 // for no sandbox policy.
69 virtual SandboxType GetSandboxType();
72 } // namespace content
74 #endif // CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_