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 "ppapi/shared_impl/api_id.h" | 42 #include "ppapi/shared_impl/api_id.h" |
41 #include "third_party/WebKit/public/web/WebKit.h" | 43 #include "third_party/WebKit/public/web/WebKit.h" |
42 #include "ui/base/ui_base_switches.h" | 44 #include "ui/base/ui_base_switches.h" |
43 | 45 |
44 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
45 #include "base/win/win_util.h" | 47 #include "base/win/win_util.h" |
46 #include "base/win/windows_version.h" | 48 #include "base/win/windows_version.h" |
47 #include "sandbox/win/src/sandbox.h" | 49 #include "sandbox/win/src/sandbox.h" |
48 #elif defined(OS_MACOSX) | 50 #elif defined(OS_MACOSX) |
49 #include "content/common/sandbox_init_mac.h" | 51 #include "content/common/sandbox_init_mac.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 globals->set_command_line( | 98 globals->set_command_line( |
97 command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs)); | 99 command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs)); |
98 | 100 |
99 webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl); | 101 webkit_platform_support_.reset(new PpapiWebKitPlatformSupportImpl); |
100 blink::initialize(webkit_platform_support_.get()); | 102 blink::initialize(webkit_platform_support_.get()); |
101 | 103 |
102 // Register interfaces that expect messages from the browser process. Please | 104 // Register interfaces that expect messages from the browser process. Please |
103 // note that only those InterfaceProxy-based ones require registration. | 105 // note that only those InterfaceProxy-based ones require registration. |
104 AddRoute(ppapi::API_ID_PPB_HOSTRESOLVER_PRIVATE, | 106 AddRoute(ppapi::API_ID_PPB_HOSTRESOLVER_PRIVATE, |
105 &dispatcher_message_listener_); | 107 &dispatcher_message_listener_); |
108 | |
109 if (!is_broker_) { | |
110 channel()->AddFilter( | |
111 new ppapi::proxy::PluginMessageFilter( | |
dmichael (off chromium)
2013/12/11 21:30:36
Why do we need this filter *and* the one the dispa
yzshen1
2013/12/11 22:22:07
This is the channel between the browser and the pl
| |
112 NULL, globals->resource_reply_thread_registrar())); | |
dmichael (off chromium)
2013/12/11 21:30:36
Why are you passing a NULL GloballyInstanceIDSet n
yzshen1
2013/12/11 22:22:07
Because between the browser and the plugin we don'
| |
113 } | |
106 } | 114 } |
107 | 115 |
108 PpapiThread::~PpapiThread() { | 116 PpapiThread::~PpapiThread() { |
109 } | 117 } |
110 | 118 |
111 void PpapiThread::Shutdown() { | 119 void PpapiThread::Shutdown() { |
112 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); | 120 ppapi::proxy::PluginGlobals::Get()->set_plugin_proxy_delegate(NULL); |
113 if (plugin_entry_points_.shutdown_module) | 121 if (plugin_entry_points_.shutdown_module) |
114 plugin_entry_points_.shutdown_module(); | 122 plugin_entry_points_.shutdown_module(); |
115 webkit_platform_support_->Shutdown(); | 123 webkit_platform_support_->Shutdown(); |
(...skipping 12 matching lines...) Expand all Loading... | |
128 // browser process. Messages from the renderer process are sent via a different | 136 // browser process. Messages from the renderer process are sent via a different |
129 // channel that ends up at Dispatcher::OnMessageReceived. | 137 // channel that ends up at Dispatcher::OnMessageReceived. |
130 bool PpapiThread::OnControlMessageReceived(const IPC::Message& msg) { | 138 bool PpapiThread::OnControlMessageReceived(const IPC::Message& msg) { |
131 bool handled = true; | 139 bool handled = true; |
132 IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) | 140 IPC_BEGIN_MESSAGE_MAP(PpapiThread, msg) |
133 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnLoadPlugin) | 141 IPC_MESSAGE_HANDLER(PpapiMsg_LoadPlugin, OnLoadPlugin) |
134 IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnCreateChannel) | 142 IPC_MESSAGE_HANDLER(PpapiMsg_CreateChannel, OnCreateChannel) |
135 IPC_MESSAGE_HANDLER(PpapiMsg_SetNetworkState, OnSetNetworkState) | 143 IPC_MESSAGE_HANDLER(PpapiMsg_SetNetworkState, OnSetNetworkState) |
136 IPC_MESSAGE_HANDLER(PpapiMsg_Crash, OnCrash) | 144 IPC_MESSAGE_HANDLER(PpapiMsg_Crash, OnCrash) |
137 IPC_MESSAGE_HANDLER(PpapiMsg_Hang, OnHang) | 145 IPC_MESSAGE_HANDLER(PpapiMsg_Hang, OnHang) |
138 IPC_MESSAGE_HANDLER(PpapiPluginMsg_ResourceReply, OnResourceReply) | |
139 IPC_MESSAGE_UNHANDLED(handled = false) | 146 IPC_MESSAGE_UNHANDLED(handled = false) |
140 IPC_END_MESSAGE_MAP() | 147 IPC_END_MESSAGE_MAP() |
141 return handled; | 148 return handled; |
142 } | 149 } |
143 | 150 |
144 void PpapiThread::OnChannelConnected(int32 peer_pid) { | 151 void PpapiThread::OnChannelConnected(int32 peer_pid) { |
145 ChildThread::OnChannelConnected(peer_pid); | 152 ChildThread::OnChannelConnected(peer_pid); |
146 #if defined(OS_WIN) | 153 #if defined(OS_WIN) |
147 if (is_broker_) | 154 if (is_broker_) |
148 peer_handle_.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid)); | 155 peer_handle_.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid)); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded. | 386 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded. |
380 !SetupRendererChannel(renderer_pid, renderer_child_id, incognito, | 387 !SetupRendererChannel(renderer_pid, renderer_child_id, incognito, |
381 &channel_handle)) { | 388 &channel_handle)) { |
382 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); | 389 Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle())); |
383 return; | 390 return; |
384 } | 391 } |
385 | 392 |
386 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); | 393 Send(new PpapiHostMsg_ChannelCreated(channel_handle)); |
387 } | 394 } |
388 | 395 |
389 void PpapiThread::OnResourceReply( | |
390 const ppapi::proxy::ResourceMessageReplyParams& reply_params, | |
391 const IPC::Message& nested_msg) { | |
392 ppapi::proxy::PluginDispatcher::DispatchResourceReply(reply_params, | |
393 nested_msg); | |
394 } | |
395 | |
396 void PpapiThread::OnSetNetworkState(bool online) { | 396 void PpapiThread::OnSetNetworkState(bool online) { |
397 // Note the browser-process side shouldn't send us these messages in the | 397 // Note the browser-process side shouldn't send us these messages in the |
398 // first unless the plugin has dev permissions, so we don't need to check | 398 // first unless the plugin has dev permissions, so we don't need to check |
399 // again here. We don't want random plugins depending on this dev interface. | 399 // again here. We don't want random plugins depending on this dev interface. |
400 if (!plugin_entry_points_.get_interface) | 400 if (!plugin_entry_points_.get_interface) |
401 return; | 401 return; |
402 const PPP_NetworkState_Dev* ns = static_cast<const PPP_NetworkState_Dev*>( | 402 const PPP_NetworkState_Dev* ns = static_cast<const PPP_NetworkState_Dev*>( |
403 plugin_entry_points_.get_interface(PPP_NETWORK_STATE_DEV_INTERFACE)); | 403 plugin_entry_points_.get_interface(PPP_NETWORK_STATE_DEV_INTERFACE)); |
404 if (ns) | 404 if (ns) |
405 ns->SetOnLine(PP_FromBool(online)); | 405 ns->SetOnLine(PP_FromBool(online)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 histogram_name.str(), | 496 histogram_name.str(), |
497 1, | 497 1, |
498 LOAD_RESULT_MAX, | 498 LOAD_RESULT_MAX, |
499 LOAD_RESULT_MAX + 1, | 499 LOAD_RESULT_MAX + 1, |
500 base::HistogramBase::kUmaTargetedHistogramFlag); | 500 base::HistogramBase::kUmaTargetedHistogramFlag); |
501 | 501 |
502 histogram->Add(result); | 502 histogram->Add(result); |
503 } | 503 } |
504 | 504 |
505 } // namespace content | 505 } // namespace content |
OLD | NEW |