OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_COMMON_SANDBOX_INIT_WRAPPER_H_ | |
6 #define CONTENT_COMMON_SANDBOX_INIT_WRAPPER_H_ | |
7 #pragma once | |
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" | |
14 | |
15 #include <string> | |
16 | |
17 #include "base/basictypes.h" | |
18 #include "content/common/content_export.h" | |
19 | |
20 #if defined(OS_WIN) | |
21 #include "sandbox/src/sandbox.h" | |
22 #endif | |
23 | |
24 class CommandLine; | |
25 | |
26 #if defined(OS_WIN) | |
27 | |
28 class CONTENT_EXPORT SandboxInitWrapper { | |
29 public: | |
30 SandboxInitWrapper() : broker_services_(), target_services_() { } | |
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 | |
71 | |
72 #endif // CONTENT_COMMON_SANDBOX_INIT_WRAPPER_H_ | |
OLD | NEW |