Chromium Code Reviews| 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 // Initialize the content client very early on in the main initialization | |
| 453 // sequence, ContentMainRunner depends on methods of ContentClient, in | |
| 454 // particular the AddAdditionalSchemes() method which returns internal Chrome | |
| 455 // schemes to be registered with googleurl has having the standard | |
| 456 // <scheme>://<host>:<port>/<path> parsing semantics. This must happen before | |
| 457 // processing any URLs with the affected schemes, and must be done in all | |
| 458 // processes that work with these URLs (i.e. including renderers). | |
|
jam
2012/04/17 03:30:10
nit: this comment is describing what the code does
michaeln
2012/04/17 04:08:26
How about i leave it at...
// Initialize the conte
jam
2012/04/17 04:49:51
I think that's still documenting why something is
michaeln
2012/04/17 19:23:32
Ok, removed these retained comments. Fyi, there ar
| |
| 459 std::string process_type = command_line.GetSwitchValueASCII( | |
| 460 switches::kProcessType); | |
| 461 content::SetContentClient(&chrome_content_client_); | |
| 462 InitializeChromeContentClient(process_type); | |
| 463 | |
| 451 return false; | 464 return false; |
| 452 } | 465 } |
| 453 | 466 |
| 454 #if defined(OS_MACOSX) | 467 #if defined(OS_MACOSX) |
| 455 void ChromeMainDelegate::InitMacCrashReporter(const CommandLine& command_line, | 468 void ChromeMainDelegate::InitMacCrashReporter(const CommandLine& command_line, |
| 456 const std::string& process_type) { | 469 const std::string& process_type) { |
| 457 // TODO(mark): Right now, InitCrashReporter() needs to be called after | 470 // TODO(mark): Right now, InitCrashReporter() needs to be called after |
| 458 // CommandLine::Init() and chrome::RegisterPathProvider(). Ideally, | 471 // CommandLine::Init() and chrome::RegisterPathProvider(). Ideally, |
| 459 // Breakpad initialization could occur sooner, preferably even before the | 472 // Breakpad initialization could occur sooner, preferably even before the |
| 460 // framework dylib is even loaded, to catch potential early crashes. | 473 // 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()) | 550 if (IsCrashReporterEnabled()) |
| 538 InitCrashProcessInfo(); | 551 InitCrashProcessInfo(); |
| 539 } | 552 } |
| 540 #endif // defined(OS_MACOSX) | 553 #endif // defined(OS_MACOSX) |
| 541 | 554 |
| 542 void ChromeMainDelegate::PreSandboxStartup() { | 555 void ChromeMainDelegate::PreSandboxStartup() { |
| 543 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 556 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 544 std::string process_type = | 557 std::string process_type = |
| 545 command_line.GetSwitchValueASCII(switches::kProcessType); | 558 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 546 | 559 |
| 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. | 560 // Initialize the Chrome path provider. |
| 552 chrome::RegisterPathProvider(); | 561 chrome::RegisterPathProvider(); |
| 553 | 562 |
| 554 #if defined(OS_MACOSX) | 563 #if defined(OS_MACOSX) |
| 555 // On the Mac, the child executable lives at a predefined location within | 564 // On the Mac, the child executable lives at a predefined location within |
| 556 // the app bundle's versioned directory. | 565 // the app bundle's versioned directory. |
| 557 PathService::Override(content::CHILD_PROCESS_EXE, | 566 PathService::Override(content::CHILD_PROCESS_EXE, |
| 558 chrome::GetVersionedDirectory(). | 567 chrome::GetVersionedDirectory(). |
| 559 Append(chrome::kHelperProcessExecutablePath)); | 568 Append(chrome::kHelperProcessExecutablePath)); |
| 560 | 569 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 589 } | 598 } |
| 590 #endif // GOOGLE_CHROME_BUILD | 599 #endif // GOOGLE_CHROME_BUILD |
| 591 | 600 |
| 592 logging::OldFileDeletionState file_state = | 601 logging::OldFileDeletionState file_state = |
| 593 logging::APPEND_TO_OLD_LOG_FILE; | 602 logging::APPEND_TO_OLD_LOG_FILE; |
| 594 if (process_type.empty()) { | 603 if (process_type.empty()) { |
| 595 file_state = logging::DELETE_OLD_LOG_FILE; | 604 file_state = logging::DELETE_OLD_LOG_FILE; |
| 596 } | 605 } |
| 597 logging::InitChromeLogging(command_line, file_state); | 606 logging::InitChromeLogging(command_line, file_state); |
| 598 | 607 |
| 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) | 608 #if defined(OS_WIN) |
| 606 // TODO(darin): Kill this once http://crbug.com/52609 is fixed. | 609 // TODO(darin): Kill this once http://crbug.com/52609 is fixed. |
| 607 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); | 610 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); |
| 608 #endif | 611 #endif |
| 609 | 612 |
| 610 if (SubprocessNeedsResourceBundle(process_type)) { | 613 if (SubprocessNeedsResourceBundle(process_type)) { |
| 611 // Initialize ResourceBundle which handles files loaded from external | 614 // Initialize ResourceBundle which handles files loaded from external |
| 612 // sources. The language should have been passed in to us from the | 615 // sources. The language should have been passed in to us from the |
| 613 // browser process as a command line flag. | 616 // browser process as a command line flag. |
| 614 DCHECK(command_line.HasSwitch(switches::kLang) || | 617 DCHECK(command_line.HasSwitch(switches::kLang) || |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 736 | 739 |
| 737 #if defined(USE_LINUX_BREAKPAD) | 740 #if defined(USE_LINUX_BREAKPAD) |
| 738 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets | 741 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets |
| 739 // this up for the browser process in a different manner. | 742 // this up for the browser process in a different manner. |
| 740 InitCrashReporter(); | 743 InitCrashReporter(); |
| 741 #endif | 744 #endif |
| 742 | 745 |
| 743 InitializeChromeContentClient(process_type); | 746 InitializeChromeContentClient(process_type); |
| 744 } | 747 } |
| 745 #endif // OS_MACOSX | 748 #endif // OS_MACOSX |
| OLD | NEW |