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 "content/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "content/common/child_process.h" | 14 #include "content/common/child_process.h" |
15 #include "content/common/child_process_messages.h" | 15 #include "content/common/child_process_messages.h" |
16 #include "content/ppapi_plugin/broker_process_dispatcher.h" | 16 #include "content/ppapi_plugin/broker_process_dispatcher.h" |
17 #include "content/ppapi_plugin/plugin_process_dispatcher.h" | 17 #include "content/ppapi_plugin/plugin_process_dispatcher.h" |
18 #include "content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h" | 18 #include "content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h" |
19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
yzshen1
2012/04/18 17:57:22
This may not be needed anymore.
| |
20 #include "content/public/common/sandbox_init.h" | 20 #include "content/public/common/sandbox_init.h" |
21 #include "ipc/ipc_channel_handle.h" | 21 #include "ipc/ipc_channel_handle.h" |
22 #include "ipc/ipc_sync_channel.h" | 22 #include "ipc/ipc_sync_channel.h" |
23 #include "ppapi/c/dev/ppp_network_state_dev.h" | 23 #include "ppapi/c/dev/ppp_network_state_dev.h" |
24 #include "ppapi/c/pp_errors.h" | 24 #include "ppapi/c/pp_errors.h" |
25 #include "ppapi/c/ppp.h" | 25 #include "ppapi/c/ppp.h" |
26 #include "ppapi/c/private/ppp_flash_browser_operations.h" | 26 #include "ppapi/c/private/ppp_flash_browser_operations.h" |
27 #include "ppapi/proxy/plugin_globals.h" | 27 #include "ppapi/proxy/plugin_globals.h" |
28 #include "ppapi/proxy/ppapi_messages.h" | 28 #include "ppapi/proxy/ppapi_messages.h" |
29 #include "ppapi/proxy/interface_list.h" | 29 #include "ppapi/proxy/interface_list.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
31 #include "webkit/plugins/plugin_switches.h" | |
31 | 32 |
32 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
33 #include "sandbox/src/sandbox.h" | 34 #include "sandbox/src/sandbox.h" |
34 #elif defined(OS_MACOSX) | 35 #elif defined(OS_MACOSX) |
35 #include "content/common/sandbox_init_mac.h" | 36 #include "content/common/sandbox_init_mac.h" |
36 #endif | 37 #endif |
37 | 38 |
38 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
39 extern sandbox::TargetServices* g_target_services; | 40 extern sandbox::TargetServices* g_target_services; |
40 #else | 41 #else |
41 extern void* g_target_services; | 42 extern void* g_target_services; |
42 #endif | 43 #endif |
43 | 44 |
44 typedef int32_t (*InitializeBrokerFunc) | 45 typedef int32_t (*InitializeBrokerFunc) |
45 (PP_ConnectInstance_Func* connect_instance_func); | 46 (PP_ConnectInstance_Func* connect_instance_func); |
46 | 47 |
47 PpapiThread::PpapiThread(bool is_broker) | 48 PpapiThread::PpapiThread(const CommandLine& command_line, bool is_broker) |
48 : is_broker_(is_broker), | 49 : is_broker_(is_broker), |
49 get_plugin_interface_(NULL), | 50 get_plugin_interface_(NULL), |
50 connect_instance_func_(NULL), | 51 connect_instance_func_(NULL), |
51 local_pp_module_( | 52 local_pp_module_( |
52 base::RandInt(0, std::numeric_limits<PP_Module>::max())), | 53 base::RandInt(0, std::numeric_limits<PP_Module>::max())), |
53 next_plugin_dispatcher_id_(1) { | 54 next_plugin_dispatcher_id_(1) { |
54 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(this); | 55 ppapi::proxy::PluginGlobals* globals = ppapi::proxy::PluginGlobals::Get(); |
56 globals->set_plugin_proxy_delegate(this); | |
57 globals->set_command_line( | |
58 command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs)); | |
59 | |
55 webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl); | 60 webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl); |
56 WebKit::initialize(webkit_platform_support_.get()); | 61 WebKit::initialize(webkit_platform_support_.get()); |
57 } | 62 } |
58 | 63 |
59 PpapiThread::~PpapiThread() { | 64 PpapiThread::~PpapiThread() { |
60 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); | 65 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); |
61 | 66 |
62 if (!library_.is_valid()) | 67 if (!library_.is_valid()) |
63 return; | 68 return; |
64 | 69 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 | 365 |
361 // From here, the dispatcher will manage its own lifetime according to the | 366 // From here, the dispatcher will manage its own lifetime according to the |
362 // lifetime of the attached channel. | 367 // lifetime of the attached channel. |
363 return true; | 368 return true; |
364 } | 369 } |
365 | 370 |
366 void PpapiThread::SavePluginName(const FilePath& path) { | 371 void PpapiThread::SavePluginName(const FilePath& path) { |
367 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( | 372 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( |
368 path.BaseName().AsUTF8Unsafe()); | 373 path.BaseName().AsUTF8Unsafe()); |
369 } | 374 } |
OLD | NEW |