| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "media/video/capture/video_capture_proxy.h" | 57 #include "media/video/capture/video_capture_proxy.h" |
| 58 #include "ppapi/c/dev/pp_video_dev.h" | 58 #include "ppapi/c/dev/pp_video_dev.h" |
| 59 #include "ppapi/c/pp_errors.h" | 59 #include "ppapi/c/pp_errors.h" |
| 60 #include "ppapi/c/private/ppb_flash.h" | 60 #include "ppapi/c/private/ppb_flash.h" |
| 61 #include "ppapi/c/private/ppb_flash_net_connector.h" | 61 #include "ppapi/c/private/ppb_flash_net_connector.h" |
| 62 #include "ppapi/proxy/host_dispatcher.h" | 62 #include "ppapi/proxy/host_dispatcher.h" |
| 63 #include "ppapi/proxy/ppapi_messages.h" | 63 #include "ppapi/proxy/ppapi_messages.h" |
| 64 #include "ppapi/shared_impl/platform_file.h" | 64 #include "ppapi/shared_impl/platform_file.h" |
| 65 #include "ppapi/shared_impl/ppapi_preferences.h" | 65 #include "ppapi/shared_impl/ppapi_preferences.h" |
| 66 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | 66 #include "ppapi/shared_impl/ppb_device_ref_shared.h" |
| 67 #include "ppapi/thunk/enter.h" |
| 68 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h" |
| 67 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" | 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" |
| 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" | 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" |
| 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 77 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 76 #include "ui/gfx/size.h" | 78 #include "ui/gfx/size.h" |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 | 1055 |
| 1054 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) { | 1056 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) { |
| 1055 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because it | 1057 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because it |
| 1056 // can be called before UDPSocketBind is called. | 1058 // can be called before UDPSocketBind is called. |
| 1057 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id)); | 1059 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id)); |
| 1058 if (udp_sockets_.Lookup(socket_id)) | 1060 if (udp_sockets_.Lookup(socket_id)) |
| 1059 udp_sockets_.Remove(socket_id); | 1061 udp_sockets_.Remove(socket_id); |
| 1060 } | 1062 } |
| 1061 | 1063 |
| 1062 void PepperPluginDelegateImpl::TCPServerSocketListen( | 1064 void PepperPluginDelegateImpl::TCPServerSocketListen( |
| 1063 webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket, | 1065 PP_Resource socket_resource, |
| 1064 uint32 temp_socket_id, | |
| 1065 const PP_NetAddress_Private& addr, | 1066 const PP_NetAddress_Private& addr, |
| 1066 int32_t backlog) { | 1067 int32_t backlog) { |
| 1067 uninitialized_tcp_server_sockets_.AddWithID(socket, temp_socket_id); | |
| 1068 render_view_->Send( | 1068 render_view_->Send( |
| 1069 new PpapiHostMsg_PPBTCPServerSocket_Listen( | 1069 new PpapiHostMsg_PPBTCPServerSocket_Listen( |
| 1070 render_view_->routing_id(), 0, temp_socket_id, addr, backlog)); | 1070 render_view_->routing_id(), 0, socket_resource, addr, backlog)); |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 real_socket_id) { | 1073 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) { |
| 1074 DCHECK(tcp_server_sockets_.Lookup(real_socket_id)); | 1074 DCHECK(tcp_server_sockets_.Lookup(server_socket_id)); |
| 1075 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Accept( | 1075 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Accept( |
| 1076 real_socket_id)); | 1076 render_view_->routing_id(), server_socket_id)); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 void PepperPluginDelegateImpl::TCPServerSocketStopListening( | 1079 void PepperPluginDelegateImpl::TCPServerSocketStopListening( |
| 1080 uint32 real_socket_id, | 1080 PP_Resource socket_resource, |
| 1081 uint32 temp_socket_id) { | 1081 uint32 socket_id) { |
| 1082 if (real_socket_id == 0) { | 1082 if (socket_id != 0) { |
| 1083 if (uninitialized_tcp_server_sockets_.Lookup(temp_socket_id)) { | 1083 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id)); |
| 1084 // Pending Listen request. | 1084 tcp_server_sockets_.Remove(socket_id); |
| 1085 uninitialized_tcp_server_sockets_.Remove(temp_socket_id); | |
| 1086 } | |
| 1087 } else { | |
| 1088 render_view_->Send( | |
| 1089 new PpapiHostMsg_PPBTCPServerSocket_Destroy(real_socket_id)); | |
| 1090 tcp_server_sockets_.Remove(real_socket_id); | |
| 1091 } | 1085 } |
| 1092 } | 1086 } |
| 1093 | 1087 |
| 1094 void PepperPluginDelegateImpl::RegisterHostResolver( | 1088 void PepperPluginDelegateImpl::RegisterHostResolver( |
| 1095 ppapi::PPB_HostResolver_Shared* host_resolver, | 1089 ppapi::PPB_HostResolver_Shared* host_resolver, |
| 1096 uint32 host_resolver_id) { | 1090 uint32 host_resolver_id) { |
| 1097 host_resolvers_.AddWithID(host_resolver, host_resolver_id); | 1091 host_resolvers_.AddWithID(host_resolver, host_resolver_id); |
| 1098 } | 1092 } |
| 1099 | 1093 |
| 1100 void PepperPluginDelegateImpl::HostResolverResolve( | 1094 void PepperPluginDelegateImpl::HostResolverResolve( |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 bool succeeded, | 1491 bool succeeded, |
| 1498 int32_t bytes_written) { | 1492 int32_t bytes_written) { |
| 1499 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = | 1493 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = |
| 1500 udp_sockets_.Lookup(socket_id); | 1494 udp_sockets_.Lookup(socket_id); |
| 1501 if (socket) | 1495 if (socket) |
| 1502 socket->OnSendToCompleted(succeeded, bytes_written); | 1496 socket->OnSendToCompleted(succeeded, bytes_written); |
| 1503 } | 1497 } |
| 1504 | 1498 |
| 1505 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( | 1499 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( |
| 1506 uint32 plugin_dispatcher_id, | 1500 uint32 plugin_dispatcher_id, |
| 1507 uint32 real_socket_id, | 1501 PP_Resource socket_resource, |
| 1508 uint32 temp_socket_id, | 1502 uint32 socket_id, |
| 1509 int32_t status) { | 1503 int32_t status) { |
| 1510 webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket = | 1504 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> |
| 1511 uninitialized_tcp_server_sockets_.Lookup(temp_socket_id); | 1505 enter(socket_resource, true); |
| 1512 if (socket == NULL) { | 1506 if (enter.succeeded()) { |
| 1507 ppapi::PPB_TCPServerSocket_Shared* socket = |
| 1508 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); |
| 1509 if (status == PP_OK) |
| 1510 tcp_server_sockets_.AddWithID(socket, socket_id); |
| 1511 socket->OnListenCompleted(socket_id, status); |
| 1512 } else if (socket_id != 0 && status == PP_OK) { |
| 1513 // StopListening was called before completion of Listen. | 1513 // StopListening was called before completion of Listen. |
| 1514 render_view_->Send( | 1514 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id)); |
| 1515 new PpapiHostMsg_PPBTCPServerSocket_Destroy(real_socket_id)); | |
| 1516 } else { | |
| 1517 uninitialized_tcp_server_sockets_.Remove(temp_socket_id); | |
| 1518 | |
| 1519 if (status == PP_OK) | |
| 1520 tcp_server_sockets_.AddWithID(socket, real_socket_id); | |
| 1521 socket->OnListenCompleted(real_socket_id, status); | |
| 1522 } | 1515 } |
| 1523 } | 1516 } |
| 1524 | 1517 |
| 1525 void PepperPluginDelegateImpl::OnTCPServerSocketAcceptACK( | 1518 void PepperPluginDelegateImpl::OnTCPServerSocketAcceptACK( |
| 1526 uint32 plugin_dispatcher_id, | 1519 uint32 plugin_dispatcher_id, |
| 1527 uint32 real_server_socket_id, | 1520 uint32 server_socket_id, |
| 1528 uint32 accepted_socket_id, | 1521 uint32 accepted_socket_id, |
| 1529 const PP_NetAddress_Private& local_addr, | 1522 const PP_NetAddress_Private& local_addr, |
| 1530 const PP_NetAddress_Private& remote_addr) { | 1523 const PP_NetAddress_Private& remote_addr) { |
| 1531 webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket = | 1524 ppapi::PPB_TCPServerSocket_Shared* socket = |
| 1532 tcp_server_sockets_.Lookup(real_server_socket_id); | 1525 tcp_server_sockets_.Lookup(server_socket_id); |
| 1533 if (socket) { | 1526 if (socket) { |
| 1534 bool succeeded = accepted_socket_id != 0; | 1527 bool succeeded = (accepted_socket_id != 0); |
| 1535 socket->OnAcceptCompleted(succeeded, | 1528 socket->OnAcceptCompleted(succeeded, |
| 1536 accepted_socket_id, | 1529 accepted_socket_id, |
| 1537 local_addr, | 1530 local_addr, |
| 1538 remote_addr); | 1531 remote_addr); |
| 1532 } else if (accepted_socket_id != 0) { |
| 1533 render_view_->Send( |
| 1534 new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); |
| 1539 } | 1535 } |
| 1540 } | 1536 } |
| 1541 | 1537 |
| 1542 void PepperPluginDelegateImpl::OnHostResolverResolveACK( | 1538 void PepperPluginDelegateImpl::OnHostResolverResolveACK( |
| 1543 uint32 plugin_dispatcher_id, | 1539 uint32 plugin_dispatcher_id, |
| 1544 uint32 host_resolver_id, | 1540 uint32 host_resolver_id, |
| 1545 bool succeeded, | 1541 bool succeeded, |
| 1546 const std::string& canonical_name, | 1542 const std::string& canonical_name, |
| 1547 const ppapi::NetAddressList& net_address_list) { | 1543 const ppapi::NetAddressList& net_address_list) { |
| 1548 ppapi::PPB_HostResolver_Shared* host_resolver = | 1544 ppapi::PPB_HostResolver_Shared* host_resolver = |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1638 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); | 1634 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); |
| 1639 delete target; | 1635 delete target; |
| 1640 mouse_lock_instances_.erase(it); | 1636 mouse_lock_instances_.erase(it); |
| 1641 } | 1637 } |
| 1642 } | 1638 } |
| 1643 | 1639 |
| 1644 webkit_glue::ClipboardClient* | 1640 webkit_glue::ClipboardClient* |
| 1645 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1641 PepperPluginDelegateImpl::CreateClipboardClient() const { |
| 1646 return new RendererClipboardClient; | 1642 return new RendererClipboardClient; |
| 1647 } | 1643 } |
| OLD | NEW |