Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: content/common/sandbox_mac.h

Issue 2686433002: Move SandboxCompiler class into the sandbox library. (Closed)
Patch Set: Try getting rid of sysctl-read Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/common/sandbox_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_MAC_H_ 5 #ifndef CONTENT_COMMON_SANDBOX_MAC_H_
6 #define CONTENT_COMMON_SANDBOX_MAC_H_ 6 #define CONTENT_COMMON_SANDBOX_MAC_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/public/common/sandbox_type.h" 15 #include "content/public/common/sandbox_type.h"
16 16
17 namespace base { 17 namespace base {
18 class FilePath; 18 class FilePath;
19 } 19 }
20 20
21 namespace content { 21 namespace content {
22 22
23 // This class wraps the C-style sandbox APIs in a class to ensure proper
24 // initialization and cleanup.
25 class CONTENT_EXPORT SandboxCompiler {
26 public:
27 explicit SandboxCompiler(const std::string& profile_str);
28
29 ~SandboxCompiler();
30
31 // Inserts a boolean into the parameters key/value map. A duplicate key is not
32 // allowed, and will cause the function to return false. The value is not
33 // inserted in this case.
34 bool InsertBooleanParam(const std::string& key, bool value);
35
36 // Inserts a string into the parameters key/value map. A duplicate key is not
37 // allowed, and will cause the function to return false. The value is not
38 // inserted in this case.
39 bool InsertStringParam(const std::string& key, const std::string& value);
40
41 // Compiles and applies the profile; returns true on success.
42 bool CompileAndApplyProfile(std::string* error);
43
44 private:
45 // Storage of the key/value pairs of strings that are used in the sandbox
46 // profile.
47 std::map<std::string, std::string> params_map_;
48
49 // The sandbox profile source code.
50 const std::string profile_str_;
51
52 DISALLOW_COPY_AND_ASSIGN(SandboxCompiler);
53 };
54
55 class CONTENT_EXPORT Sandbox { 23 class CONTENT_EXPORT Sandbox {
56 public: 24 public:
57 25
58 // Warm up System APIs that empirically need to be accessed before the 26 // Warm up System APIs that empirically need to be accessed before the
59 // sandbox is turned on. |sandbox_type| is the type of sandbox to warm up. 27 // sandbox is turned on. |sandbox_type| is the type of sandbox to warm up.
60 // Valid |sandbox_type| values are defined by the enum SandboxType, or can be 28 // Valid |sandbox_type| values are defined by the enum SandboxType, or can be
61 // defined by the embedder via 29 // defined by the embedder via
62 // ContentClient::GetSandboxProfileForProcessType(). 30 // ContentClient::GetSandboxProfileForProcessType().
63 static void SandboxWarmup(int sandbox_type); 31 static void SandboxWarmup(int sandbox_type);
64 32
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, StringEscape); 72 FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, StringEscape);
105 FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, RegexEscape); 73 FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, RegexEscape);
106 FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, SandboxAccess); 74 FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, SandboxAccess);
107 75
108 DISALLOW_IMPLICIT_CONSTRUCTORS(Sandbox); 76 DISALLOW_IMPLICIT_CONSTRUCTORS(Sandbox);
109 }; 77 };
110 78
111 } // namespace content 79 } // namespace content
112 80
113 #endif // CONTENT_COMMON_SANDBOX_MAC_H_ 81 #endif // CONTENT_COMMON_SANDBOX_MAC_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/sandbox_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698