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

Side by Side Diff: content/browser/browser_main.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
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/browser/browser_main.h" 5 #include "content/browser/browser_main.h"
6 6
7 #include "base/allocator/allocator_shim.h" 7 #include "base/allocator/allocator_shim.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "content/browser/browser_main_loop.h" 12 #include "content/browser/browser_main_loop.h"
13 #include "content/browser/notification_service_impl.h" 13 #include "content/browser/notification_service_impl.h"
14 #include "content/common/main_function_params.h" 14 #include "content/common/main_function_params.h"
15 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
16 16
17 #if defined(OS_WIN) 17 #if defined(OS_WIN)
18 #include "base/win/scoped_com_initializer.h" 18 #include "base/win/scoped_com_initializer.h"
19 #include "content/common/sandbox_policy.h"
20 #include "sandbox/src/sandbox.h"
21 #endif 19 #endif
22 20
23 namespace { 21 namespace {
24 22
25 #if defined(OS_WIN)
26 // Windows-specific initialization code for the sandbox broker services.
27 void InitializeBrokerServices(const MainFunctionParams& parameters,
28 const CommandLine& parsed_command_line) {
29 sandbox::BrokerServices* broker_services =
30 parameters.sandbox_info_.BrokerServices();
31 if (broker_services) {
32 sandbox::InitBrokerServices(broker_services);
33 if (!parsed_command_line.HasSwitch(switches::kNoSandbox)) {
34 bool use_winsta = !parsed_command_line.HasSwitch(
35 switches::kDisableAltWinstation);
36 // Precreate the desktop and window station used by the renderers.
37 sandbox::TargetPolicy* policy = broker_services->CreatePolicy();
38 sandbox::ResultCode result = policy->CreateAlternateDesktop(use_winsta);
39 CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result);
40 policy->Release();
41 }
42 }
43 }
44 #endif
45
46 bool g_exited_main_message_loop = false; 23 bool g_exited_main_message_loop = false;
47 24
48 } // namespace 25 } // namespace
49 26
50 namespace content { 27 namespace content {
51 28
52 bool ExitedMainMessageLoop() { 29 bool ExitedMainMessageLoop() {
53 return g_exited_main_message_loop; 30 return g_exited_main_message_loop;
54 } 31 }
55 32
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // TODO(viettrungluu): put the remainder into BrowserMainParts 76 // TODO(viettrungluu): put the remainder into BrowserMainParts
100 77
101 #if defined(OS_WIN) 78 #if defined(OS_WIN)
102 #if !defined(NO_TCMALLOC) 79 #if !defined(NO_TCMALLOC)
103 // When linking shared libraries, NO_TCMALLOC is defined, and dynamic 80 // When linking shared libraries, NO_TCMALLOC is defined, and dynamic
104 // allocator selection is not supported. 81 // allocator selection is not supported.
105 82
106 // Make this call before going multithreaded, or spawning any subprocesses. 83 // Make this call before going multithreaded, or spawning any subprocesses.
107 base::allocator::SetupSubprocessAllocator(); 84 base::allocator::SetupSubprocessAllocator();
108 #endif 85 #endif
109 // The broker service initialization needs to run early because it will
110 // initialize the sandbox broker, which requires the process to swap its
111 // window station. During this time all the UI will be broken. This has to
112 // run before threads and windows are created.
113 InitializeBrokerServices(parameters, parameters.command_line_);
114 86
115 base::win::ScopedCOMInitializer com_initializer; 87 base::win::ScopedCOMInitializer com_initializer;
116 #endif // OS_WIN 88 #endif // OS_WIN
117 89
118 base::StatisticsRecorder statistics; 90 base::StatisticsRecorder statistics;
119 91
120 main_loop->RunMainMessageLoopParts(&g_exited_main_message_loop); 92 main_loop->RunMainMessageLoopParts(&g_exited_main_message_loop);
121 93
122 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); 94 TRACE_EVENT_END_ETW("BrowserMain", 0, 0);
123 95
124 return main_loop->GetResultCode(); 96 return main_loop->GetResultCode();
125 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698