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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/stats_counters.h" | 10 #include "base/metrics/stats_counters.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(OS_POSIX) && !defined(OS_MACOSX) | 92 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
93 #include "chrome/app/breakpad_linux.h" | 93 #include "chrome/app/breakpad_linux.h" |
94 #endif | 94 #endif |
95 | 95 |
96 #if !defined(CHROME_MULTIPLE_DLL) || defined(CHROME_MULTIPLE_DLL_CHILD) | 96 base::LazyInstance<chrome::ChromeContentBrowserClient> |
| 97 g_chrome_content_browser_client = LAZY_INSTANCE_INITIALIZER; |
97 base::LazyInstance<chrome::ChromeContentRendererClient> | 98 base::LazyInstance<chrome::ChromeContentRendererClient> |
98 g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER; | 99 g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER; |
99 base::LazyInstance<chrome::ChromeContentUtilityClient> | 100 base::LazyInstance<chrome::ChromeContentUtilityClient> |
100 g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER; | 101 g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER; |
101 base::LazyInstance<chrome::ChromeContentPluginClient> | 102 base::LazyInstance<chrome::ChromeContentPluginClient> |
102 g_chrome_content_plugin_client = LAZY_INSTANCE_INITIALIZER; | 103 g_chrome_content_plugin_client = LAZY_INSTANCE_INITIALIZER; |
103 #else // In browser in multiple DLL mode. | |
104 base::LazyInstance<chrome::ChromeContentBrowserClient> | |
105 g_chrome_content_browser_client = LAZY_INSTANCE_INITIALIZER; | |
106 #endif | |
107 | 104 |
108 #if defined(OS_POSIX) | 105 #if defined(OS_POSIX) |
109 base::LazyInstance<chrome::ChromeBreakpadClient>::Leaky | 106 base::LazyInstance<chrome::ChromeBreakpadClient>::Leaky |
110 g_chrome_breakpad_client = LAZY_INSTANCE_INITIALIZER; | 107 g_chrome_breakpad_client = LAZY_INSTANCE_INITIALIZER; |
111 #endif | 108 #endif |
112 | 109 |
113 extern int NaClMain(const content::MainFunctionParams&); | 110 extern int NaClMain(const content::MainFunctionParams&); |
114 extern int ServiceProcessMain(const content::MainFunctionParams&); | 111 extern int ServiceProcessMain(const content::MainFunctionParams&); |
115 | 112 |
116 namespace { | 113 namespace { |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 #if !defined(DISABLE_NACL) && defined(OS_LINUX) | 381 #if !defined(DISABLE_NACL) && defined(OS_LINUX) |
385 nacl::RegisterPathProvider(); | 382 nacl::RegisterPathProvider(); |
386 #endif | 383 #endif |
387 | 384 |
388 // No support for ANDROID yet as DiagnosticsController needs wchar support. | 385 // No support for ANDROID yet as DiagnosticsController needs wchar support. |
389 // TODO(gspencer): That's not true anymore, or at least there are no w-string | 386 // TODO(gspencer): That's not true anymore, or at least there are no w-string |
390 // references anymore. Not sure if that means this can be enabled on Android or | 387 // references anymore. Not sure if that means this can be enabled on Android or |
391 // not though: it still uses string16. As there is no easily accessible command | 388 // not though: it still uses string16. As there is no easily accessible command |
392 // line on Android, I'm not sure this is a big deal, at least for purposes of | 389 // line on Android, I'm not sure this is a big deal, at least for purposes of |
393 // troubleshooting with a customer. | 390 // troubleshooting with a customer. |
394 #if !defined(OS_ANDROID) && !defined(CHROME_MULTIPLE_DLL_CHILD) | 391 #if !defined(OS_ANDROID) |
395 // If we are in diagnostics mode this is the end of the line: after the | 392 // If we are in diagnostics mode this is the end of the line: after the |
396 // diagnostics are run the process will invariably exit. | 393 // diagnostics are run the process will invariably exit. |
397 if (command_line.HasSwitch(switches::kDiagnostics)) { | 394 if (command_line.HasSwitch(switches::kDiagnostics)) { |
398 diagnostics::DiagnosticsWriter::FormatType format = | 395 diagnostics::DiagnosticsWriter::FormatType format = |
399 diagnostics::DiagnosticsWriter::HUMAN; | 396 diagnostics::DiagnosticsWriter::HUMAN; |
400 if (command_line.HasSwitch(switches::kDiagnosticsFormat)) { | 397 if (command_line.HasSwitch(switches::kDiagnosticsFormat)) { |
401 std::string format_str = | 398 std::string format_str = |
402 command_line.GetSwitchValueASCII(switches::kDiagnosticsFormat); | 399 command_line.GetSwitchValueASCII(switches::kDiagnosticsFormat); |
403 if (format_str == "machine") { | 400 if (format_str == "machine") { |
404 format = diagnostics::DiagnosticsWriter::MACHINE; | 401 format = diagnostics::DiagnosticsWriter::MACHINE; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 #if defined(OS_WIN) | 666 #if defined(OS_WIN) |
670 SuppressWindowsErrorDialogs(); | 667 SuppressWindowsErrorDialogs(); |
671 #endif | 668 #endif |
672 } | 669 } |
673 | 670 |
674 int ChromeMainDelegate::RunProcess( | 671 int ChromeMainDelegate::RunProcess( |
675 const std::string& process_type, | 672 const std::string& process_type, |
676 const content::MainFunctionParams& main_function_params) { | 673 const content::MainFunctionParams& main_function_params) { |
677 // ANDROID doesn't support "service", so no ServiceProcessMain, and arraysize | 674 // ANDROID doesn't support "service", so no ServiceProcessMain, and arraysize |
678 // doesn't support empty array. So we comment out the block for Android. | 675 // doesn't support empty array. So we comment out the block for Android. |
679 #if !defined(OS_ANDROID) && \ | 676 #if !defined(OS_ANDROID) |
680 (!defined(CHROME_MULTIPLE_DLL) || defined(CHROME_MULTIPLE_DLL_BROWSER)) | |
681 static const MainFunction kMainFunctions[] = { | 677 static const MainFunction kMainFunctions[] = { |
682 { switches::kServiceProcess, ServiceProcessMain }, | 678 { switches::kServiceProcess, ServiceProcessMain }, |
683 #if defined(OS_MACOSX) | 679 #if defined(OS_MACOSX) |
684 { switches::kRelauncherProcess, | 680 { switches::kRelauncherProcess, |
685 mac_relauncher::internal::RelauncherMain }, | 681 mac_relauncher::internal::RelauncherMain }, |
686 #endif | 682 #endif |
687 | 683 // TODO(scottmg): http://crbug.com/237249 NaCl -> child. |
688 #if !defined(DISABLE_NACL) && \ | 684 #if !defined(DISABLE_NACL) |
689 (!defined(CHROME_MULTIPLE_DLL) || defined(CHROME_MULTIPLE_DLL_CHILD)) | |
690 { switches::kNaClLoaderProcess, NaClMain }, | 685 { switches::kNaClLoaderProcess, NaClMain }, |
691 #endif // DISABLE_NACL | 686 #endif // DISABLE_NACL |
692 }; | 687 }; |
693 | 688 |
694 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { | 689 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { |
695 if (process_type == kMainFunctions[i].name) | 690 if (process_type == kMainFunctions[i].name) |
696 return kMainFunctions[i].function(main_function_params); | 691 return kMainFunctions[i].function(main_function_params); |
697 } | 692 } |
698 #endif | 693 #endif |
699 | 694 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 | 742 |
748 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 743 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
749 // 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 |
750 // this up for the browser process in a different manner. | 745 // this up for the browser process in a different manner. |
751 InitCrashReporter(); | 746 InitCrashReporter(); |
752 #endif | 747 #endif |
753 } | 748 } |
754 | 749 |
755 #endif // OS_MACOSX | 750 #endif // OS_MACOSX |
756 | 751 |
757 #if !defined(CHROME_MULTIPLE_DLL) || defined(CHROME_MULTIPLE_DLL_CHILD) | |
758 | |
759 content::ContentPluginClient* ChromeMainDelegate::CreateContentPluginClient() { | |
760 return &g_chrome_content_plugin_client.Get(); | |
761 } | |
762 | |
763 content::ContentRendererClient* | |
764 ChromeMainDelegate::CreateContentRendererClient() { | |
765 return &g_chrome_content_renderer_client.Get(); | |
766 } | |
767 | |
768 content::ContentUtilityClient* | |
769 ChromeMainDelegate::CreateContentUtilityClient() { | |
770 return &g_chrome_content_utility_client.Get(); | |
771 } | |
772 | |
773 content::ContentBrowserClient* | |
774 ChromeMainDelegate::CreateContentBrowserClient() { | |
775 return NULL; | |
776 } | |
777 | |
778 #else // In browser in multiple DLL mode. | |
779 | |
780 content::ContentBrowserClient* | 752 content::ContentBrowserClient* |
781 ChromeMainDelegate::CreateContentBrowserClient() { | 753 ChromeMainDelegate::CreateContentBrowserClient() { |
782 return &g_chrome_content_browser_client.Get(); | 754 return &g_chrome_content_browser_client.Get(); |
783 } | 755 } |
784 | 756 |
785 content::ContentPluginClient* ChromeMainDelegate::CreateContentPluginClient() { | 757 content::ContentPluginClient* ChromeMainDelegate::CreateContentPluginClient() { |
786 return NULL; | 758 // TODO(scottmg): http://crbug.com/237249 This will have to be split out into |
| 759 // browser and child parts. |
| 760 return &g_chrome_content_plugin_client.Get(); |
787 } | 761 } |
788 | 762 |
789 content::ContentRendererClient* | 763 content::ContentRendererClient* |
790 ChromeMainDelegate::CreateContentRendererClient() { | 764 ChromeMainDelegate::CreateContentRendererClient() { |
791 return NULL; | 765 return &g_chrome_content_renderer_client.Get(); |
792 } | 766 } |
793 | 767 |
794 content::ContentUtilityClient* | 768 content::ContentUtilityClient* |
795 ChromeMainDelegate::CreateContentUtilityClient() { | 769 ChromeMainDelegate::CreateContentUtilityClient() { |
796 return NULL; | 770 return &g_chrome_content_utility_client.Get(); |
797 } | 771 } |
798 | |
799 #endif | |
OLD | NEW |