| 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/base_paths.h" | 7 #include "base/base_paths.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_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "chrome/app/close_handle_hook_win.h" | 48 #include "chrome/app/close_handle_hook_win.h" |
| 49 #include "chrome/common/child_process_logging.h" | 49 #include "chrome/common/child_process_logging.h" |
| 50 #include "chrome/common/terminate_on_heap_corruption_experiment_win.h" | 50 #include "chrome/common/terminate_on_heap_corruption_experiment_win.h" |
| 51 #include "chrome/common/v8_breakpad_support_win.h" | 51 #include "chrome/common/v8_breakpad_support_win.h" |
| 52 #include "sandbox/win/src/sandbox.h" | 52 #include "sandbox/win/src/sandbox.h" |
| 53 #include "ui/base/resource/resource_bundle_win.h" | 53 #include "ui/base/resource/resource_bundle_win.h" |
| 54 #endif | 54 #endif |
| 55 | 55 |
| 56 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
| 57 #include "base/mac/foundation_util.h" | 57 #include "base/mac/foundation_util.h" |
| 58 #include "base/mac/os_crash_dumps.h" | |
| 59 #include "chrome/app/chrome_main_mac.h" | 58 #include "chrome/app/chrome_main_mac.h" |
| 60 #include "chrome/browser/mac/relauncher.h" | 59 #include "chrome/browser/mac/relauncher.h" |
| 61 #include "chrome/common/mac/cfbundle_blocker.h" | 60 #include "chrome/common/mac/cfbundle_blocker.h" |
| 62 #include "chrome/common/mac/objc_zombie.h" | 61 #include "chrome/common/mac/objc_zombie.h" |
| 63 #include "components/crash/app/breakpad_mac.h" | 62 #include "components/crash/app/crashpad_mac.h" |
| 64 #include "ui/base/l10n/l10n_util_mac.h" | 63 #include "ui/base/l10n/l10n_util_mac.h" |
| 65 #endif | 64 #endif |
| 66 | 65 |
| 67 #if defined(OS_POSIX) | 66 #if defined(OS_POSIX) |
| 68 #include <locale.h> | 67 #include <locale.h> |
| 69 #include <signal.h> | 68 #include <signal.h> |
| 70 #include "chrome/app/chrome_crash_reporter_client.h" | 69 #include "chrome/app/chrome_crash_reporter_client.h" |
| 71 #include "components/crash/app/crash_reporter_client.h" | 70 #include "components/crash/app/crash_reporter_client.h" |
| 72 #endif | 71 #endif |
| 73 | 72 |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 | 557 |
| 559 content::SetContentClient(&chrome_content_client_); | 558 content::SetContentClient(&chrome_content_client_); |
| 560 | 559 |
| 561 return false; | 560 return false; |
| 562 } | 561 } |
| 563 | 562 |
| 564 #if defined(OS_MACOSX) | 563 #if defined(OS_MACOSX) |
| 565 void ChromeMainDelegate::InitMacCrashReporter( | 564 void ChromeMainDelegate::InitMacCrashReporter( |
| 566 const base::CommandLine& command_line, | 565 const base::CommandLine& command_line, |
| 567 const std::string& process_type) { | 566 const std::string& process_type) { |
| 568 // TODO(mark): Right now, InitCrashReporter() needs to be called after | 567 // TODO(mark): Right now, InitializeCrashpad() needs to be called after |
| 569 // CommandLine::Init() and chrome::RegisterPathProvider(). Ideally, | 568 // CommandLine::Init() and chrome::RegisterPathProvider(). Ideally, Crashpad |
| 570 // Breakpad initialization could occur sooner, preferably even before the | 569 // initialization could occur sooner, preferably even before the framework |
| 571 // framework dylib is even loaded, to catch potential early crashes. | 570 // dylib is even loaded, to catch potential early crashes. |
| 572 breakpad::InitCrashReporter(process_type); | 571 crash_reporter::InitializeCrashpad(process_type); |
| 573 | 572 |
| 574 #if defined(NDEBUG) | 573 const bool browser_process = process_type.empty(); |
| 575 bool is_debug_build = false; | 574 if (!browser_process) { |
| 576 #else | 575 std::string metrics_client_id = |
| 577 bool is_debug_build = true; | 576 command_line.GetSwitchValueASCII(switches::kMetricsClientID); |
| 578 #endif | 577 crash_keys::SetMetricsClientIdFromGUID(metrics_client_id); |
| 579 | |
| 580 // Details on when we enable Apple's Crash reporter. | |
| 581 // | |
| 582 // Motivation: | |
| 583 // In debug mode it takes Apple's crash reporter eons to generate a crash | |
| 584 // dump. | |
| 585 // | |
| 586 // What we do: | |
| 587 // * We only pass crashes for foreground processes to Apple's Crash | |
| 588 // reporter. At the time of this writing, that means just the Browser | |
| 589 // process. | |
| 590 // * If Breakpad is enabled, it will pass browser crashes to Crash Reporter | |
| 591 // itself. | |
| 592 // * If Breakpad is disabled, we only turn on Crash Reporter for the | |
| 593 // Browser process in release mode. | |
| 594 if (!command_line.HasSwitch(switches::kDisableBreakpad)) { | |
| 595 bool disable_apple_crash_reporter = is_debug_build || | |
| 596 base::mac::IsBackgroundOnlyProcess(); | |
| 597 if (!breakpad::IsCrashReporterEnabled() && disable_apple_crash_reporter) { | |
| 598 base::mac::DisableOSCrashDumps(); | |
| 599 } | |
| 600 } | 578 } |
| 601 | 579 |
| 602 // Mac Chrome is packaged with a main app bundle and a helper app bundle. | 580 // Mac Chrome is packaged with a main app bundle and a helper app bundle. |
| 603 // The main app bundle should only be used for the browser process, so it | 581 // The main app bundle should only be used for the browser process, so it |
| 604 // should never see a --type switch (switches::kProcessType). Likewise, | 582 // should never see a --type switch (switches::kProcessType). Likewise, |
| 605 // the helper should always have a --type switch. | 583 // the helper should always have a --type switch. |
| 606 // | 584 // |
| 607 // This check is done this late so there is already a call to | 585 // This check is done this late so there is already a call to |
| 608 // base::mac::IsBackgroundOnlyProcess(), so there is no change in | 586 // base::mac::IsBackgroundOnlyProcess(), so there is no change in |
| 609 // startup/initialization order. | 587 // startup/initialization order. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 << switches::kPluginProcess << " and " | 623 << switches::kPluginProcess << " and " |
| 646 << switches::kNaClLoaderProcess << ", saw " << process_type; | 624 << switches::kNaClLoaderProcess << ", saw " << process_type; |
| 647 #endif | 625 #endif |
| 648 } | 626 } |
| 649 } | 627 } |
| 650 } else { | 628 } else { |
| 651 CHECK(!command_line.HasSwitch(switches::kProcessType) && | 629 CHECK(!command_line.HasSwitch(switches::kProcessType) && |
| 652 process_type.empty()) | 630 process_type.empty()) |
| 653 << "Main application forbids --type, saw " << process_type; | 631 << "Main application forbids --type, saw " << process_type; |
| 654 } | 632 } |
| 655 | |
| 656 if (breakpad::IsCrashReporterEnabled()) | |
| 657 breakpad::InitCrashProcessInfo(process_type); | |
| 658 } | 633 } |
| 659 #endif // defined(OS_MACOSX) | 634 #endif // defined(OS_MACOSX) |
| 660 | 635 |
| 661 void ChromeMainDelegate::PreSandboxStartup() { | 636 void ChromeMainDelegate::PreSandboxStartup() { |
| 662 const base::CommandLine& command_line = | 637 const base::CommandLine& command_line = |
| 663 *base::CommandLine::ForCurrentProcess(); | 638 *base::CommandLine::ForCurrentProcess(); |
| 664 std::string process_type = | 639 std::string process_type = |
| 665 command_line.GetSwitchValueASCII(switches::kProcessType); | 640 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 666 | 641 |
| 667 #if defined(OS_POSIX) | 642 #if defined(OS_POSIX) |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 } | 953 } |
| 979 | 954 |
| 980 content::ContentUtilityClient* | 955 content::ContentUtilityClient* |
| 981 ChromeMainDelegate::CreateContentUtilityClient() { | 956 ChromeMainDelegate::CreateContentUtilityClient() { |
| 982 #if defined(CHROME_MULTIPLE_DLL_BROWSER) | 957 #if defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 983 return NULL; | 958 return NULL; |
| 984 #else | 959 #else |
| 985 return g_chrome_content_utility_client.Pointer(); | 960 return g_chrome_content_utility_client.Pointer(); |
| 986 #endif | 961 #endif |
| 987 } | 962 } |
| OLD | NEW |