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

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

Issue 2931173003: Implement the V2 sandbox in the process launcher. (Closed)
Patch Set: Created 3 years, 6 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) 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"
(...skipping 19 matching lines...) Expand all
30 DCHECK(sandbox_type); 30 DCHECK(sandbox_type);
31 DCHECK(allowed_dir); 31 DCHECK(allowed_dir);
32 32
33 *sandbox_type = -1; 33 *sandbox_type = -1;
34 *allowed_dir = base::FilePath(); // Empty by default. 34 *allowed_dir = base::FilePath(); // Empty by default.
35 35
36 const base::CommandLine& command_line = 36 const base::CommandLine& command_line =
37 *base::CommandLine::ForCurrentProcess(); 37 *base::CommandLine::ForCurrentProcess();
38 if (command_line.HasSwitch(switches::kNoSandbox)) 38 if (command_line.HasSwitch(switches::kNoSandbox))
39 return false; 39 return false;
40 if (command_line.HasSwitch(switches::kV2SandboxedEnabled)) 40 if (command_line.HasSwitch(switches::kV2SandboxedEnabled)) {
41 CHECK(sandbox::Seatbelt::IsSandboxed()); 41 CHECK(sandbox::Seatbelt::IsSandboxed());
42 // Do not enable the sandbox if V2 is already enabled.
43 return false;
44 }
42 45
43 std::string process_type = 46 std::string process_type =
44 command_line.GetSwitchValueASCII(switches::kProcessType); 47 command_line.GetSwitchValueASCII(switches::kProcessType);
45 if (process_type.empty()) { 48 if (process_type.empty()) {
46 // Browser process isn't sandboxed. 49 // Browser process isn't sandboxed.
47 return false; 50 return false;
48 } else if (process_type == switches::kRendererProcess) { 51 } else if (process_type == switches::kRendererProcess) {
49 *sandbox_type = SANDBOX_TYPE_RENDERER; 52 *sandbox_type = SANDBOX_TYPE_RENDERER;
50 } else if (process_type == switches::kUtilityProcess) { 53 } else if (process_type == switches::kUtilityProcess) {
51 // Utility process sandbox. 54 // Utility process sandbox.
(...skipping 19 matching lines...) Expand all
71 74
72 bool InitializeSandbox() { 75 bool InitializeSandbox() {
73 int sandbox_type = 0; 76 int sandbox_type = 0;
74 base::FilePath allowed_dir; 77 base::FilePath allowed_dir;
75 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir)) 78 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir))
76 return true; 79 return true;
77 return InitializeSandbox(sandbox_type, allowed_dir); 80 return InitializeSandbox(sandbox_type, allowed_dir);
78 } 81 }
79 82
80 } // namespace content 83 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698