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

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

Issue 8414020: Expose the sandbox related code through the content API. I did a bit of cleanup while I was doing... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/common/sandbox_init_wrapper.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "content/public/common/content_switches.h"
10
11 void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) {
12 if (!info)
13 return;
14 if (info->legacy) {
15 // Looks like we are in the case when the new chrome.dll is being launched
16 // by the old chrome.exe, the old chrome exe has SandboxInterfaceInfo as a
17 // union, while now we have a struct.
18 // TODO(cpu): Remove this nasty hack after M10 release.
19 broker_services_ = reinterpret_cast<sandbox::BrokerServices*>(info->legacy);
20 target_services_ = reinterpret_cast<sandbox::TargetServices*>(info->legacy);
21 } else {
22 // Normal case, both the exe and the dll are the same version. Both
23 // interface pointers cannot be non-zero. A process can either be a target
24 // or a broker but not both.
25 broker_services_ = info->broker_services;
26 target_services_ = info->target_services;
27 DCHECK(!(target_services_ && broker_services_));
28 }
29 }
30
31 bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line,
32 const std::string& process_type) {
33 if (command_line.HasSwitch(switches::kNoSandbox))
34 return true;
35 if ((process_type == switches::kRendererProcess) ||
36 (process_type == switches::kWorkerProcess) ||
37 (process_type == switches::kNaClLoaderProcess) ||
38 (process_type == switches::kUtilityProcess)) {
39 // The above five process types must be sandboxed unless --no-sandbox
40 // is present in the command line.
41 if (!target_services_)
42 return false;
43 } else {
44 // Other process types might or might not be sandboxed.
45 // TODO(cpu): clean this mess.
46 if (!target_services_)
47 return true;
48 }
49 return (sandbox::SBOX_ALL_OK == target_services_->Init());
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698