OLD | NEW |
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/renderer/renderer_main_platform_delegate.h" | 5 #include "content/renderer/renderer_main_platform_delegate.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 "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 105 } |
106 blink::WebFontRendering::setUseDirectWrite(use_direct_write); | 106 blink::WebFontRendering::setUseDirectWrite(use_direct_write); |
107 if (use_direct_write) { | 107 if (use_direct_write) { |
108 blink::WebRuntimeFeatures::enableSubpixelFontScaling(true); | 108 blink::WebRuntimeFeatures::enableSubpixelFontScaling(true); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 void RendererMainPlatformDelegate::PlatformUninitialize() { | 112 void RendererMainPlatformDelegate::PlatformUninitialize() { |
113 } | 113 } |
114 | 114 |
115 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { | |
116 const CommandLine& command_line = parameters_.command_line; | |
117 | |
118 DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString(); | |
119 | |
120 sandbox::TargetServices* target_services = | |
121 parameters_.sandbox_info->target_services; | |
122 | |
123 if (target_services && !no_sandbox) { | |
124 std::wstring test_dll_name = | |
125 command_line.GetSwitchValueNative(switches::kTestSandbox); | |
126 if (!test_dll_name.empty()) { | |
127 sandbox_test_module_ = LoadLibrary(test_dll_name.c_str()); | |
128 DCHECK(sandbox_test_module_); | |
129 if (!sandbox_test_module_) { | |
130 return false; | |
131 } | |
132 } | |
133 } | |
134 return true; | |
135 } | |
136 | |
137 bool RendererMainPlatformDelegate::EnableSandbox() { | 115 bool RendererMainPlatformDelegate::EnableSandbox() { |
138 sandbox::TargetServices* target_services = | 116 sandbox::TargetServices* target_services = |
139 parameters_.sandbox_info->target_services; | 117 parameters_.sandbox_info->target_services; |
140 | 118 |
141 if (target_services) { | 119 if (target_services) { |
142 // Cause advapi32 to load before the sandbox is turned on. | 120 // Cause advapi32 to load before the sandbox is turned on. |
143 unsigned int dummy_rand; | 121 unsigned int dummy_rand; |
144 rand_s(&dummy_rand); | 122 rand_s(&dummy_rand); |
145 // Warm up language subsystems before the sandbox is turned on. | 123 // Warm up language subsystems before the sandbox is turned on. |
146 ::GetUserDefaultLangID(); | 124 ::GetUserDefaultLangID(); |
147 ::GetUserDefaultLCID(); | 125 ::GetUserDefaultLCID(); |
148 | 126 |
149 target_services->LowerToken(); | 127 target_services->LowerToken(); |
150 return true; | 128 return true; |
151 } | 129 } |
152 return false; | 130 return false; |
153 } | 131 } |
154 | 132 |
155 void RendererMainPlatformDelegate::RunSandboxTests(bool no_sandbox) { | |
156 if (sandbox_test_module_) { | |
157 RunRendererTests run_security_tests = | |
158 reinterpret_cast<RunRendererTests>(GetProcAddress(sandbox_test_module_, | |
159 kRenderTestCall)); | |
160 DCHECK(run_security_tests); | |
161 if (run_security_tests) { | |
162 int test_count = 0; | |
163 DVLOG(1) << "Running renderer security tests"; | |
164 BOOL result = run_security_tests(&test_count); | |
165 CHECK(result) << "Test number " << test_count << " has failed."; | |
166 } | |
167 } | |
168 } | |
169 | |
170 } // namespace content | 133 } // namespace content |
OLD | NEW |