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

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

Issue 1855303003: Wrap deprecated sandbox functions in C++ class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « content/common/BUILD.gn ('k') | content/content_common.gypi » ('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 #include "content/common/sandbox_mac.h" 5 #include "content/common/sandbox_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <CoreFoundation/CFTimeZone.h> 11 #include <CoreFoundation/CFTimeZone.h>
12 extern "C" {
13 #include <sandbox.h>
14 }
15 #include <signal.h> 12 #include <signal.h>
16 #include <sys/param.h> 13 #include <sys/param.h>
17 14
18 #include "base/command_line.h" 15 #include "base/command_line.h"
19 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
20 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
21 #include "base/files/scoped_file.h" 18 #include "base/files/scoped_file.h"
22 #include "base/mac/bundle_locations.h" 19 #include "base/mac/bundle_locations.h"
23 #include "base/mac/foundation_util.h" 20 #include "base/mac/foundation_util.h"
24 #include "base/mac/mac_util.h" 21 #include "base/mac/mac_util.h"
25 #include "base/mac/scoped_cftyperef.h" 22 #include "base/mac/scoped_cftyperef.h"
26 #include "base/mac/scoped_nsautorelease_pool.h" 23 #include "base/mac/scoped_nsautorelease_pool.h"
27 #include "base/mac/scoped_nsobject.h" 24 #include "base/mac/scoped_nsobject.h"
28 #include "base/macros.h" 25 #include "base/macros.h"
29 #include "base/rand_util.h" 26 #include "base/rand_util.h"
30 #include "base/strings/string16.h" 27 #include "base/strings/string16.h"
31 #include "base/strings/string_piece.h" 28 #include "base/strings/string_piece.h"
32 #include "base/strings/string_split.h" 29 #include "base/strings/string_split.h"
33 #include "base/strings/string_util.h" 30 #include "base/strings/string_util.h"
34 #include "base/strings/stringprintf.h" 31 #include "base/strings/stringprintf.h"
35 #include "base/strings/sys_string_conversions.h" 32 #include "base/strings/sys_string_conversions.h"
36 #include "base/strings/utf_string_conversions.h" 33 #include "base/strings/utf_string_conversions.h"
37 #include "base/sys_info.h" 34 #include "base/sys_info.h"
38 #include "content/common/gpu/media/vt_video_decode_accelerator_mac.h" 35 #include "content/common/gpu/media/vt_video_decode_accelerator_mac.h"
39 #include "content/grit/content_resources.h" 36 #include "content/grit/content_resources.h"
40 #include "content/public/common/content_client.h" 37 #include "content/public/common/content_client.h"
41 #include "content/public/common/content_switches.h" 38 #include "content/public/common/content_switches.h"
39 #include "sandbox/mac/seatbelt.h"
42 #include "third_party/icu/source/common/unicode/uchar.h" 40 #include "third_party/icu/source/common/unicode/uchar.h"
43 #include "ui/base/layout.h" 41 #include "ui/base/layout.h"
44 #include "ui/gl/gl_surface.h" 42 #include "ui/gl/gl_surface.h"
45 43
46 extern "C" { 44 extern "C" {
47 void CGSSetDenyWindowServerConnections(bool); 45 void CGSSetDenyWindowServerConnections(bool);
48 void CGSShutdownServerConnections(); 46 void CGSShutdownServerConnections();
49
50 int sandbox_init_with_parameters(const char* profile,
51 uint64_t flags,
52 const char* const parameters[],
53 char** errorbuf);
54 }; 47 };
55 48
56 namespace content { 49 namespace content {
57 namespace { 50 namespace {
58 51
59 // Is the sandbox currently active. 52 // Is the sandbox currently active.
60 bool gSandboxIsActive = false; 53 bool gSandboxIsActive = false;
61 54
62 struct SandboxTypeToResourceIDMapping { 55 struct SandboxTypeToResourceIDMapping {
63 SandboxType sandbox_type; 56 SandboxType sandbox_type;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 char* error_internal = nullptr; 138 char* error_internal = nullptr;
146 std::vector<const char*> params; 139 std::vector<const char*> params;
147 140
148 for (const auto& kv : params_map_) { 141 for (const auto& kv : params_map_) {
149 params.push_back(kv.first.c_str()); 142 params.push_back(kv.first.c_str());
150 params.push_back(kv.second.c_str()); 143 params.push_back(kv.second.c_str());
151 } 144 }
152 // The parameters array must be null terminated. 145 // The parameters array must be null terminated.
153 params.push_back(static_cast<const char*>(0)); 146 params.push_back(static_cast<const char*>(0));
154 147
155 if (sandbox_init_with_parameters(profile_str_.c_str(), 0, params.data(), 148 if (sandbox::Seatbelt::InitWithParams(profile_str_.c_str(), 0, params.data(),
156 &error_internal)) { 149 &error_internal)) {
157 error->assign(error_internal); 150 error->assign(error_internal);
158 #pragma clang diagnostic push 151 sandbox::Seatbelt::FreeError(error_internal);
159 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
160 sandbox_free_error(error_internal);
161 #pragma clang diagnostic pop
162 return false; 152 return false;
163 } 153 }
164 return true; 154 return true;
165 } 155 }
166 156
167 // static 157 // static
168 bool Sandbox::QuotePlainString(const std::string& src_utf8, std::string* dst) { 158 bool Sandbox::QuotePlainString(const std::string& src_utf8, std::string* dst) {
169 dst->clear(); 159 dst->clear();
170 160
171 const char* src = src_utf8.c_str(); 161 const char* src = src_utf8.c_str();
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) { 517 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) {
528 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " 518 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: "
529 << path.value(); 519 << path.value();
530 return path; 520 return path;
531 } 521 }
532 522
533 return base::FilePath(canonical_path); 523 return base::FilePath(canonical_path);
534 } 524 }
535 525
536 } // namespace content 526 } // namespace content
OLDNEW
« no previous file with comments | « content/common/BUILD.gn ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698