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

Side by Side Diff: content/common/sandbox_init_mac.cc

Issue 2102443002: [GN] content_unittests should depeng on //content/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mac Created 4 years, 5 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/public/common/content_client.h » ('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) 2011 The Chromium Authors. All rights reserved. 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 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_init_mac.h" 5 #include "content/common/sandbox_init_mac.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/common/sandbox_mac.h" 10 #include "content/common/sandbox_mac.h"
11 #include "content/public/common/content_switches.h" 11 #include "content/public/common/content_switches.h"
12 #include "content/public/common/sandbox_init.h" 12 #include "content/public/common/sandbox_init.h"
13 13
14 namespace content { 14 namespace content {
15 15 namespace {
16 bool InitializeSandbox(int sandbox_type, const base::FilePath& allowed_dir) {
17 // Warm up APIs before turning on the sandbox.
18 Sandbox::SandboxWarmup(sandbox_type);
19
20 // Actually sandbox the process.
21 return Sandbox::EnableSandbox(sandbox_type, allowed_dir);
22 }
23 16
24 // Fill in |sandbox_type| and |allowed_dir| based on the command line, returns 17 // Fill in |sandbox_type| and |allowed_dir| based on the command line, returns
25 // false if the current process type doesn't need to be sandboxed or if the 18 // false if the current process type doesn't need to be sandboxed or if the
26 // sandbox was disabled from the command line. 19 // sandbox was disabled from the command line.
27 bool GetSandboxTypeFromCommandLine(int* sandbox_type, 20 bool GetSandboxTypeFromCommandLine(int* sandbox_type,
28 base::FilePath* allowed_dir) { 21 base::FilePath* allowed_dir) {
29 DCHECK(sandbox_type); 22 DCHECK(sandbox_type);
30 DCHECK(allowed_dir); 23 DCHECK(allowed_dir);
31 24
32 *sandbox_type = -1; 25 *sandbox_type = -1;
(...skipping 26 matching lines...) Expand all
59 *sandbox_type = SANDBOX_TYPE_PPAPI; 52 *sandbox_type = SANDBOX_TYPE_PPAPI;
60 } else { 53 } else {
61 // This is a process which we don't know about, i.e. an embedder-defined 54 // This is a process which we don't know about, i.e. an embedder-defined
62 // process. If the embedder wants it sandboxed, they have a chance to return 55 // process. If the embedder wants it sandboxed, they have a chance to return
63 // the sandbox profile in ContentClient::GetSandboxProfileForSandboxType. 56 // the sandbox profile in ContentClient::GetSandboxProfileForSandboxType.
64 return false; 57 return false;
65 } 58 }
66 return true; 59 return true;
67 } 60 }
68 61
62 } // namespace
63
64 bool InitializeSandbox(int sandbox_type, const base::FilePath& allowed_dir) {
65 // Warm up APIs before turning on the sandbox.
66 Sandbox::SandboxWarmup(sandbox_type);
67
68 // Actually sandbox the process.
69 return Sandbox::EnableSandbox(sandbox_type, allowed_dir);
70 }
71
69 bool InitializeSandbox() { 72 bool InitializeSandbox() {
70 int sandbox_type = 0; 73 int sandbox_type = 0;
71 base::FilePath allowed_dir; 74 base::FilePath allowed_dir;
72 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir)) 75 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir))
73 return true; 76 return true;
74 return InitializeSandbox(sandbox_type, allowed_dir); 77 return InitializeSandbox(sandbox_type, allowed_dir);
75 } 78 }
76 79
77 } // namespace content 80 } // namespace content
OLDNEW
« no previous file with comments | « content/common/BUILD.gn ('k') | content/public/common/content_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698