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

Side by Side Diff: chrome/common/sandbox_init_wrapper_win.cc

Issue 6549027: Merge 74514 - Use a struct instead of a union for SandboxInterfaceInfo... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/648/src/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/app/client_util.h ('k') | sandbox/src/sandbox_types.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) 2009 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 "chrome/common/sandbox_init_wrapper.h" 5 #include "chrome/common/sandbox_init_wrapper.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h"
9
8 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
9 11
10 void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) { 12 void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) {
11 if (info) { 13 if (info) {
12 broker_services_ = info->broker_services; 14 broker_services_ = info->broker_services;
13 target_services_ = info->target_services; 15 target_services_ = info->target_services;
14 } 16 }
17 // Both interface pointers cannot be non-zero. A process can either
18 // be a target or a broker but not both.
19 DCHECK(!(target_services_ && broker_services_));
15 } 20 }
16 21
17 bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, 22 bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line,
18 const std::string& process_type) { 23 const std::string& process_type) {
19 if (command_line.HasSwitch(switches::kNoSandbox)) 24 if (command_line.HasSwitch(switches::kNoSandbox))
20 return true; 25 return true;
21 if ((process_type == switches::kRendererProcess) || 26 if ((process_type == switches::kRendererProcess) ||
22 (process_type == switches::kExtensionProcess) || 27 (process_type == switches::kExtensionProcess) ||
23 (process_type == switches::kWorkerProcess) || 28 (process_type == switches::kWorkerProcess) ||
24 (process_type == switches::kNaClLoaderProcess) || 29 (process_type == switches::kNaClLoaderProcess) ||
25 (process_type == switches::kUtilityProcess) || 30 (process_type == switches::kUtilityProcess)) {
26 (process_type == switches::kPluginProcess && 31 // The above five process types must be sandboxed unless --no-sandbox
27 command_line.HasSwitch(switches::kSafePlugins))) { 32 // is present in the command line.
28 if (!target_services_) 33 if (!target_services_)
29 return false; 34 return false;
30 target_services_->Init(); 35 } else {
36 // Other process types might or might not be sandboxed.
37 // TODO(cpu): clean this mess.
38 if (!target_services_)
39 return true;
31 } 40 }
32 return true; 41 return (sandbox::SBOX_ALL_OK == target_services_->Init());
33 } 42 }
OLDNEW
« no previous file with comments | « chrome/app/client_util.h ('k') | sandbox/src/sandbox_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698