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 "chrome/app/chrome_main_delegate.h" | 5 #include "chrome/app/chrome_main_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 if (HasDeprecatedArguments(command_line.GetCommandLineString())) { | 440 if (HasDeprecatedArguments(command_line.GetCommandLineString())) { |
441 *exit_code = 1; | 441 *exit_code = 1; |
442 return true; | 442 return true; |
443 } | 443 } |
444 #endif | 444 #endif |
445 | 445 |
446 if (!command_line.HasSwitch(switches::kProcessType) && | 446 if (!command_line.HasSwitch(switches::kProcessType) && |
447 command_line.HasSwitch(switches::kEnableBenchmarking)) { | 447 command_line.HasSwitch(switches::kEnableBenchmarking)) { |
448 base::FieldTrial::EnableBenchmarking(); | 448 base::FieldTrial::EnableBenchmarking(); |
449 } | 449 } |
| 450 |
| 451 std::string process_type = command_line.GetSwitchValueASCII( |
| 452 switches::kProcessType); |
| 453 content::SetContentClient(&chrome_content_client_); |
| 454 InitializeChromeContentClient(process_type); |
| 455 |
450 return false; | 456 return false; |
451 } | 457 } |
452 | 458 |
453 #if defined(OS_MACOSX) | 459 #if defined(OS_MACOSX) |
454 void ChromeMainDelegate::InitMacCrashReporter(const CommandLine& command_line, | 460 void ChromeMainDelegate::InitMacCrashReporter(const CommandLine& command_line, |
455 const std::string& process_type) { | 461 const std::string& process_type) { |
456 // TODO(mark): Right now, InitCrashReporter() needs to be called after | 462 // TODO(mark): Right now, InitCrashReporter() needs to be called after |
457 // CommandLine::Init() and chrome::RegisterPathProvider(). Ideally, | 463 // CommandLine::Init() and chrome::RegisterPathProvider(). Ideally, |
458 // Breakpad initialization could occur sooner, preferably even before the | 464 // Breakpad initialization could occur sooner, preferably even before the |
459 // framework dylib is even loaded, to catch potential early crashes. | 465 // framework dylib is even loaded, to catch potential early crashes. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 if (IsCrashReporterEnabled()) | 542 if (IsCrashReporterEnabled()) |
537 InitCrashProcessInfo(); | 543 InitCrashProcessInfo(); |
538 } | 544 } |
539 #endif // defined(OS_MACOSX) | 545 #endif // defined(OS_MACOSX) |
540 | 546 |
541 void ChromeMainDelegate::PreSandboxStartup() { | 547 void ChromeMainDelegate::PreSandboxStartup() { |
542 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 548 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
543 std::string process_type = | 549 std::string process_type = |
544 command_line.GetSwitchValueASCII(switches::kProcessType); | 550 command_line.GetSwitchValueASCII(switches::kProcessType); |
545 | 551 |
546 // Initialize the content client which that code uses to talk to Chrome. | |
547 content::SetContentClient(&chrome_content_client_); | |
548 InitializeChromeContentClient(process_type); | |
549 | |
550 // Initialize the Chrome path provider. | |
551 chrome::RegisterPathProvider(); | 552 chrome::RegisterPathProvider(); |
552 | 553 |
553 #if defined(OS_MACOSX) | 554 #if defined(OS_MACOSX) |
554 // On the Mac, the child executable lives at a predefined location within | 555 // On the Mac, the child executable lives at a predefined location within |
555 // the app bundle's versioned directory. | 556 // the app bundle's versioned directory. |
556 PathService::Override(content::CHILD_PROCESS_EXE, | 557 PathService::Override(content::CHILD_PROCESS_EXE, |
557 chrome::GetVersionedDirectory(). | 558 chrome::GetVersionedDirectory(). |
558 Append(chrome::kHelperProcessExecutablePath)); | 559 Append(chrome::kHelperProcessExecutablePath)); |
559 | 560 |
560 InitMacCrashReporter(command_line, process_type); | 561 InitMacCrashReporter(command_line, process_type); |
(...skipping 21 matching lines...) Expand all Loading... |
582 if (command_line.HasSwitch(switches::kSingleProcess)) | 583 if (command_line.HasSwitch(switches::kSingleProcess)) |
583 InitializeChromeContentRendererClient(); | 584 InitializeChromeContentRendererClient(); |
584 | 585 |
585 logging::OldFileDeletionState file_state = | 586 logging::OldFileDeletionState file_state = |
586 logging::APPEND_TO_OLD_LOG_FILE; | 587 logging::APPEND_TO_OLD_LOG_FILE; |
587 if (process_type.empty()) { | 588 if (process_type.empty()) { |
588 file_state = logging::DELETE_OLD_LOG_FILE; | 589 file_state = logging::DELETE_OLD_LOG_FILE; |
589 } | 590 } |
590 logging::InitChromeLogging(command_line, file_state); | 591 logging::InitChromeLogging(command_line, file_state); |
591 | 592 |
592 // Register internal Chrome schemes so they'll be parsed correctly. This | |
593 // must happen before we process any URLs with the affected schemes, and | |
594 // must be done in all processes that work with these URLs (i.e. including | |
595 // renderers). | |
596 chrome::RegisterChromeSchemes(); | |
597 | |
598 #if defined(OS_WIN) | 593 #if defined(OS_WIN) |
599 // TODO(darin): Kill this once http://crbug.com/52609 is fixed. | 594 // TODO(darin): Kill this once http://crbug.com/52609 is fixed. |
600 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); | 595 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); |
601 #endif | 596 #endif |
602 | 597 |
603 if (SubprocessNeedsResourceBundle(process_type)) { | 598 if (SubprocessNeedsResourceBundle(process_type)) { |
604 // Initialize ResourceBundle which handles files loaded from external | 599 // Initialize ResourceBundle which handles files loaded from external |
605 // sources. The language should have been passed in to us from the | 600 // sources. The language should have been passed in to us from the |
606 // browser process as a command line flag. | 601 // browser process as a command line flag. |
607 DCHECK(command_line.HasSwitch(switches::kLang) || | 602 DCHECK(command_line.HasSwitch(switches::kLang) || |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 | 724 |
730 #if defined(USE_LINUX_BREAKPAD) | 725 #if defined(USE_LINUX_BREAKPAD) |
731 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets | 726 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets |
732 // this up for the browser process in a different manner. | 727 // this up for the browser process in a different manner. |
733 InitCrashReporter(); | 728 InitCrashReporter(); |
734 #endif | 729 #endif |
735 | 730 |
736 InitializeChromeContentClient(process_type); | 731 InitializeChromeContentClient(process_type); |
737 } | 732 } |
738 #endif // OS_MACOSX | 733 #endif // OS_MACOSX |
OLD | NEW |