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

Side by Side Diff: sandbox/mac/sandbox_compiler.cc

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 | « sandbox/mac/sandbox_compiler.h ('k') | sandbox/mac/sandbox_mac_compiler_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 #include "sandbox/mac/sandbox_compiler.h"
6
7 #include <map>
8 #include <string>
9 #include <vector>
10
11 #include "sandbox/mac/seatbelt.h"
12
13 namespace sandbox {
14
15 SandboxCompiler::SandboxCompiler(const std::string& profile_str)
16 : params_map_(), profile_str_(profile_str) {}
17
18 SandboxCompiler::~SandboxCompiler() {}
19
20 bool SandboxCompiler::InsertBooleanParam(const std::string& key, bool value) {
21 return params_map_.insert(std::make_pair(key, value ? "TRUE" : "FALSE"))
22 .second;
23 }
24
25 bool SandboxCompiler::InsertStringParam(const std::string& key,
26 const std::string& value) {
27 return params_map_.insert(std::make_pair(key, value)).second;
28 }
29
30 bool SandboxCompiler::CompileAndApplyProfile(std::string* error) {
31 char* error_internal = nullptr;
32 std::vector<const char*> params;
33
34 for (const auto& kv : params_map_) {
35 params.push_back(kv.first.c_str());
36 params.push_back(kv.second.c_str());
37 }
38 // The parameters array must be null terminated.
39 params.push_back(static_cast<const char*>(0));
40
41 if (sandbox::Seatbelt::InitWithParams(profile_str_.c_str(), 0, params.data(),
42 &error_internal)) {
43 error->assign(error_internal);
44 sandbox::Seatbelt::FreeError(error_internal);
45 return false;
46 }
47 return true;
48 }
49
50 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/mac/sandbox_compiler.h ('k') | sandbox/mac/sandbox_mac_compiler_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698