| 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/environment.h" | 8 #include "base/environment.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 process_type == switches::kWorkerProcess || | 245 process_type == switches::kWorkerProcess || |
| 246 process_type == switches::kNaClLoaderProcess || | 246 process_type == switches::kNaClLoaderProcess || |
| 247 process_type == switches::kPpapiPluginProcess || | 247 process_type == switches::kPpapiPluginProcess || |
| 248 process_type == switches::kPpapiBrokerProcess || | 248 process_type == switches::kPpapiBrokerProcess || |
| 249 process_type == switches::kGpuProcess || | 249 process_type == switches::kGpuProcess || |
| 250 #endif | 250 #endif |
| 251 process_type == switches::kRendererProcess || | 251 process_type == switches::kRendererProcess || |
| 252 process_type == switches::kUtilityProcess; | 252 process_type == switches::kUtilityProcess; |
| 253 } | 253 } |
| 254 | 254 |
| 255 #if defined(OS_MACOSX) | |
| 256 // Update the name shown in Activity Monitor so users are less likely to ask | |
| 257 // why Chrome has so many processes. | |
| 258 void SetMacProcessName(const CommandLine& command_line) { | |
| 259 std::string process_type = | |
| 260 command_line.GetSwitchValueASCII(switches::kProcessType); | |
| 261 // Don't worry about the browser process, its gets the stock name. | |
| 262 int name_id = 0; | |
| 263 if (command_line.HasSwitch(switches::kExtensionProcess)) { | |
| 264 name_id = IDS_WORKER_APP_NAME; | |
| 265 } else if (process_type == switches::kRendererProcess) { | |
| 266 name_id = IDS_RENDERER_APP_NAME; | |
| 267 } else if (process_type == switches::kPluginProcess || | |
| 268 process_type == switches::kPpapiPluginProcess) { | |
| 269 name_id = IDS_PLUGIN_APP_NAME; | |
| 270 } else if (process_type == switches::kUtilityProcess) { | |
| 271 name_id = IDS_UTILITY_APP_NAME; | |
| 272 } | |
| 273 if (name_id) { | |
| 274 NSString* app_name = l10n_util::GetNSString(name_id); | |
| 275 base::mac::SetProcessName(base::mac::NSToCFCast(app_name)); | |
| 276 } | |
| 277 } | |
| 278 | |
| 279 #endif // defined(OS_MACOSX) | |
| 280 | |
| 281 #if defined(OS_POSIX) | 255 #if defined(OS_POSIX) |
| 282 // Check for --version and --product-version; return true if we encountered | 256 // Check for --version and --product-version; return true if we encountered |
| 283 // one of these switches and should exit now. | 257 // one of these switches and should exit now. |
| 284 bool HandleVersionSwitches(const CommandLine& command_line) { | 258 bool HandleVersionSwitches(const CommandLine& command_line) { |
| 285 const chrome::VersionInfo version_info; | 259 const chrome::VersionInfo version_info; |
| 286 | 260 |
| 287 #if !defined(OS_MACOSX) | 261 #if !defined(OS_MACOSX) |
| 288 if (command_line.HasSwitch(switches::kProductVersion)) { | 262 if (command_line.HasSwitch(switches::kProductVersion)) { |
| 289 printf("%s\n", version_info.Version().c_str()); | 263 printf("%s\n", version_info.Version().c_str()); |
| 290 return true; | 264 return true; |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 ResourceBundle::InitSharedInstanceWithLocale(locale, NULL); | 688 ResourceBundle::InitSharedInstanceWithLocale(locale, NULL); |
| 715 | 689 |
| 716 base::FilePath resources_pack_path; | 690 base::FilePath resources_pack_path; |
| 717 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); | 691 PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); |
| 718 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 692 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
| 719 resources_pack_path, ui::SCALE_FACTOR_NONE); | 693 resources_pack_path, ui::SCALE_FACTOR_NONE); |
| 720 #endif | 694 #endif |
| 721 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << | 695 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << |
| 722 locale; | 696 locale; |
| 723 | 697 |
| 724 #if defined(OS_MACOSX) | |
| 725 // Update the process name (need resources to get the strings, so | |
| 726 // only do this when ResourcesBundle has been initialized). | |
| 727 SetMacProcessName(command_line); | |
| 728 #endif // defined(OS_MACOSX) | |
| 729 | |
| 730 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) | 698 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 731 if (process_type == switches::kUtilityProcess) | 699 if (process_type == switches::kUtilityProcess) |
| 732 chrome::ChromeContentUtilityClient::PreSandboxStartup(); | 700 chrome::ChromeContentUtilityClient::PreSandboxStartup(); |
| 733 #endif | 701 #endif |
| 734 } | 702 } |
| 735 | 703 |
| 736 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 704 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 737 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain | 705 // Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain |
| 738 // sets this up for the browser process in a different manner. Zygotes | 706 // sets this up for the browser process in a different manner. Zygotes |
| 739 // need to call InitCrashReporter() in RunZygote(). | 707 // need to call InitCrashReporter() in RunZygote(). |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 } | 849 } |
| 882 | 850 |
| 883 content::ContentUtilityClient* | 851 content::ContentUtilityClient* |
| 884 ChromeMainDelegate::CreateContentUtilityClient() { | 852 ChromeMainDelegate::CreateContentUtilityClient() { |
| 885 #if defined(CHROME_MULTIPLE_DLL_BROWSER) | 853 #if defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 886 return NULL; | 854 return NULL; |
| 887 #else | 855 #else |
| 888 return &g_chrome_content_utility_client.Get(); | 856 return &g_chrome_content_utility_client.Get(); |
| 889 #endif | 857 #endif |
| 890 } | 858 } |
| OLD | NEW |