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/shell/app/shell_main_delegate.h" | 5 #include "content/shell/app/shell_main_delegate.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/cpu.h" | 9 #include "base/cpu.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 #endif | 122 #endif |
123 #if defined(OS_MACOSX) | 123 #if defined(OS_MACOSX) |
124 // Needs to happen before InitializeResourceBundle() and before | 124 // Needs to happen before InitializeResourceBundle() and before |
125 // BlinkTestPlatformInitialize() are called. | 125 // BlinkTestPlatformInitialize() are called. |
126 OverrideFrameworkBundlePath(); | 126 OverrideFrameworkBundlePath(); |
127 OverrideChildProcessPath(); | 127 OverrideChildProcessPath(); |
128 EnsureCorrectResolutionSettings(); | 128 EnsureCorrectResolutionSettings(); |
129 #endif // OS_MACOSX | 129 #endif // OS_MACOSX |
130 | 130 |
131 InitLogging(); | 131 InitLogging(); |
132 CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 132 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); |
133 if (command_line.HasSwitch(switches::kCheckLayoutTestSysDeps)) { | 133 if (command_line.HasSwitch(switches::kCheckLayoutTestSysDeps)) { |
134 // If CheckLayoutSystemDeps succeeds, we don't exit early. Instead we | 134 // If CheckLayoutSystemDeps succeeds, we don't exit early. Instead we |
135 // continue and try to load the fonts in BlinkTestPlatformInitialize | 135 // continue and try to load the fonts in BlinkTestPlatformInitialize |
136 // below, and then try to bring up the rest of the content module. | 136 // below, and then try to bring up the rest of the content module. |
137 if (!CheckLayoutSystemDeps()) { | 137 if (!CheckLayoutSystemDeps()) { |
138 if (exit_code) | 138 if (exit_code) |
139 *exit_code = 1; | 139 *exit_code = 1; |
140 return true; | 140 return true; |
141 } | 141 } |
142 } | 142 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 SetContentClient(&content_client_); | 202 SetContentClient(&content_client_); |
203 return false; | 203 return false; |
204 } | 204 } |
205 | 205 |
206 void ShellMainDelegate::PreSandboxStartup() { | 206 void ShellMainDelegate::PreSandboxStartup() { |
207 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) | 207 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) |
208 // Create an instance of the CPU class to parse /proc/cpuinfo and cache | 208 // Create an instance of the CPU class to parse /proc/cpuinfo and cache |
209 // cpu_brand info. | 209 // cpu_brand info. |
210 base::CPU cpu_info; | 210 base::CPU cpu_info; |
211 #endif | 211 #endif |
212 if (CommandLine::ForCurrentProcess()->HasSwitch( | 212 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
213 switches::kEnableCrashReporter)) { | 213 switches::kEnableCrashReporter)) { |
214 std::string process_type = | 214 std::string process_type = |
215 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 215 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
216 switches::kProcessType); | 216 switches::kProcessType); |
217 crash_reporter::SetCrashReporterClient(g_shell_crash_client.Pointer()); | 217 crash_reporter::SetCrashReporterClient(g_shell_crash_client.Pointer()); |
218 #if defined(OS_MACOSX) | 218 #if defined(OS_MACOSX) |
219 base::mac::DisableOSCrashDumps(); | 219 base::mac::DisableOSCrashDumps(); |
220 breakpad::InitCrashReporter(process_type); | 220 breakpad::InitCrashReporter(process_type); |
221 breakpad::InitCrashProcessInfo(process_type); | 221 breakpad::InitCrashProcessInfo(process_type); |
222 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | 222 #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
223 if (process_type != switches::kZygoteProcess) { | 223 if (process_type != switches::kZygoteProcess) { |
224 #if defined(OS_ANDROID) | 224 #if defined(OS_ANDROID) |
225 if (process_type.empty()) | 225 if (process_type.empty()) |
(...skipping 22 matching lines...) Expand all Loading... |
248 if (!process_type.empty()) | 248 if (!process_type.empty()) |
249 return -1; | 249 return -1; |
250 | 250 |
251 #if !defined(OS_ANDROID) | 251 #if !defined(OS_ANDROID) |
252 // Android stores the BrowserMainRunner instance as a scoped member pointer | 252 // Android stores the BrowserMainRunner instance as a scoped member pointer |
253 // on the ShellMainDelegate class because of different object lifetime. | 253 // on the ShellMainDelegate class because of different object lifetime. |
254 scoped_ptr<BrowserMainRunner> browser_runner_; | 254 scoped_ptr<BrowserMainRunner> browser_runner_; |
255 #endif | 255 #endif |
256 | 256 |
257 browser_runner_.reset(BrowserMainRunner::Create()); | 257 browser_runner_.reset(BrowserMainRunner::Create()); |
258 CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 258 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); |
259 return command_line.HasSwitch(switches::kDumpRenderTree) || | 259 return command_line.HasSwitch(switches::kDumpRenderTree) || |
260 command_line.HasSwitch(switches::kCheckLayoutTestSysDeps) | 260 command_line.HasSwitch(switches::kCheckLayoutTestSysDeps) |
261 ? LayoutTestBrowserMain(main_function_params, browser_runner_) | 261 ? LayoutTestBrowserMain(main_function_params, browser_runner_) |
262 : ShellBrowserMain(main_function_params, browser_runner_); | 262 : ShellBrowserMain(main_function_params, browser_runner_); |
263 } | 263 } |
264 | 264 |
265 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 265 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
266 void ShellMainDelegate::ZygoteForked() { | 266 void ShellMainDelegate::ZygoteForked() { |
267 if (CommandLine::ForCurrentProcess()->HasSwitch( | 267 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
268 switches::kEnableCrashReporter)) { | 268 switches::kEnableCrashReporter)) { |
269 std::string process_type = | 269 std::string process_type = |
270 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 270 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
271 switches::kProcessType); | 271 switches::kProcessType); |
272 breakpad::InitCrashReporter(process_type); | 272 breakpad::InitCrashReporter(process_type); |
273 } | 273 } |
274 } | 274 } |
275 #endif | 275 #endif |
276 | 276 |
277 void ShellMainDelegate::InitializeResourceBundle() { | 277 void ShellMainDelegate::InitializeResourceBundle() { |
278 #if defined(OS_ANDROID) | 278 #if defined(OS_ANDROID) |
279 // In the Android case, the renderer runs with a different UID and can never | 279 // In the Android case, the renderer runs with a different UID and can never |
280 // access the file system. So we are passed a file descriptor to the | 280 // access the file system. So we are passed a file descriptor to the |
(...skipping 23 matching lines...) Expand all Loading... |
304 #else | 304 #else |
305 PathService::Get(base::DIR_MODULE, &pak_dir); | 305 PathService::Get(base::DIR_MODULE, &pak_dir); |
306 #endif | 306 #endif |
307 | 307 |
308 pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")); | 308 pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")); |
309 #endif | 309 #endif |
310 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | 310 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); |
311 } | 311 } |
312 | 312 |
313 ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { | 313 ContentBrowserClient* ShellMainDelegate::CreateContentBrowserClient() { |
314 browser_client_.reset( | 314 browser_client_.reset(base::CommandLine::ForCurrentProcess()->HasSwitch( |
315 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree) ? | 315 switches::kDumpRenderTree) |
316 new LayoutTestContentBrowserClient : | 316 ? new LayoutTestContentBrowserClient |
317 new ShellContentBrowserClient); | 317 : new ShellContentBrowserClient); |
318 | 318 |
319 return browser_client_.get(); | 319 return browser_client_.get(); |
320 } | 320 } |
321 | 321 |
322 ContentRendererClient* ShellMainDelegate::CreateContentRendererClient() { | 322 ContentRendererClient* ShellMainDelegate::CreateContentRendererClient() { |
323 renderer_client_.reset( | 323 renderer_client_.reset(base::CommandLine::ForCurrentProcess()->HasSwitch( |
324 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree) ? | 324 switches::kDumpRenderTree) |
325 new LayoutTestContentRendererClient : | 325 ? new LayoutTestContentRendererClient |
326 new ShellContentRendererClient); | 326 : new ShellContentRendererClient); |
327 | 327 |
328 return renderer_client_.get(); | 328 return renderer_client_.get(); |
329 } | 329 } |
330 | 330 |
331 } // namespace content | 331 } // namespace content |
OLD | NEW |