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