OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CONTENT_COMMON_SANDBOX_INIT_WRAPPER_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_SANDBOX_INIT_H_ |
6 #define CONTENT_COMMON_SANDBOX_INIT_WRAPPER_H_ | 6 #define CONTENT_PUBLIC_COMMON_SANDBOX_INIT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // Wraps the sandbox initialization and platform variables to consolodate | |
10 // the code and reduce the number of platform ifdefs elsewhere. The POSIX | |
11 // version of this wrapper is basically empty. | |
12 | |
13 #include "build/build_config.h" | 9 #include "build/build_config.h" |
14 | |
15 #include <string> | |
16 | |
17 #include "base/basictypes.h" | |
18 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
19 | 11 |
20 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
21 #include "sandbox/src/sandbox.h" | 13 namespace sandbox { |
| 14 struct SandboxInterfaceInfo; |
| 15 } |
22 #endif | 16 #endif |
23 | 17 |
24 class CommandLine; | 18 namespace content { |
25 | 19 |
| 20 // Initialize the sandbox for renderer, gpu, utility, worker, nacl, and plug-in |
| 21 // processes, depending on the command line flags. Although The browser process |
| 22 // is not sandboxed, this also needs to be called because it will initialize |
| 23 // the broker code. |
| 24 // Returns true if the sandbox was initialized succesfully, false if an error |
| 25 // occurred. If process_type isn't one that needs sandboxing true is always |
| 26 // returned. |
26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
27 | 28 CONTENT_EXPORT bool InitializeSandbox( |
28 class CONTENT_EXPORT SandboxInitWrapper { | 29 sandbox::SandboxInterfaceInfo* sandbox_info); |
29 public: | 30 #elif defined(OS_MACOSX) |
30 SandboxInitWrapper() : broker_services_(), target_services_() { } | 31 CONTENT_EXPORT bool InitializeSandbox(); |
31 // SetServices() needs to be called before InitializeSandbox() on Win32 with | |
32 // the info received from the chrome exe main. | |
33 void SetServices(sandbox::SandboxInterfaceInfo* sandbox_info); | |
34 sandbox::BrokerServices* BrokerServices() const { return broker_services_; } | |
35 sandbox::TargetServices* TargetServices() const { return target_services_; } | |
36 | |
37 // Initialize the sandbox for renderer, gpu, utility, worker, nacl, and | |
38 // plug-in processes, depending on the command line flags. The browser | |
39 // process is not sandboxed. | |
40 // Returns true if the sandbox was initialized succesfully, false if an error | |
41 // occurred. If process_type isn't one that needs sandboxing true is always | |
42 // returned. | |
43 bool InitializeSandbox(const CommandLine& parsed_command_line, | |
44 const std::string& process_type); | |
45 private: | |
46 sandbox::BrokerServices* broker_services_; | |
47 sandbox::TargetServices* target_services_; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(SandboxInitWrapper); | |
50 }; | |
51 | |
52 #elif defined(OS_POSIX) | |
53 | |
54 class SandboxInitWrapper { | |
55 public: | |
56 SandboxInitWrapper() { } | |
57 | |
58 // Initialize the sandbox for renderer and plug-in processes, depending on | |
59 // the command line flags. The browser process is not sandboxed. | |
60 // Returns true if the sandbox was initialized succesfully, false if an error | |
61 // occurred. If process_type isn't one that needs sandboxing true is always | |
62 // returned. | |
63 bool InitializeSandbox(const CommandLine& parsed_command_line, | |
64 const std::string& process_type); | |
65 | |
66 private: | |
67 DISALLOW_COPY_AND_ASSIGN(SandboxInitWrapper); | |
68 }; | |
69 | |
70 #endif | 32 #endif |
71 | 33 |
72 #endif // CONTENT_COMMON_SANDBOX_INIT_WRAPPER_H_ | 34 } // namespace content |
| 35 |
| 36 #endif // CONTENT_PUBLIC_COMMON_SANDBOX_INIT_H_ |
OLD | NEW |