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/renderer/pepper/pepper_plugin_delegate_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 80 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 81 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
82 #include "ui/gfx/size.h" | 82 #include "ui/gfx/size.h" |
83 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 83 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
84 #include "webkit/plugins/npapi/webplugin.h" | 84 #include "webkit/plugins/npapi/webplugin.h" |
85 #include "webkit/plugins/ppapi/plugin_module.h" | 85 #include "webkit/plugins/ppapi/plugin_module.h" |
86 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 86 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
87 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" | 87 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
88 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" | 88 #include "webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.h" |
89 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" | 89 #include "webkit/plugins/ppapi/ppb_tcp_socket_private_impl.h" |
90 #include "webkit/plugins/ppapi/ppb_udp_socket_private_impl.h" | |
91 #include "webkit/plugins/ppapi/resource_helper.h" | 90 #include "webkit/plugins/ppapi/resource_helper.h" |
92 #include "webkit/plugins/webplugininfo.h" | 91 #include "webkit/plugins/webplugininfo.h" |
93 | 92 |
94 using WebKit::WebView; | 93 using WebKit::WebView; |
95 using WebKit::WebFrame; | 94 using WebKit::WebFrame; |
96 | 95 |
97 namespace content { | 96 namespace content { |
98 | 97 |
99 namespace { | 98 namespace { |
100 | 99 |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 if (tcp_sockets_.Lookup(socket_id)) | 1180 if (tcp_sockets_.Lookup(socket_id)) |
1182 tcp_sockets_.Remove(socket_id); | 1181 tcp_sockets_.Remove(socket_id); |
1183 } | 1182 } |
1184 | 1183 |
1185 void PepperPluginDelegateImpl::RegisterTCPSocket( | 1184 void PepperPluginDelegateImpl::RegisterTCPSocket( |
1186 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, | 1185 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, |
1187 uint32 socket_id) { | 1186 uint32 socket_id) { |
1188 tcp_sockets_.AddWithID(socket, socket_id); | 1187 tcp_sockets_.AddWithID(socket, socket_id); |
1189 } | 1188 } |
1190 | 1189 |
1191 uint32 PepperPluginDelegateImpl::UDPSocketCreate() { | |
1192 uint32 socket_id = 0; | |
1193 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create( | |
1194 render_view_->routing_id(), 0, &socket_id)); | |
1195 return socket_id; | |
1196 } | |
1197 | |
1198 void PepperPluginDelegateImpl::UDPSocketSetBoolSocketFeature( | |
1199 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket, | |
1200 uint32 socket_id, | |
1201 int32_t name, | |
1202 bool value) { | |
1203 render_view_->Send( | |
1204 new PpapiHostMsg_PPBUDPSocket_SetBoolSocketFeature( | |
1205 render_view_->routing_id(), socket_id, name, value)); | |
1206 } | |
1207 | |
1208 void PepperPluginDelegateImpl::UDPSocketBind( | |
1209 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket, | |
1210 uint32 socket_id, | |
1211 const PP_NetAddress_Private& addr) { | |
1212 if (!udp_sockets_.Lookup(socket_id)) | |
1213 udp_sockets_.AddWithID(socket, socket_id); | |
1214 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind( | |
1215 render_view_->routing_id(), socket_id, addr)); | |
1216 } | |
1217 | |
1218 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id, | |
1219 int32_t num_bytes) { | |
1220 DCHECK(udp_sockets_.Lookup(socket_id)); | |
1221 render_view_->Send( | |
1222 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes)); | |
1223 } | |
1224 | |
1225 void PepperPluginDelegateImpl::UDPSocketSendTo( | |
1226 uint32 socket_id, | |
1227 const std::string& buffer, | |
1228 const PP_NetAddress_Private& net_addr) { | |
1229 DCHECK(udp_sockets_.Lookup(socket_id)); | |
1230 render_view_->Send( | |
1231 new PpapiHostMsg_PPBUDPSocket_SendTo(render_view_->routing_id(), | |
1232 socket_id, buffer, net_addr)); | |
1233 } | |
1234 | |
1235 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) { | |
1236 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because it | |
1237 // can be called before UDPSocketBind is called. | |
1238 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id)); | |
1239 if (udp_sockets_.Lookup(socket_id)) | |
1240 udp_sockets_.Remove(socket_id); | |
1241 } | |
1242 | |
1243 void PepperPluginDelegateImpl::TCPServerSocketListen( | 1190 void PepperPluginDelegateImpl::TCPServerSocketListen( |
1244 PP_Resource socket_resource, | 1191 PP_Resource socket_resource, |
1245 const PP_NetAddress_Private& addr, | 1192 const PP_NetAddress_Private& addr, |
1246 int32_t backlog) { | 1193 int32_t backlog) { |
1247 render_view_->Send( | 1194 render_view_->Send( |
1248 new PpapiHostMsg_PPBTCPServerSocket_Listen( | 1195 new PpapiHostMsg_PPBTCPServerSocket_Listen( |
1249 render_view_->routing_id(), 0, socket_resource, addr, backlog)); | 1196 render_view_->routing_id(), 0, socket_resource, addr, backlog)); |
1250 } | 1197 } |
1251 | 1198 |
1252 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) { | 1199 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 | 1424 |
1478 bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) { | 1425 bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) { |
1479 bool handled = true; | 1426 bool handled = true; |
1480 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message) | 1427 IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message) |
1481 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, | 1428 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, |
1482 OnTCPSocketConnectACK) | 1429 OnTCPSocketConnectACK) |
1483 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, | 1430 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, |
1484 OnTCPSocketSSLHandshakeACK) | 1431 OnTCPSocketSSLHandshakeACK) |
1485 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) | 1432 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) |
1486 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) | 1433 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) |
1487 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_BindACK, OnUDPSocketBindACK) | |
1488 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK, | |
1489 OnUDPSocketRecvFromACK) | |
1490 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnUDPSocketSendToACK) | |
1491 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, | 1434 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, |
1492 OnTCPServerSocketListenACK) | 1435 OnTCPServerSocketListenACK) |
1493 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, | 1436 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, |
1494 OnTCPServerSocketAcceptACK) | 1437 OnTCPServerSocketAcceptACK) |
1495 IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK, | 1438 IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK, |
1496 OnHostResolverResolveACK) | 1439 OnHostResolverResolveACK) |
1497 IPC_MESSAGE_UNHANDLED(handled = false) | 1440 IPC_MESSAGE_UNHANDLED(handled = false) |
1498 IPC_END_MESSAGE_MAP() | 1441 IPC_END_MESSAGE_MAP() |
1499 return handled; | 1442 return handled; |
1500 } | 1443 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id, | 1486 void PepperPluginDelegateImpl::OnTCPSocketWriteACK(uint32 plugin_dispatcher_id, |
1544 uint32 socket_id, | 1487 uint32 socket_id, |
1545 bool succeeded, | 1488 bool succeeded, |
1546 int32_t bytes_written) { | 1489 int32_t bytes_written) { |
1547 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = | 1490 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket = |
1548 tcp_sockets_.Lookup(socket_id); | 1491 tcp_sockets_.Lookup(socket_id); |
1549 if (socket) | 1492 if (socket) |
1550 socket->OnWriteCompleted(succeeded, bytes_written); | 1493 socket->OnWriteCompleted(succeeded, bytes_written); |
1551 } | 1494 } |
1552 | 1495 |
1553 void PepperPluginDelegateImpl::OnUDPSocketBindACK( | |
1554 uint32 plugin_dispatcher_id, | |
1555 uint32 socket_id, | |
1556 bool succeeded, | |
1557 const PP_NetAddress_Private& addr) { | |
1558 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = | |
1559 udp_sockets_.Lookup(socket_id); | |
1560 if (socket) | |
1561 socket->OnBindCompleted(succeeded, addr); | |
1562 if (!succeeded) | |
1563 udp_sockets_.Remove(socket_id); | |
1564 } | |
1565 | |
1566 void PepperPluginDelegateImpl::OnUDPSocketRecvFromACK( | |
1567 uint32 plugin_dispatcher_id, | |
1568 uint32 socket_id, | |
1569 bool succeeded, | |
1570 const std::string& data, | |
1571 const PP_NetAddress_Private& remote_addr) { | |
1572 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = | |
1573 udp_sockets_.Lookup(socket_id); | |
1574 if (socket) | |
1575 socket->OnRecvFromCompleted(succeeded, data, remote_addr); | |
1576 } | |
1577 | |
1578 void PepperPluginDelegateImpl::OnUDPSocketSendToACK(uint32 plugin_dispatcher_id, | |
1579 uint32 socket_id, | |
1580 bool succeeded, | |
1581 int32_t bytes_written) { | |
1582 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = | |
1583 udp_sockets_.Lookup(socket_id); | |
1584 if (socket) | |
1585 socket->OnSendToCompleted(succeeded, bytes_written); | |
1586 } | |
1587 | |
1588 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( | 1496 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( |
1589 uint32 plugin_dispatcher_id, | 1497 uint32 plugin_dispatcher_id, |
1590 PP_Resource socket_resource, | 1498 PP_Resource socket_resource, |
1591 uint32 socket_id, | 1499 uint32 socket_id, |
1592 int32_t status) { | 1500 int32_t status) { |
1593 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> | 1501 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> |
1594 enter(socket_resource, true); | 1502 enter(socket_resource, true); |
1595 if (enter.succeeded()) { | 1503 if (enter.succeeded()) { |
1596 ppapi::PPB_TCPServerSocket_Shared* socket = | 1504 ppapi::PPB_TCPServerSocket_Shared* socket = |
1597 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); | 1505 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 RenderWidgetFullscreenPepper* container = | 1640 RenderWidgetFullscreenPepper* container = |
1733 static_cast<RenderWidgetFullscreenPepper*>( | 1641 static_cast<RenderWidgetFullscreenPepper*>( |
1734 instance->fullscreen_container()); | 1642 instance->fullscreen_container()); |
1735 return container->mouse_lock_dispatcher(); | 1643 return container->mouse_lock_dispatcher(); |
1736 } else { | 1644 } else { |
1737 return render_view_->mouse_lock_dispatcher(); | 1645 return render_view_->mouse_lock_dispatcher(); |
1738 } | 1646 } |
1739 } | 1647 } |
1740 | 1648 |
1741 } // namespace content | 1649 } // namespace content |
OLD | NEW |