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" |
11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/statistics_recorder.h" | 14 #include "base/metrics/statistics_recorder.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/process/memory.h" | 16 #include "base/process/memory.h" |
17 #include "base/process/process_handle.h" | 17 #include "base/process/process_handle.h" |
18 #include "base/process/process_info.h" | 18 #include "base/process/process_info.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "base/trace_event/trace_event_impl.h" | 21 #include "base/trace_event/trace_event_impl.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "chrome/app/chrome_crash_reporter_client.h" | |
24 #include "chrome/browser/chrome_content_browser_client.h" | 23 #include "chrome/browser/chrome_content_browser_client.h" |
25 #include "chrome/browser/defaults.h" | 24 #include "chrome/browser/defaults.h" |
26 #include "chrome/common/channel_info.h" | 25 #include "chrome/common/channel_info.h" |
27 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/chrome_content_client.h" | 27 #include "chrome/common/chrome_content_client.h" |
29 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
30 #include "chrome/common/chrome_paths_internal.h" | 29 #include "chrome/common/chrome_paths_internal.h" |
31 #include "chrome/common/chrome_result_codes.h" | 30 #include "chrome/common/chrome_result_codes.h" |
32 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
33 #include "chrome/common/crash_keys.h" | 32 #include "chrome/common/crash_keys.h" |
34 #include "chrome/common/logging_chrome.h" | 33 #include "chrome/common/logging_chrome.h" |
35 #include "chrome/common/profiling.h" | 34 #include "chrome/common/profiling.h" |
36 #include "chrome/common/switch_utils.h" | 35 #include "chrome/common/switch_utils.h" |
37 #include "chrome/common/trace_event_args_whitelist.h" | 36 #include "chrome/common/trace_event_args_whitelist.h" |
38 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
39 #include "chrome/plugin/chrome_content_plugin_client.h" | 38 #include "chrome/plugin/chrome_content_plugin_client.h" |
40 #include "chrome/renderer/chrome_content_renderer_client.h" | 39 #include "chrome/renderer/chrome_content_renderer_client.h" |
41 #include "chrome/utility/chrome_content_utility_client.h" | 40 #include "chrome/utility/chrome_content_utility_client.h" |
42 #include "components/component_updater/component_updater_paths.h" | 41 #include "components/component_updater/component_updater_paths.h" |
43 #include "components/content_settings/core/common/content_settings_pattern.h" | 42 #include "components/content_settings/core/common/content_settings_pattern.h" |
44 #include "components/crash/content/app/crash_reporter_client.h" | |
45 #include "components/version_info/version_info.h" | 43 #include "components/version_info/version_info.h" |
46 #include "content/public/common/content_client.h" | 44 #include "content/public/common/content_client.h" |
47 #include "content/public/common/content_paths.h" | 45 #include "content/public/common/content_paths.h" |
48 #include "content/public/common/content_switches.h" | 46 #include "content/public/common/content_switches.h" |
49 #include "extensions/common/constants.h" | 47 #include "extensions/common/constants.h" |
50 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
51 #include "ui/base/ui_base_switches.h" | 49 #include "ui/base/ui_base_switches.h" |
52 | 50 |
53 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
54 #include <atlbase.h> | 52 #include <atlbase.h> |
55 #include <malloc.h> | 53 #include <malloc.h> |
56 #include <algorithm> | 54 #include <algorithm> |
57 #include "chrome/app/close_handle_hook_win.h" | 55 #include "chrome/app/close_handle_hook_win.h" |
58 #include "chrome/common/child_process_logging.h" | 56 #include "chrome/common/child_process_logging.h" |
59 #include "chrome/common/v8_breakpad_support_win.h" | 57 #include "chrome/common/v8_breakpad_support_win.h" |
60 #include "components/crash/content/app/crashpad.h" | |
61 #include "sandbox/win/src/sandbox.h" | 58 #include "sandbox/win/src/sandbox.h" |
62 #include "ui/base/resource/resource_bundle_win.h" | 59 #include "ui/base/resource/resource_bundle_win.h" |
63 #endif | 60 #endif |
64 | 61 |
65 #if defined(OS_MACOSX) | 62 #if defined(OS_MACOSX) |
66 #include "base/mac/foundation_util.h" | 63 #include "base/mac/foundation_util.h" |
67 #include "chrome/app/chrome_main_mac.h" | 64 #include "chrome/app/chrome_main_mac.h" |
68 #include "chrome/browser/mac/relauncher.h" | 65 #include "chrome/browser/mac/relauncher.h" |
69 #include "chrome/common/mac/cfbundle_blocker.h" | 66 #include "chrome/common/mac/cfbundle_blocker.h" |
70 #include "components/crash/content/app/crashpad.h" | 67 #include "components/crash/content/app/crashpad_mac.h" |
71 #include "components/crash/core/common/objc_zombie.h" | 68 #include "components/crash/core/common/objc_zombie.h" |
72 #include "ui/base/l10n/l10n_util_mac.h" | 69 #include "ui/base/l10n/l10n_util_mac.h" |
73 #endif | 70 #endif |
74 | 71 |
75 #if defined(OS_POSIX) | 72 #if defined(OS_POSIX) |
76 #include <locale.h> | 73 #include <locale.h> |
77 #include <signal.h> | 74 #include <signal.h> |
| 75 #include "chrome/app/chrome_crash_reporter_client.h" |
| 76 #include "components/crash/content/app/crash_reporter_client.h" |
78 #endif | 77 #endif |
79 | 78 |
80 #if !defined(DISABLE_NACL) && defined(OS_LINUX) | 79 #if !defined(DISABLE_NACL) && defined(OS_LINUX) |
81 #include "components/nacl/common/nacl_paths.h" | 80 #include "components/nacl/common/nacl_paths.h" |
82 #include "components/nacl/zygote/nacl_fork_delegate_linux.h" | 81 #include "components/nacl/zygote/nacl_fork_delegate_linux.h" |
83 #endif | 82 #endif |
84 | 83 |
85 #if defined(OS_CHROMEOS) | 84 #if defined(OS_CHROMEOS) |
86 #include "base/sys_info.h" | 85 #include "base/sys_info.h" |
87 #include "chrome/browser/chromeos/boot_times_recorder.h" | 86 #include "chrome/browser/chromeos/boot_times_recorder.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER; | 138 g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER; |
140 base::LazyInstance<ChromeContentPluginClient> | 139 base::LazyInstance<ChromeContentPluginClient> |
141 g_chrome_content_plugin_client = LAZY_INSTANCE_INITIALIZER; | 140 g_chrome_content_plugin_client = LAZY_INSTANCE_INITIALIZER; |
142 #endif | 141 #endif |
143 | 142 |
144 #if !defined(CHROME_MULTIPLE_DLL_CHILD) | 143 #if !defined(CHROME_MULTIPLE_DLL_CHILD) |
145 base::LazyInstance<ChromeContentBrowserClient> g_chrome_content_browser_client = | 144 base::LazyInstance<ChromeContentBrowserClient> g_chrome_content_browser_client = |
146 LAZY_INSTANCE_INITIALIZER; | 145 LAZY_INSTANCE_INITIALIZER; |
147 #endif | 146 #endif |
148 | 147 |
149 #if defined(OS_POSIX) || defined(OS_WIN) | 148 #if defined(OS_POSIX) |
150 base::LazyInstance<ChromeCrashReporterClient>::Leaky g_chrome_crash_client = | 149 base::LazyInstance<ChromeCrashReporterClient>::Leaky g_chrome_crash_client = |
151 LAZY_INSTANCE_INITIALIZER; | 150 LAZY_INSTANCE_INITIALIZER; |
152 #endif | 151 #endif |
153 | 152 |
154 extern int NaClMain(const content::MainFunctionParams&); | 153 extern int NaClMain(const content::MainFunctionParams&); |
155 extern int ServiceProcessMain(const content::MainFunctionParams&); | 154 extern int ServiceProcessMain(const content::MainFunctionParams&); |
156 | 155 |
157 namespace { | 156 namespace { |
158 | 157 |
159 #if defined(OS_WIN) | 158 #if defined(OS_WIN) |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 } | 441 } |
443 | 442 |
444 bool ChromeMainDelegate::BasicStartupComplete(int* exit_code) { | 443 bool ChromeMainDelegate::BasicStartupComplete(int* exit_code) { |
445 #if defined(OS_CHROMEOS) | 444 #if defined(OS_CHROMEOS) |
446 chromeos::BootTimesRecorder::Get()->SaveChromeMainStats(); | 445 chromeos::BootTimesRecorder::Get()->SaveChromeMainStats(); |
447 #endif | 446 #endif |
448 | 447 |
449 const base::CommandLine& command_line = | 448 const base::CommandLine& command_line = |
450 *base::CommandLine::ForCurrentProcess(); | 449 *base::CommandLine::ForCurrentProcess(); |
451 | 450 |
| 451 |
452 #if defined(OS_WIN) | 452 #if defined(OS_WIN) |
453 // Browser should not be sandboxed. | 453 // Browser should not be sandboxed. |
454 const bool is_browser = !command_line.HasSwitch(switches::kProcessType); | 454 const bool is_browser = !command_line.HasSwitch(switches::kProcessType); |
455 if (is_browser && IsSandboxedProcess()) { | 455 if (is_browser && IsSandboxedProcess()) { |
456 *exit_code = chrome::RESULT_CODE_INVALID_SANDBOX_STATE; | 456 *exit_code = chrome::RESULT_CODE_INVALID_SANDBOX_STATE; |
457 return true; | 457 return true; |
458 } | 458 } |
459 #endif | 459 #endif |
460 | 460 |
461 #if defined(OS_MACOSX) | 461 #if defined(OS_MACOSX) |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 } | 658 } |
659 } | 659 } |
660 #endif // defined(OS_MACOSX) | 660 #endif // defined(OS_MACOSX) |
661 | 661 |
662 void ChromeMainDelegate::PreSandboxStartup() { | 662 void ChromeMainDelegate::PreSandboxStartup() { |
663 const base::CommandLine& command_line = | 663 const base::CommandLine& command_line = |
664 *base::CommandLine::ForCurrentProcess(); | 664 *base::CommandLine::ForCurrentProcess(); |
665 std::string process_type = | 665 std::string process_type = |
666 command_line.GetSwitchValueASCII(switches::kProcessType); | 666 command_line.GetSwitchValueASCII(switches::kProcessType); |
667 | 667 |
668 #if defined(OS_POSIX) || defined(OS_WIN) | 668 #if defined(OS_POSIX) |
669 crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); | 669 crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); |
670 #endif | 670 #endif |
671 | 671 |
672 #if defined(OS_MACOSX) | 672 #if defined(OS_MACOSX) |
673 // On the Mac, the child executable lives at a predefined location within | 673 // On the Mac, the child executable lives at a predefined location within |
674 // the app bundle's versioned directory. | 674 // the app bundle's versioned directory. |
675 PathService::Override(content::CHILD_PROCESS_EXE, | 675 PathService::Override(content::CHILD_PROCESS_EXE, |
676 chrome::GetVersionedDirectory(). | 676 chrome::GetVersionedDirectory(). |
677 Append(chrome::kHelperProcessExecutablePath)); | 677 Append(chrome::kHelperProcessExecutablePath)); |
678 | 678 |
679 InitMacCrashReporter(command_line, process_type); | 679 InitMacCrashReporter(command_line, process_type); |
680 #endif | 680 #endif |
681 | 681 |
682 #if defined(OS_WIN) | 682 #if defined(OS_WIN) |
683 // TODO(scottmg): It would be nice to do this earlier to catch early crashes, | |
684 // perhaps as early as WinMain in chrome.exe. This would require some code | |
685 // restructuring to have paths and command lines set up, and also to handle | |
686 // having some of the code live in chrome.exe, while having the database be | |
687 // accessed by browser code in chrome.dll (to get a list of uploaded crashes | |
688 // for chrome://crashes). | |
689 crash_reporter::InitializeCrashpad(process_type.empty(), process_type); | |
690 #endif // OS_WIN | |
691 | |
692 #if defined(OS_WIN) | |
693 child_process_logging::Init(); | 683 child_process_logging::Init(); |
694 #endif | 684 #endif |
695 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) | 685 #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) |
696 // Create an instance of the CPU class to parse /proc/cpuinfo and cache | 686 // Create an instance of the CPU class to parse /proc/cpuinfo and cache |
697 // cpu_brand info. | 687 // cpu_brand info. |
698 base::CPU cpu_info; | 688 base::CPU cpu_info; |
699 #endif | 689 #endif |
700 | 690 |
701 // Initialize the user data dir for any process type that needs it. | 691 // Initialize the user data dir for any process type that needs it. |
702 if (chrome::ProcessNeedsProfileDir(process_type)) | 692 if (chrome::ProcessNeedsProfileDir(process_type)) |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 case version_info::Channel::CANARY: | 980 case version_info::Channel::CANARY: |
991 return true; | 981 return true; |
992 case version_info::Channel::DEV: | 982 case version_info::Channel::DEV: |
993 case version_info::Channel::BETA: | 983 case version_info::Channel::BETA: |
994 case version_info::Channel::STABLE: | 984 case version_info::Channel::STABLE: |
995 default: | 985 default: |
996 // Don't enable instrumentation. | 986 // Don't enable instrumentation. |
997 return false; | 987 return false; |
998 } | 988 } |
999 } | 989 } |
OLD | NEW |