Chromium Code Reviews| 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 <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 #include "media/video/capture/video_capture_proxy.h" | 56 #include "media/video/capture/video_capture_proxy.h" |
| 57 #include "ppapi/c/dev/pp_video_dev.h" | 57 #include "ppapi/c/dev/pp_video_dev.h" |
| 58 #include "ppapi/c/pp_errors.h" | 58 #include "ppapi/c/pp_errors.h" |
| 59 #include "ppapi/c/private/ppb_flash.h" | 59 #include "ppapi/c/private/ppb_flash.h" |
| 60 #include "ppapi/c/private/ppb_flash_net_connector.h" | 60 #include "ppapi/c/private/ppb_flash_net_connector.h" |
| 61 #include "ppapi/proxy/host_dispatcher.h" | 61 #include "ppapi/proxy/host_dispatcher.h" |
| 62 #include "ppapi/proxy/ppapi_messages.h" | 62 #include "ppapi/proxy/ppapi_messages.h" |
| 63 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | 63 #include "ppapi/shared_impl/ppb_device_ref_shared.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/thunk/enter.h" | |
| 67 #include "ppapi/thunk/ppb_tcp_server_socket_private_api.h" | |
| 66 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 67 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet ion.h" | 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet ion.h" |
| 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" | 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams. h" |
| 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
| 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 75 #include "ui/gfx/size.h" | 77 #include "ui/gfx/size.h" |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 | 1054 |
| 1053 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) { | 1055 void PepperPluginDelegateImpl::UDPSocketClose(uint32 socket_id) { |
| 1054 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because it | 1056 // There are no DCHECK(udp_sockets_.Lookup(socket_id)) because it |
| 1055 // can be called before UDPSocketBind is called. | 1057 // can be called before UDPSocketBind is called. |
| 1056 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id)); | 1058 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Close(socket_id)); |
| 1057 if (udp_sockets_.Lookup(socket_id)) | 1059 if (udp_sockets_.Lookup(socket_id)) |
| 1058 udp_sockets_.Remove(socket_id); | 1060 udp_sockets_.Remove(socket_id); |
| 1059 } | 1061 } |
| 1060 | 1062 |
| 1061 void PepperPluginDelegateImpl::TCPServerSocketListen( | 1063 void PepperPluginDelegateImpl::TCPServerSocketListen( |
| 1062 webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket, | 1064 PP_Resource socket_resource, |
| 1063 uint32 temp_socket_id, | |
| 1064 const PP_NetAddress_Private& addr, | 1065 const PP_NetAddress_Private& addr, |
| 1065 int32_t backlog) { | 1066 int32_t backlog) { |
| 1066 uninitialized_tcp_server_sockets_.AddWithID(socket, temp_socket_id); | |
| 1067 render_view_->Send( | 1067 render_view_->Send( |
| 1068 new PpapiHostMsg_PPBTCPServerSocket_Listen( | 1068 new PpapiHostMsg_PPBTCPServerSocket_Listen( |
| 1069 render_view_->routing_id(), 0, temp_socket_id, addr, backlog)); | 1069 render_view_->routing_id(), 0, socket_resource, addr, backlog)); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 real_socket_id) { | 1072 void PepperPluginDelegateImpl::TCPServerSocketAccept(uint32 server_socket_id) { |
| 1073 DCHECK(tcp_server_sockets_.Lookup(real_socket_id)); | 1073 DCHECK(tcp_server_sockets_.Lookup(server_socket_id)); |
| 1074 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Accept( | 1074 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Accept( |
| 1075 real_socket_id)); | 1075 render_view_->routing_id(), server_socket_id)); |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 void PepperPluginDelegateImpl::TCPServerSocketStopListening( | 1078 void PepperPluginDelegateImpl::TCPServerSocketStopListening( |
| 1079 uint32 real_socket_id, | 1079 PP_Resource socket_resource, |
| 1080 uint32 temp_socket_id) { | 1080 uint32 socket_id) { |
| 1081 if (real_socket_id == 0) { | 1081 if (socket_id != 0) { |
| 1082 if (uninitialized_tcp_server_sockets_.Lookup(temp_socket_id)) { | 1082 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id)); |
| 1083 // Pending Listen request. | 1083 tcp_server_sockets_.Remove(socket_id); |
| 1084 uninitialized_tcp_server_sockets_.Remove(temp_socket_id); | |
| 1085 } | |
| 1086 } else { | |
| 1087 render_view_->Send( | |
| 1088 new PpapiHostMsg_PPBTCPServerSocket_Destroy(real_socket_id)); | |
| 1089 tcp_server_sockets_.Remove(real_socket_id); | |
| 1090 } | 1084 } |
| 1091 } | 1085 } |
| 1092 | 1086 |
| 1093 bool PepperPluginDelegateImpl::AddNetworkListObserver( | 1087 bool PepperPluginDelegateImpl::AddNetworkListObserver( |
| 1094 webkit_glue::NetworkListObserver* observer) { | 1088 webkit_glue::NetworkListObserver* observer) { |
| 1095 #if defined(ENABLE_P2P_APIS) | 1089 #if defined(ENABLE_P2P_APIS) |
| 1096 content::P2PSocketDispatcher* socket_dispatcher = | 1090 content::P2PSocketDispatcher* socket_dispatcher = |
| 1097 render_view_->p2p_socket_dispatcher(); | 1091 render_view_->p2p_socket_dispatcher(); |
| 1098 if (!socket_dispatcher) { | 1092 if (!socket_dispatcher) { |
| 1099 return false; | 1093 return false; |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1456 bool succeeded, | 1450 bool succeeded, |
| 1457 int32_t bytes_written) { | 1451 int32_t bytes_written) { |
| 1458 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = | 1452 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket = |
| 1459 udp_sockets_.Lookup(socket_id); | 1453 udp_sockets_.Lookup(socket_id); |
| 1460 if (socket) | 1454 if (socket) |
| 1461 socket->OnSendToCompleted(succeeded, bytes_written); | 1455 socket->OnSendToCompleted(succeeded, bytes_written); |
| 1462 } | 1456 } |
| 1463 | 1457 |
| 1464 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( | 1458 void PepperPluginDelegateImpl::OnTCPServerSocketListenACK( |
| 1465 uint32 plugin_dispatcher_id, | 1459 uint32 plugin_dispatcher_id, |
| 1466 uint32 real_socket_id, | 1460 PP_Resource socket_resource, |
| 1467 uint32 temp_socket_id, | 1461 uint32 socket_id, |
| 1468 int32_t status) { | 1462 int32_t status) { |
| 1469 webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket = | 1463 ppapi::thunk::EnterResource<ppapi::thunk::PPB_TCPServerSocket_Private_API> |
| 1470 uninitialized_tcp_server_sockets_.Lookup(temp_socket_id); | 1464 enter(socket_resource, true); |
| 1471 if (socket == NULL) { | 1465 if (enter.succeeded()) { |
| 1466 ppapi::PPB_TCPServerSocket_Shared* socket = | |
| 1467 static_cast<ppapi::PPB_TCPServerSocket_Shared*>(enter.object()); | |
| 1468 if (status == PP_OK) | |
| 1469 tcp_server_sockets_.AddWithID(socket, socket_id); | |
| 1470 socket->OnListenCompleted(socket_id, status); | |
| 1471 } else if (socket_id != 0 && status == PP_OK) { | |
| 1472 // StopListening was called before completion of Listen. | 1472 // StopListening was called before completion of Listen. |
| 1473 render_view_->Send( | 1473 render_view_->Send(new PpapiHostMsg_PPBTCPServerSocket_Destroy(socket_id)); |
| 1474 new PpapiHostMsg_PPBTCPServerSocket_Destroy(real_socket_id)); | |
| 1475 } else { | |
| 1476 uninitialized_tcp_server_sockets_.Remove(temp_socket_id); | |
| 1477 | |
| 1478 if (status == PP_OK) | |
| 1479 tcp_server_sockets_.AddWithID(socket, real_socket_id); | |
| 1480 socket->OnListenCompleted(real_socket_id, status); | |
| 1481 } | 1474 } |
| 1482 } | 1475 } |
| 1483 | 1476 |
| 1484 void PepperPluginDelegateImpl::OnTCPServerSocketAcceptACK( | 1477 void PepperPluginDelegateImpl::OnTCPServerSocketAcceptACK( |
| 1485 uint32 plugin_dispatcher_id, | 1478 uint32 plugin_dispatcher_id, |
| 1486 uint32 real_server_socket_id, | 1479 uint32 server_socket_id, |
| 1487 uint32 accepted_socket_id, | 1480 uint32 accepted_socket_id, |
| 1488 const PP_NetAddress_Private& local_addr, | 1481 const PP_NetAddress_Private& local_addr, |
| 1489 const PP_NetAddress_Private& remote_addr) { | 1482 const PP_NetAddress_Private& remote_addr) { |
| 1490 webkit::ppapi::PPB_TCPServerSocket_Private_Impl* socket = | 1483 ppapi::PPB_TCPServerSocket_Shared* socket = |
| 1491 tcp_server_sockets_.Lookup(real_server_socket_id); | 1484 tcp_server_sockets_.Lookup(server_socket_id); |
| 1492 if (socket) { | 1485 if (socket) { |
| 1493 bool succeeded = accepted_socket_id != 0; | 1486 bool succeeded = (accepted_socket_id != 0); |
| 1494 socket->OnAcceptCompleted(succeeded, | 1487 socket->OnAcceptCompleted(succeeded, |
| 1495 accepted_socket_id, | 1488 accepted_socket_id, |
| 1496 local_addr, | 1489 local_addr, |
| 1497 remote_addr); | 1490 remote_addr); |
| 1491 } else { | |
| 1492 render_view_->Send( | |
|
yzshen1
2012/03/14 17:05:04
nit: only send Disconnect when accepted_socket_id
ygorshenin1
2012/03/15 07:08:04
Done.
| |
| 1493 new PpapiHostMsg_PPBTCPSocket_Disconnect(accepted_socket_id)); | |
| 1498 } | 1494 } |
| 1499 } | 1495 } |
| 1500 | 1496 |
| 1501 int PepperPluginDelegateImpl::GetRoutingID() const { | 1497 int PepperPluginDelegateImpl::GetRoutingID() const { |
| 1502 return render_view_->routing_id(); | 1498 return render_view_->routing_id(); |
| 1503 } | 1499 } |
| 1504 | 1500 |
| 1505 int PepperPluginDelegateImpl::OpenDevice(PP_DeviceType_Dev type, | 1501 int PepperPluginDelegateImpl::OpenDevice(PP_DeviceType_Dev type, |
| 1506 const std::string& device_id, | 1502 const std::string& device_id, |
| 1507 const OpenDeviceCallback& callback) { | 1503 const OpenDeviceCallback& callback) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1582 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); | 1578 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); |
| 1583 delete target; | 1579 delete target; |
| 1584 mouse_lock_instances_.erase(it); | 1580 mouse_lock_instances_.erase(it); |
| 1585 } | 1581 } |
| 1586 } | 1582 } |
| 1587 | 1583 |
| 1588 webkit_glue::ClipboardClient* | 1584 webkit_glue::ClipboardClient* |
| 1589 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1585 PepperPluginDelegateImpl::CreateClipboardClient() const { |
| 1590 return new RendererClipboardClient; | 1586 return new RendererClipboardClient; |
| 1591 } | 1587 } |
| OLD | NEW |