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/stats_counters.h" | 10 #include "base/metrics/stats_counters.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "base/strings/string_util.h" | 41 #include "base/strings/string_util.h" |
42 #include "sandbox/win/src/sandbox.h" | 42 #include "sandbox/win/src/sandbox.h" |
43 #include "tools/memory_watcher/memory_watcher.h" | 43 #include "tools/memory_watcher/memory_watcher.h" |
44 #include "ui/base/resource/resource_bundle_win.h" | 44 #include "ui/base/resource/resource_bundle_win.h" |
45 #endif | 45 #endif |
46 | 46 |
47 #if defined(OS_MACOSX) | 47 #if defined(OS_MACOSX) |
48 #include "base/mac/mac_util.h" | 48 #include "base/mac/mac_util.h" |
49 #include "base/mac/os_crash_dumps.h" | 49 #include "base/mac/os_crash_dumps.h" |
50 #include "chrome/app/breakpad_mac.h" | 50 #include "chrome/app/breakpad_mac.h" |
51 #include "chrome/app/chrome_breakpad_client.h" | |
52 #include "chrome/app/chrome_main_mac.h" | 51 #include "chrome/app/chrome_main_mac.h" |
53 #include "chrome/browser/mac/relauncher.h" | 52 #include "chrome/browser/mac/relauncher.h" |
54 #include "chrome/common/chrome_paths_internal.h" | 53 #include "chrome/common/chrome_paths_internal.h" |
55 #include "chrome/common/mac/cfbundle_blocker.h" | 54 #include "chrome/common/mac/cfbundle_blocker.h" |
56 #include "chrome/common/mac/objc_zombie.h" | 55 #include "chrome/common/mac/objc_zombie.h" |
57 #include "components/breakpad/breakpad_client.h" | |
58 #include "grit/chromium_strings.h" | 56 #include "grit/chromium_strings.h" |
59 #include "ui/base/l10n/l10n_util_mac.h" | 57 #include "ui/base/l10n/l10n_util_mac.h" |
60 #endif | 58 #endif |
61 | 59 |
62 #if defined(OS_POSIX) | 60 #if defined(OS_POSIX) |
63 #include <locale.h> | 61 #include <locale.h> |
64 #include <signal.h> | 62 #include <signal.h> |
| 63 #include "chrome/app/chrome_breakpad_client.h" |
| 64 #include "components/breakpad/breakpad_client.h" |
65 #endif | 65 #endif |
66 | 66 |
67 #if !defined(DISABLE_NACL) && defined(OS_LINUX) | 67 #if !defined(DISABLE_NACL) && defined(OS_LINUX) |
68 #include "chrome/app/nacl_fork_delegate_linux.h" | 68 #include "chrome/app/nacl_fork_delegate_linux.h" |
69 #include "chrome/common/nacl_paths.h" | 69 #include "chrome/common/nacl_paths.h" |
70 #endif | 70 #endif |
71 | 71 |
72 #if defined(OS_CHROMEOS) | 72 #if defined(OS_CHROMEOS) |
73 #include "base/sys_info.h" | 73 #include "base/sys_info.h" |
74 #include "chrome/browser/chromeos/boot_times_loader.h" | 74 #include "chrome/browser/chromeos/boot_times_loader.h" |
75 #include "chromeos/chromeos_paths.h" | 75 #include "chromeos/chromeos_paths.h" |
76 #endif | 76 #endif |
77 | 77 |
78 #if defined(OS_ANDROID) | 78 #if defined(OS_ANDROID) |
79 #include "chrome/common/descriptors_android.h" | 79 #include "chrome/common/descriptors_android.h" |
80 #else | 80 #else |
81 // Diagnostics is only available on non-android platforms. | 81 // Diagnostics is only available on non-android platforms. |
82 #include "chrome/browser/diagnostics/diagnostics_controller.h" | 82 #include "chrome/browser/diagnostics/diagnostics_controller.h" |
83 #include "chrome/browser/diagnostics/diagnostics_writer.h" | 83 #include "chrome/browser/diagnostics/diagnostics_writer.h" |
84 #endif | 84 #endif |
85 | 85 |
86 #if defined(USE_X11) | 86 #if defined(USE_X11) |
87 #include <stdlib.h> | 87 #include <stdlib.h> |
88 #include <string.h> | 88 #include <string.h> |
89 #include "ui/base/x/x11_util.h" | 89 #include "ui/base/x/x11_util.h" |
90 #endif | 90 #endif |
91 | 91 |
92 #if defined(USE_LINUX_BREAKPAD) | 92 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
93 #include "chrome/app/breakpad_linux.h" | 93 #include "chrome/app/breakpad_linux.h" |
94 #include "chrome/app/chrome_breakpad_client.h" | |
95 #include "components/breakpad/breakpad_client.h" | |
96 #endif | 94 #endif |
97 | 95 |
98 base::LazyInstance<chrome::ChromeContentBrowserClient> | 96 base::LazyInstance<chrome::ChromeContentBrowserClient> |
99 g_chrome_content_browser_client = LAZY_INSTANCE_INITIALIZER; | 97 g_chrome_content_browser_client = LAZY_INSTANCE_INITIALIZER; |
100 base::LazyInstance<chrome::ChromeContentRendererClient> | 98 base::LazyInstance<chrome::ChromeContentRendererClient> |
101 g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER; | 99 g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER; |
102 base::LazyInstance<chrome::ChromeContentUtilityClient> | 100 base::LazyInstance<chrome::ChromeContentUtilityClient> |
103 g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER; | 101 g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER; |
104 base::LazyInstance<chrome::ChromeContentPluginClient> | 102 base::LazyInstance<chrome::ChromeContentPluginClient> |
105 g_chrome_content_plugin_client = LAZY_INSTANCE_INITIALIZER; | 103 g_chrome_content_plugin_client = LAZY_INSTANCE_INITIALIZER; |
106 | 104 |
107 #if defined(OS_MACOSX) || defined(USE_LINUX_BREAKPAD) | 105 #if defined(OS_POSIX) |
108 base::LazyInstance<chrome::ChromeBreakpadClient>::Leaky | 106 base::LazyInstance<chrome::ChromeBreakpadClient>::Leaky |
109 g_chrome_breakpad_client = LAZY_INSTANCE_INITIALIZER; | 107 g_chrome_breakpad_client = LAZY_INSTANCE_INITIALIZER; |
110 #endif | 108 #endif |
111 | 109 |
112 extern int NaClMain(const content::MainFunctionParams&); | 110 extern int NaClMain(const content::MainFunctionParams&); |
113 extern int ServiceProcessMain(const content::MainFunctionParams&); | 111 extern int ServiceProcessMain(const content::MainFunctionParams&); |
114 | 112 |
115 namespace { | 113 namespace { |
116 | 114 |
117 #if defined(OS_WIN) | 115 #if defined(OS_WIN) |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 if (IsCrashReporterEnabled()) | 505 if (IsCrashReporterEnabled()) |
508 InitCrashProcessInfo(); | 506 InitCrashProcessInfo(); |
509 } | 507 } |
510 #endif // defined(OS_MACOSX) | 508 #endif // defined(OS_MACOSX) |
511 | 509 |
512 void ChromeMainDelegate::PreSandboxStartup() { | 510 void ChromeMainDelegate::PreSandboxStartup() { |
513 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 511 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
514 std::string process_type = | 512 std::string process_type = |
515 command_line.GetSwitchValueASCII(switches::kProcessType); | 513 command_line.GetSwitchValueASCII(switches::kProcessType); |
516 | 514 |
517 #if defined(OS_MACOSX) || defined(USE_LINUX_BREAKPAD) | 515 #if defined(OS_POSIX) |
518 breakpad::SetBreakpadClient(g_chrome_breakpad_client.Pointer()); | 516 breakpad::SetBreakpadClient(g_chrome_breakpad_client.Pointer()); |
519 #endif | 517 #endif |
520 | 518 |
521 #if defined(OS_MACOSX) | 519 #if defined(OS_MACOSX) |
522 // On the Mac, the child executable lives at a predefined location within | 520 // On the Mac, the child executable lives at a predefined location within |
523 // the app bundle's versioned directory. | 521 // the app bundle's versioned directory. |
524 PathService::Override(content::CHILD_PROCESS_EXE, | 522 PathService::Override(content::CHILD_PROCESS_EXE, |
525 chrome::GetVersionedDirectory(). | 523 chrome::GetVersionedDirectory(). |
526 Append(chrome::kHelperProcessExecutablePath)); | 524 Append(chrome::kHelperProcessExecutablePath)); |
527 | 525 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << | 626 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << |
629 locale; | 627 locale; |
630 | 628 |
631 #if defined(OS_MACOSX) | 629 #if defined(OS_MACOSX) |
632 // Update the process name (need resources to get the strings, so | 630 // Update the process name (need resources to get the strings, so |
633 // only do this when ResourcesBundle has been initialized). | 631 // only do this when ResourcesBundle has been initialized). |
634 SetMacProcessName(command_line); | 632 SetMacProcessName(command_line); |
635 #endif // defined(OS_MACOSX) | 633 #endif // defined(OS_MACOSX) |
636 } | 634 } |
637 | 635 |
638 #if defined(USE_LINUX_BREAKPAD) | 636 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
639 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain | 637 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain |
640 // sets this up for the browser process in a different manner. Zygotes | 638 // sets this up for the browser process in a different manner. Zygotes |
641 // need to call InitCrashReporter() in RunZygote(). | 639 // need to call InitCrashReporter() in RunZygote(). |
642 if (!process_type.empty() && process_type != switches::kZygoteProcess) { | 640 if (!process_type.empty() && process_type != switches::kZygoteProcess) { |
643 #if defined(OS_ANDROID) | 641 #if defined(OS_ANDROID) |
644 InitNonBrowserCrashReporterForAndroid(); | 642 InitNonBrowserCrashReporterForAndroid(); |
645 #else | 643 #else |
646 InitCrashReporter(); | 644 InitCrashReporter(); |
647 #endif | 645 #endif |
648 } | 646 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 #endif | 733 #endif |
736 } | 734 } |
737 | 735 |
738 void ChromeMainDelegate::ZygoteForked() { | 736 void ChromeMainDelegate::ZygoteForked() { |
739 Profiling::ProcessStarted(); | 737 Profiling::ProcessStarted(); |
740 if (Profiling::BeingProfiled()) { | 738 if (Profiling::BeingProfiled()) { |
741 base::debug::RestartProfilingAfterFork(); | 739 base::debug::RestartProfilingAfterFork(); |
742 SetUpProfilingShutdownHandler(); | 740 SetUpProfilingShutdownHandler(); |
743 } | 741 } |
744 | 742 |
745 #if defined(USE_LINUX_BREAKPAD) | 743 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
746 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets | 744 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets |
747 // this up for the browser process in a different manner. | 745 // this up for the browser process in a different manner. |
748 InitCrashReporter(); | 746 InitCrashReporter(); |
749 #endif | 747 #endif |
750 } | 748 } |
751 | 749 |
752 #endif // OS_MACOSX | 750 #endif // OS_MACOSX |
753 | 751 |
754 content::ContentBrowserClient* | 752 content::ContentBrowserClient* |
755 ChromeMainDelegate::CreateContentBrowserClient() { | 753 ChromeMainDelegate::CreateContentBrowserClient() { |
756 return &g_chrome_content_browser_client.Get(); | 754 return &g_chrome_content_browser_client.Get(); |
757 } | 755 } |
758 | 756 |
759 content::ContentPluginClient* ChromeMainDelegate::CreateContentPluginClient() { | 757 content::ContentPluginClient* ChromeMainDelegate::CreateContentPluginClient() { |
760 // TODO(scottmg): http://crbug.com/237249 This will have to be split out into | 758 // TODO(scottmg): http://crbug.com/237249 This will have to be split out into |
761 // browser and child parts. | 759 // browser and child parts. |
762 return &g_chrome_content_plugin_client.Get(); | 760 return &g_chrome_content_plugin_client.Get(); |
763 } | 761 } |
764 | 762 |
765 content::ContentRendererClient* | 763 content::ContentRendererClient* |
766 ChromeMainDelegate::CreateContentRendererClient() { | 764 ChromeMainDelegate::CreateContentRendererClient() { |
767 return &g_chrome_content_renderer_client.Get(); | 765 return &g_chrome_content_renderer_client.Get(); |
768 } | 766 } |
769 | 767 |
770 content::ContentUtilityClient* | 768 content::ContentUtilityClient* |
771 ChromeMainDelegate::CreateContentUtilityClient() { | 769 ChromeMainDelegate::CreateContentUtilityClient() { |
772 return &g_chrome_content_utility_client.Get(); | 770 return &g_chrome_content_utility_client.Get(); |
773 } | 771 } |
OLD | NEW |