linux_aura: Disable the plugin install infobar.
[chromium-blink-merge.git] / content / public / common / sandbox_init.h
blob313662da0b016c46f03cf4983d44bd113ce466a0
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_SANDBOX_INIT_H_
6 #define CONTENT_PUBLIC_COMMON_SANDBOX_INIT_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/process/process.h"
10 #include "build/build_config.h"
11 #include "content/common/content_export.h"
13 namespace base {
14 class CommandLine;
15 class FilePath;
18 namespace sandbox {
19 class SandboxBPFPolicy;
20 struct SandboxInterfaceInfo;
23 namespace content {
24 class SandboxedProcessLauncherDelegate;
26 #if defined(OS_WIN)
28 // Initialize the sandbox for renderer, gpu, utility, worker, nacl, and plug-in
29 // processes, depending on the command line flags. Although The browser process
30 // is not sandboxed, this also needs to be called because it will initialize
31 // the broker code.
32 // Returns true if the sandbox was initialized succesfully, false if an error
33 // occurred. If process_type isn't one that needs sandboxing true is always
34 // returned.
35 CONTENT_EXPORT bool InitializeSandbox(
36 sandbox::SandboxInterfaceInfo* sandbox_info);
38 // This is a restricted version of Windows' DuplicateHandle() function
39 // that works inside the sandbox and can send handles but not retrieve
40 // them. Unlike DuplicateHandle(), it takes a process ID rather than
41 // a process handle. It returns true on success, false otherwise.
42 CONTENT_EXPORT bool BrokerDuplicateHandle(HANDLE source_handle,
43 DWORD target_process_id,
44 HANDLE* target_handle,
45 DWORD desired_access,
46 DWORD options);
48 // Inform the current process's sandbox broker (e.g. the broker for
49 // 32-bit processes) about a process created under a different sandbox
50 // broker (e.g. the broker for 64-bit processes). This allows
51 // BrokerDuplicateHandle() to send handles to a process managed by
52 // another broker. For example, it allows the 32-bit renderer to send
53 // handles to 64-bit NaCl processes. This returns true on success,
54 // false otherwise.
55 CONTENT_EXPORT bool BrokerAddTargetPeer(HANDLE peer_process);
57 // Launch a sandboxed process. |delegate| may be NULL. If |delegate| is non-NULL
58 // then it just has to outlive this method call.
59 CONTENT_EXPORT base::ProcessHandle StartSandboxedProcess(
60 SandboxedProcessLauncherDelegate* delegate,
61 base::CommandLine* cmd_line);
63 #elif defined(OS_MACOSX)
65 // Initialize the sandbox of the given |sandbox_type|, optionally specifying a
66 // directory to allow access to. Note specifying a directory needs to be
67 // supported by the sandbox profile associated with the given |sandbox_type|.
68 // Valid values for |sandbox_type| are defined either by the enum SandboxType,
69 // or by ContentClient::GetSandboxProfileForSandboxType().
71 // If the |sandbox_type| isn't one of the ones defined by content then the
72 // embedder is queried using ContentClient::GetSandboxPolicyForSandboxType().
73 // The embedder can use values for |sandbox_type| starting from
74 // sandbox::SANDBOX_PROCESS_TYPE_AFTER_LAST_TYPE.
76 // Returns true if the sandbox was initialized succesfully, false if an error
77 // occurred. If process_type isn't one that needs sandboxing, no action is
78 // taken and true is always returned.
79 CONTENT_EXPORT bool InitializeSandbox(int sandbox_type,
80 const base::FilePath& allowed_path);
82 #elif defined(OS_LINUX)
84 class SandboxInitializerDelegate;
86 // Initialize a seccomp-bpf sandbox. |policy| may not be NULL.
87 // Returns true if the sandbox has been properly engaged.
88 CONTENT_EXPORT bool InitializeSandbox(
89 scoped_ptr<sandbox::SandboxBPFPolicy> policy);
91 // Return a "baseline" policy. This is used by a SandboxInitializerDelegate to
92 // implement a policy that is derived from the baseline.
93 CONTENT_EXPORT scoped_ptr<sandbox::SandboxBPFPolicy>
94 GetBPFSandboxBaselinePolicy();
95 #endif // defined(OS_LINUX)
97 } // namespace content
99 #endif // CONTENT_PUBLIC_COMMON_SANDBOX_INIT_H_