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

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

Issue 6598019: Merge 76108 - Make SandboxInterfaceInfo somewhat backwards compatible... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/648/src/
Patch Set: Created 9 years, 9 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 | « no previous file | 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) 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 "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" 8 #include "base/logging.h"
9 9
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 11
12 void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) { 12 void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) {
13 if (info) { 13 if (!info)
14 return;
15 if (info->legacy) {
16 // Looks like we are in the case when the new chrome.dll is being launched
17 // by the old chrome.exe, the old chrome exe has SandboxInterfaceInfo as a
18 // union, while now we have a struct.
19 // TODO(cpu): Remove this nasty hack after M10 release.
20 broker_services_ = reinterpret_cast<sandbox::BrokerServices*>(info->legacy);
21 target_services_ = reinterpret_cast<sandbox::TargetServices*>(info->legacy);
22 } else {
23 // Normal case, both the exe and the dll are the same version. Both
24 // interface pointers cannot be non-zero. A process can either be a target
25 // or a broker but not both.
14 broker_services_ = info->broker_services; 26 broker_services_ = info->broker_services;
15 target_services_ = info->target_services; 27 target_services_ = info->target_services;
28 DCHECK(!(target_services_ && broker_services_));
16 } 29 }
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_));
20 } 30 }
21 31
22 bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, 32 bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line,
23 const std::string& process_type) { 33 const std::string& process_type) {
24 if (command_line.HasSwitch(switches::kNoSandbox)) 34 if (command_line.HasSwitch(switches::kNoSandbox))
25 return true; 35 return true;
26 if ((process_type == switches::kRendererProcess) || 36 if ((process_type == switches::kRendererProcess) ||
27 (process_type == switches::kExtensionProcess) || 37 (process_type == switches::kExtensionProcess) ||
28 (process_type == switches::kWorkerProcess) || 38 (process_type == switches::kWorkerProcess) ||
29 (process_type == switches::kNaClLoaderProcess) || 39 (process_type == switches::kNaClLoaderProcess) ||
30 (process_type == switches::kUtilityProcess)) { 40 (process_type == switches::kUtilityProcess)) {
31 // The above five process types must be sandboxed unless --no-sandbox 41 // The above five process types must be sandboxed unless --no-sandbox
32 // is present in the command line. 42 // is present in the command line.
33 if (!target_services_) 43 if (!target_services_)
34 return false; 44 return false;
35 } else { 45 } else {
36 // Other process types might or might not be sandboxed. 46 // Other process types might or might not be sandboxed.
37 // TODO(cpu): clean this mess. 47 // TODO(cpu): clean this mess.
38 if (!target_services_) 48 if (!target_services_)
39 return true; 49 return true;
40 } 50 }
41 return (sandbox::SBOX_ALL_OK == target_services_->Init()); 51 return (sandbox::SBOX_ALL_OK == target_services_->Init());
42 } 52 }
OLDNEW
« no previous file with comments | « no previous file | sandbox/src/sandbox_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698