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

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
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" { 12 extern "C" {
13 #include <sandbox.h> 13 #include <sandbox.h>
Robert Sesek 2016/04/05 14:13:25 Remove now?
Greg K 2016/04/05 18:24:44 Done.
14 } 14 }
15 #include <signal.h> 15 #include <signal.h>
16 #include <sys/param.h> 16 #include <sys/param.h>
17 17
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/compiler_specific.h" 19 #include "base/compiler_specific.h"
20 #include "base/files/file_util.h" 20 #include "base/files/file_util.h"
21 #include "base/files/scoped_file.h" 21 #include "base/files/scoped_file.h"
22 #include "base/mac/bundle_locations.h" 22 #include "base/mac/bundle_locations.h"
23 #include "base/mac/foundation_util.h" 23 #include "base/mac/foundation_util.h"
24 #include "base/mac/mac_util.h" 24 #include "base/mac/mac_util.h"
25 #include "base/mac/scoped_cftyperef.h" 25 #include "base/mac/scoped_cftyperef.h"
26 #include "base/mac/scoped_nsautorelease_pool.h" 26 #include "base/mac/scoped_nsautorelease_pool.h"
27 #include "base/mac/scoped_nsobject.h" 27 #include "base/mac/scoped_nsobject.h"
28 #include "base/macros.h" 28 #include "base/macros.h"
29 #include "base/rand_util.h" 29 #include "base/rand_util.h"
30 #include "base/strings/string16.h" 30 #include "base/strings/string16.h"
31 #include "base/strings/string_piece.h" 31 #include "base/strings/string_piece.h"
32 #include "base/strings/string_split.h" 32 #include "base/strings/string_split.h"
33 #include "base/strings/string_util.h" 33 #include "base/strings/string_util.h"
34 #include "base/strings/stringprintf.h" 34 #include "base/strings/stringprintf.h"
35 #include "base/strings/sys_string_conversions.h" 35 #include "base/strings/sys_string_conversions.h"
36 #include "base/strings/utf_string_conversions.h" 36 #include "base/strings/utf_string_conversions.h"
37 #include "base/sys_info.h" 37 #include "base/sys_info.h"
38 #include "content/common/gpu/media/vt_video_decode_accelerator_mac.h" 38 #include "content/common/gpu/media/vt_video_decode_accelerator_mac.h"
39 #include "content/grit/content_resources.h" 39 #include "content/grit/content_resources.h"
40 #include "content/public/common/content_client.h" 40 #include "content/public/common/content_client.h"
41 #include "content/public/common/content_switches.h" 41 #include "content/public/common/content_switches.h"
42 #include "sandbox/mac/seatbelt.h"
42 #include "third_party/icu/source/common/unicode/uchar.h" 43 #include "third_party/icu/source/common/unicode/uchar.h"
43 #include "ui/base/layout.h" 44 #include "ui/base/layout.h"
44 #include "ui/gl/gl_surface.h" 45 #include "ui/gl/gl_surface.h"
45 46
46 extern "C" { 47 extern "C" {
47 void CGSSetDenyWindowServerConnections(bool); 48 void CGSSetDenyWindowServerConnections(bool);
48 void CGSShutdownServerConnections(); 49 void CGSShutdownServerConnections();
49 50
50 int sandbox_init_with_parameters(const char* profile, 51 int sandbox_init_with_parameters(const char* profile,
Robert Sesek 2016/04/05 14:13:25 Might as well wrap this one, too.
Greg K 2016/04/05 18:24:44 Done.
51 uint64_t flags, 52 uint64_t flags,
52 const char* const parameters[], 53 const char* const parameters[],
53 char** errorbuf); 54 char** errorbuf);
54 }; 55 };
55 56
56 namespace content { 57 namespace content {
57 namespace { 58 namespace {
58 59
59 // Is the sandbox currently active. 60 // Is the sandbox currently active.
60 bool gSandboxIsActive = false; 61 bool gSandboxIsActive = false;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 for (const auto& kv : params_map_) { 149 for (const auto& kv : params_map_) {
149 params.push_back(kv.first.c_str()); 150 params.push_back(kv.first.c_str());
150 params.push_back(kv.second.c_str()); 151 params.push_back(kv.second.c_str());
151 } 152 }
152 // The parameters array must be null terminated. 153 // The parameters array must be null terminated.
153 params.push_back(static_cast<const char*>(0)); 154 params.push_back(static_cast<const char*>(0));
154 155
155 if (sandbox_init_with_parameters(profile_str_.c_str(), 0, params.data(), 156 if (sandbox_init_with_parameters(profile_str_.c_str(), 0, params.data(),
156 &error_internal)) { 157 &error_internal)) {
157 error->assign(error_internal); 158 error->assign(error_internal);
158 #pragma clang diagnostic push 159 sandbox::Seatbelt::sandbox_free_error(error_internal);
159 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
160 sandbox_free_error(error_internal);
161 #pragma clang diagnostic pop
162 return false; 160 return false;
163 } 161 }
164 return true; 162 return true;
165 } 163 }
166 164
167 // static 165 // static
168 bool Sandbox::QuotePlainString(const std::string& src_utf8, std::string* dst) { 166 bool Sandbox::QuotePlainString(const std::string& src_utf8, std::string* dst) {
169 dst->clear(); 167 dst->clear();
170 168
171 const char* src = src_utf8.c_str(); 169 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) { 525 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) {
528 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " 526 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: "
529 << path.value(); 527 << path.value();
530 return path; 528 return path;
531 } 529 }
532 530
533 return base::FilePath(canonical_path); 531 return base::FilePath(canonical_path);
534 } 532 }
535 533
536 } // namespace content 534 } // namespace content
OLDNEW
« no previous file with comments | « content/common/BUILD.gn ('k') | content/content_common.gypi » ('j') | ipc/DEPS » ('J')

Powered by Google App Engine
This is Rietveld 408576698