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

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

Issue 12805004: Remove mention of the nacl process in content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 | « content/browser/worker_host/worker_process_host.cc ('k') | content/common/sandbox_policy.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/public/common/sandbox_init.h" 5 #include "content/public/common/sandbox_init.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 #include "content/common/sandbox_policy.h" 9 #include "content/common/sandbox_win.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
11 #include "sandbox/win/src/sandbox.h" 11 #include "sandbox/win/src/sandbox.h"
12 #include "sandbox/win/src/sandbox_types.h" 12 #include "sandbox/win/src/sandbox_types.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 bool InitializeSandbox(sandbox::SandboxInterfaceInfo* sandbox_info) { 16 bool InitializeSandbox(sandbox::SandboxInterfaceInfo* sandbox_info) {
17 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 17 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
18 std::string process_type = 18 std::string process_type =
19 command_line.GetSwitchValueASCII(switches::kProcessType); 19 command_line.GetSwitchValueASCII(switches::kProcessType);
20 sandbox::BrokerServices* broker_services = sandbox_info->broker_services; 20 sandbox::BrokerServices* broker_services = sandbox_info->broker_services;
21 if (broker_services && !InitBrokerServices(broker_services)) 21 if (broker_services) {
22 return false; 22 if (!InitBrokerServices(broker_services))
23 return false;
23 24
24 if (process_type.empty() || process_type == switches::kNaClBrokerProcess) {
25 // IMPORTANT: This piece of code needs to run as early as possible in the 25 // IMPORTANT: This piece of code needs to run as early as possible in the
26 // process because it will initialize the sandbox broker, which requires the 26 // process because it will initialize the sandbox broker, which requires the
27 // process to swap its window station. During this time all the UI will be 27 // process to swap its window station. During this time all the UI will be
28 // broken. This has to run before threads and windows are created. 28 // broken. This has to run before threads and windows are created.
29 if (broker_services) { 29 if (!command_line.HasSwitch(switches::kNoSandbox)) {
30 if (!command_line.HasSwitch(switches::kNoSandbox)) { 30 bool use_winsta = !command_line.HasSwitch(
31 bool use_winsta = !command_line.HasSwitch( 31 switches::kDisableAltWinstation);
32 switches::kDisableAltWinstation); 32 // Precreate the desktop and window station used by the renderers.
33 // Precreate the desktop and window station used by the renderers. 33 sandbox::TargetPolicy* policy = broker_services->CreatePolicy();
34 sandbox::TargetPolicy* policy = broker_services->CreatePolicy(); 34 sandbox::ResultCode result = policy->CreateAlternateDesktop(use_winsta);
35 sandbox::ResultCode result = policy->CreateAlternateDesktop(use_winsta); 35 CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result);
36 CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result); 36 policy->Release();
37 policy->Release();
38 }
39 } 37 }
40 return true; 38 return true;
41 } 39 }
42 40
43 if (command_line.HasSwitch(switches::kNoSandbox)) 41 if (command_line.HasSwitch(switches::kNoSandbox))
44 return true; 42 return true;
45 43
46 sandbox::TargetServices* target_services = sandbox_info->target_services; 44 sandbox::TargetServices* target_services = sandbox_info->target_services;
47 if ((process_type == switches::kRendererProcess) ||
48 (process_type == switches::kWorkerProcess) ||
49 (process_type == switches::kNaClLoaderProcess) ||
50 (process_type == switches::kUtilityProcess)) {
51 // The above five process types must be sandboxed unless --no-sandbox
52 // is present in the command line.
53 if (!target_services)
54 return false;
55 } else {
56 // Other process types might or might not be sandboxed.
57 // TODO(cpu): clean this mess.
58 if (!target_services)
59 return true;
60 }
61 return InitTargetServices(target_services); 45 return InitTargetServices(target_services);
62 } 46 }
63 47
64 } // namespace content 48 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/worker_host/worker_process_host.cc ('k') | content/common/sandbox_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698