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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/debug/debugger.h" | 6 #include "base/debug/debugger.h" |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "content/common/child_process.h" | 11 #include "content/common/child_process.h" |
12 #include "content/ppapi_plugin/ppapi_thread.h" | 12 #include "content/ppapi_plugin/ppapi_thread.h" |
13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
14 #include "content/public/common/main_function_params.h" | 14 #include "content/public/common/main_function_params.h" |
15 #include "ppapi/proxy/proxy_module.h" | 15 #include "ppapi/proxy/proxy_module.h" |
16 #include "ui/base/ui_base_switches.h" | 16 #include "ui/base/ui_base_switches.h" |
17 | 17 |
18 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
19 #include "sandbox/win/src/sandbox.h" | 19 #include "sandbox/win/src/sandbox.h" |
20 #endif | 20 #endif |
21 | 21 |
22 #if defined(OS_LINUX) | 22 #if defined(OS_LINUX) |
23 #include "content/public/common/sandbox_init.h" | 23 #include "content/public/common/sandbox_init.h" |
24 #endif | 24 #endif |
25 | 25 |
| 26 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 27 #include <stdlib.h> |
| 28 #endif |
| 29 |
26 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
27 sandbox::TargetServices* g_target_services = NULL; | 31 sandbox::TargetServices* g_target_services = NULL; |
28 #else | 32 #else |
29 void* g_target_services = 0; | 33 void* g_target_services = 0; |
30 #endif | 34 #endif |
31 | 35 |
32 // Main function for starting the PPAPI plugin process. | 36 // Main function for starting the PPAPI plugin process. |
33 int PpapiPluginMain(const content::MainFunctionParams& parameters) { | 37 int PpapiPluginMain(const content::MainFunctionParams& parameters) { |
34 const CommandLine& command_line = parameters.command_line; | 38 const CommandLine& command_line = parameters.command_line; |
35 | 39 |
(...skipping 10 matching lines...) Expand all Loading... |
46 else | 50 else |
47 ChildProcess::WaitForDebugger("Ppapi"); | 51 ChildProcess::WaitForDebugger("Ppapi"); |
48 } | 52 } |
49 | 53 |
50 // Set the default locale to be the current UI language. WebKit uses ICU's | 54 // Set the default locale to be the current UI language. WebKit uses ICU's |
51 // default locale for some font settings (especially switching between | 55 // default locale for some font settings (especially switching between |
52 // Japanese and Chinese fonts for the same characters). | 56 // Japanese and Chinese fonts for the same characters). |
53 if (command_line.HasSwitch(switches::kLang)) { | 57 if (command_line.HasSwitch(switches::kLang)) { |
54 std::string locale = command_line.GetSwitchValueASCII(switches::kLang); | 58 std::string locale = command_line.GetSwitchValueASCII(switches::kLang); |
55 base::i18n::SetICUDefaultLocale(locale); | 59 base::i18n::SetICUDefaultLocale(locale); |
| 60 |
| 61 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 62 // TODO(shess): Flash appears to have a POSIX locale dependency |
| 63 // outside of the existing PPAPI ICU support. Certain games hang |
| 64 // while loading, and it seems related to datetime formatting. |
| 65 // http://crbug.com/155396 |
| 66 // http://crbug.com/155671 |
| 67 // |
| 68 // ICU can accept "en-US" or "en_US", but POSIX wants "en_US". |
| 69 // TODO(shess): "en_US.UTF-8" might be even better. |
| 70 std::replace(locale.begin(), locale.end(), '-', '_'); |
| 71 setlocale(LC_ALL, locale.c_str()); |
| 72 setenv("LANG", locale.c_str(), 0); |
| 73 #endif |
56 } | 74 } |
57 | 75 |
58 MessageLoop main_message_loop; | 76 MessageLoop main_message_loop; |
59 base::PlatformThread::SetName("CrPPAPIMain"); | 77 base::PlatformThread::SetName("CrPPAPIMain"); |
60 | 78 |
61 #if defined(OS_LINUX) | 79 #if defined(OS_LINUX) |
62 content::InitializeSandbox(); | 80 content::InitializeSandbox(); |
63 #endif | 81 #endif |
64 | 82 |
65 ChildProcess ppapi_process; | 83 ChildProcess ppapi_process; |
66 ppapi_process.set_main_thread( | 84 ppapi_process.set_main_thread( |
67 new PpapiThread(parameters.command_line, false)); // Not a broker. | 85 new PpapiThread(parameters.command_line, false)); // Not a broker. |
68 | 86 |
69 main_message_loop.Run(); | 87 main_message_loop.Run(); |
70 return 0; | 88 return 0; |
71 } | 89 } |
OLD | NEW |