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/debug/crash_logging.h" | 10 #include "base/debug/crash_logging.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "content/public/plugin/content_plugin_client.h" | 29 #include "content/public/plugin/content_plugin_client.h" |
30 #include "ipc/ipc_channel_handle.h" | 30 #include "ipc/ipc_channel_handle.h" |
31 #include "ipc/ipc_platform_file.h" | 31 #include "ipc/ipc_platform_file.h" |
32 #include "ipc/ipc_sync_channel.h" | 32 #include "ipc/ipc_sync_channel.h" |
33 #include "ipc/ipc_sync_message_filter.h" | 33 #include "ipc/ipc_sync_message_filter.h" |
34 #include "ppapi/c/dev/ppp_network_state_dev.h" | 34 #include "ppapi/c/dev/ppp_network_state_dev.h" |
35 #include "ppapi/c/pp_errors.h" | 35 #include "ppapi/c/pp_errors.h" |
36 #include "ppapi/c/ppp.h" | 36 #include "ppapi/c/ppp.h" |
37 #include "ppapi/proxy/interface_list.h" | 37 #include "ppapi/proxy/interface_list.h" |
38 #include "ppapi/proxy/plugin_globals.h" | 38 #include "ppapi/proxy/plugin_globals.h" |
| 39 #include "ppapi/proxy/plugin_message_filter.h" |
39 #include "ppapi/proxy/ppapi_messages.h" | 40 #include "ppapi/proxy/ppapi_messages.h" |
| 41 #include "ppapi/proxy/resource_reply_thread_registrar.h" |
40 #include "third_party/WebKit/public/web/WebKit.h" | 42 #include "third_party/WebKit/public/web/WebKit.h" |
41 #include "ui/base/ui_base_switches.h" | 43 #include "ui/base/ui_base_switches.h" |
42 | 44 |
43 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
44 #include "base/win/win_util.h" | 46 #include "base/win/win_util.h" |
45 #include "base/win/windows_version.h" | 47 #include "base/win/windows_version.h" |
46 #include "sandbox/win/src/sandbox.h" | 48 #include "sandbox/win/src/sandbox.h" |
47 #elif defined(OS_MACOSX) | 49 #elif defined(OS_MACOSX) |
48 #include "content/common/sandbox_init_mac.h" | 50 #include "content/common/sandbox_init_mac.h" |
49 #endif | 51 #endif |
(...skipping 15 matching lines...) Expand all Loading... |
65 local_pp_module_( | 67 local_pp_module_( |
66 base::RandInt(0, std::numeric_limits<PP_Module>::max())), | 68 base::RandInt(0, std::numeric_limits<PP_Module>::max())), |
67 next_plugin_dispatcher_id_(1) { | 69 next_plugin_dispatcher_id_(1) { |
68 ppapi::proxy::PluginGlobals* globals = ppapi::proxy::PluginGlobals::Get(); | 70 ppapi::proxy::PluginGlobals* globals = ppapi::proxy::PluginGlobals::Get(); |
69 globals->set_plugin_proxy_delegate(this); | 71 globals->set_plugin_proxy_delegate(this); |
70 globals->set_command_line( | 72 globals->set_command_line( |
71 command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs)); | 73 command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs)); |
72 | 74 |
73 webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl); | 75 webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl); |
74 blink::initialize(webkit_platform_support_.get()); | 76 blink::initialize(webkit_platform_support_.get()); |
| 77 |
| 78 if (!is_broker_) { |
| 79 channel()->AddFilter( |
| 80 new ppapi::proxy::PluginMessageFilter( |
| 81 NULL, globals->resource_reply_thread_registrar())); |
| 82 } |
75 } | 83 } |
76 | 84 |
77 PpapiThread::~PpapiThread() { | 85 PpapiThread::~PpapiThread() { |
78 } | 86 } |
79 | 87 |
80 void PpapiThread::Shutdown() { | 88 void PpapiThread::Shutdown() { |
81 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); | 89 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); |
82 if (plugin_entry_points_.shutdown_module) | 90 if (plugin_entry_points_.shutdown_module) |
83 plugin_entry_points_.shutdown_module(); | 91 plugin_entry_points_.shutdown_module(); |
84 webkit_platform_support_->Shutdown(); | 92 webkit_platform_support_->Shutdown(); |
(...skipping 12 matching lines...) Expand all Loading... |
97 // browser process. Messages from the renderer process are sent via a different | 105 // browser process. Messages from the renderer process are sent via a different |
98 // channel that ends up at Dispatcher::OnMessageReceived. | 106 // channel that ends up at Dispatcher::OnMessageReceived. |
99 bool PpapiThread::OnControlMessageReceived(const IPC::Message& msg) { | 107 bool PpapiThread::OnControlMessageReceived(const IPC::Message& msg) { |
100 bool handled = true; | 108 bool handled = true; |
101 IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) | 109 IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) |
102 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnLoadPlugin) | 110 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnLoadPlugin) |
103 IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnCreateChannel) | 111 IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnCreateChannel) |
104 IPC_MESSAGE_HANDLER(PpapiMsg_SetNetworkState, OnSetNetworkState) | 112 IPC_MESSAGE_HANDLER(PpapiMsg_SetNetworkState, OnSetNetworkState) |
105 IPC_MESSAGE_HANDLER(PpapiMsg_Crash, OnCrash) | 113 IPC_MESSAGE_HANDLER(PpapiMsg_Crash, OnCrash) |
106 IPC_MESSAGE_HANDLER(PpapiMsg_Hang, OnHang) | 114 IPC_MESSAGE_HANDLER(PpapiMsg_Hang, OnHang) |
107 IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnResourceReply) | |
108 IPC_MESSAGE_UNHANDLED(handled = false) | 115 IPC_MESSAGE_UNHANDLED(handled = false) |
109 IPC_END_MESSAGE_MAP() | 116 IPC_END_MESSAGE_MAP() |
110 return handled; | 117 return handled; |
111 } | 118 } |
112 | 119 |
113 void PpapiThread::OnChannelConnected(int32 peer_pid) { | 120 void PpapiThread::OnChannelConnected(int32 peer_pid) { |
114 ChildThread::OnChannelConnected(peer_pid); | 121 ChildThread::OnChannelConnected(peer_pid); |
115 #if defined(OS_WIN) | 122 #if defined(OS_WIN) |
116 if (is_broker_) | 123 if (is_broker_) |
117 peer_handle_.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid)); | 124 peer_handle_.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid)); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded. | 355 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded. |
349 !SetupRendererChannel(renderer_pid, renderer_child_id, incognito, | 356 !SetupRendererChannel(renderer_pid, renderer_child_id, incognito, |
350 &channel_handle)) { | 357 &channel_handle)) { |
351 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); | 358 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); |
352 return; | 359 return; |
353 } | 360 } |
354 | 361 |
355 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); | 362 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); |
356 } | 363 } |
357 | 364 |
358 void PpapiThread::OnResourceReply( | |
359 const ppapi::proxy::ResourceMessageReplyParams& reply_params, | |
360 const IPC::Message& nested_msg) { | |
361 ppapi::proxy::PluginDispatcher::DispatchResourceReply(reply_params, | |
362 nested_msg); | |
363 } | |
364 | |
365 void PpapiThread::OnSetNetworkState(bool online) { | 365 void PpapiThread::OnSetNetworkState(bool online) { |
366 // Note the browser-process side shouldn't send us these messages in the | 366 // Note the browser-process side shouldn't send us these messages in the |
367 // first unless the plugin has dev permissions, so we don't need to check | 367 // first unless the plugin has dev permissions, so we don't need to check |
368 // again here. We don't want random plugins depending on this dev interface. | 368 // again here. We don't want random plugins depending on this dev interface. |
369 if (!plugin_entry_points_.get_interface) | 369 if (!plugin_entry_points_.get_interface) |
370 return; | 370 return; |
371 const PPP_NetworkState_Dev* ns = static_cast<const PPP_NetworkState_Dev*>( | 371 const PPP_NetworkState_Dev* ns = static_cast<const PPP_NetworkState_Dev*>( |
372 plugin_entry_points_.get_interface(PPP_NETWORK_STATE_DEV_INTERFACE)); | 372 plugin_entry_points_.get_interface(PPP_NETWORK_STATE_DEV_INTERFACE)); |
373 if (ns) | 373 if (ns) |
374 ns->SetOnLine(PP_FromBool(online)); | 374 ns->SetOnLine(PP_FromBool(online)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 histogram_name.str(), | 465 histogram_name.str(), |
466 1, | 466 1, |
467 LOAD_RESULT_MAX, | 467 LOAD_RESULT_MAX, |
468 LOAD_RESULT_MAX + 1, | 468 LOAD_RESULT_MAX + 1, |
469 base::HistogramBase::kUmaTargetedHistogramFlag); | 469 base::HistogramBase::kUmaTargetedHistogramFlag); |
470 | 470 |
471 histogram->Add(result); | 471 histogram->Add(result); |
472 } | 472 } |
473 | 473 |
474 } // namespace content | 474 } // namespace content |
OLD | NEW |