| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/system_monitor/system_monitor.h" | 7 #include "base/system_monitor/system_monitor.h" |
| 8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
| 9 #include "chrome/common/chrome_paths.h" | |
| 10 #include "chrome/common/extensions/extension_l10n_util.h" | |
| 11 #include "chrome/utility/utility_thread.h" | |
| 12 #include "content/common/child_process.h" | 9 #include "content/common/child_process.h" |
| 10 #include "content/common/content_switches.h" |
| 13 #include "content/common/hi_res_timer_manager.h" | 11 #include "content/common/hi_res_timer_manager.h" |
| 14 #include "content/common/main_function_params.h" | 12 #include "content/common/main_function_params.h" |
| 15 #include "ui/base/ui_base_switches.h" | 13 #include "content/utility/utility_thread.h" |
| 16 | 14 |
| 17 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 18 #include "base/file_util.h" | |
| 19 #include "base/path_service.h" | |
| 20 #include "chrome/common/chrome_switches.h" | |
| 21 #include "content/common/sandbox_init_wrapper.h" | |
| 22 #include "sandbox/src/sandbox.h" | 16 #include "sandbox/src/sandbox.h" |
| 23 #endif // defined(OS_WIN) | 17 #endif |
| 24 | 18 |
| 25 // Mainline routine for running as the utility process. | 19 // Mainline routine for running as the utility process. |
| 26 int UtilityMain(const MainFunctionParams& parameters) { | 20 int UtilityMain(const MainFunctionParams& parameters) { |
| 27 // The main message loop of the utility process. | 21 // The main message loop of the utility process. |
| 28 MessageLoop main_message_loop; | 22 MessageLoop main_message_loop; |
| 29 base::PlatformThread::SetName("CrUtilityMain"); | 23 base::PlatformThread::SetName("CrUtilityMain"); |
| 30 | 24 |
| 31 base::SystemMonitor system_monitor; | 25 base::SystemMonitor system_monitor; |
| 32 HighResolutionTimerManager hi_res_timer_manager; | 26 HighResolutionTimerManager hi_res_timer_manager; |
| 33 | 27 |
| 34 ChildProcess utility_process; | 28 ChildProcess utility_process; |
| 35 utility_process.set_main_thread(new UtilityThread()); | 29 utility_process.set_main_thread(new UtilityThread()); |
| 30 |
| 36 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 37 // Load the pdf plugin before the sandbox is turned on. This is for Windows | |
| 38 // only because we need this DLL only on Windows. | |
| 39 FilePath pdf; | |
| 40 if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf) && | |
| 41 file_util::PathExists(pdf)) { | |
| 42 bool rv = !!LoadLibrary(pdf.value().c_str()); | |
| 43 DCHECK(rv) << "Couldn't load PDF plugin"; | |
| 44 } | |
| 45 | |
| 46 bool no_sandbox = parameters.command_line_.HasSwitch(switches::kNoSandbox); | 32 bool no_sandbox = parameters.command_line_.HasSwitch(switches::kNoSandbox); |
| 47 if (!no_sandbox) { | 33 if (!no_sandbox) { |
| 48 sandbox::TargetServices* target_services = | 34 sandbox::TargetServices* target_services = |
| 49 parameters.sandbox_info_.TargetServices(); | 35 parameters.sandbox_info_.TargetServices(); |
| 50 if (!target_services) | 36 if (!target_services) |
| 51 return false; | 37 return false; |
| 52 target_services->LowerToken(); | 38 target_services->LowerToken(); |
| 53 } | 39 } |
| 54 #endif | 40 #endif |
| 55 | 41 |
| 56 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 57 std::string lang = command_line->GetSwitchValueASCII(switches::kLang); | |
| 58 if (!lang.empty()) | |
| 59 extension_l10n_util::SetProcessLocale(lang); | |
| 60 | |
| 61 MessageLoop::current()->Run(); | 42 MessageLoop::current()->Run(); |
| 62 | 43 |
| 63 return 0; | 44 return 0; |
| 64 } | 45 } |
| OLD | NEW |