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 <map> | 9 #include <map> |
9 #include <queue> | 10 #include <queue> |
10 | 11 |
11 #include "base/bind.h" | 12 #include "base/bind.h" |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/file_path.h" | 15 #include "base/file_path.h" |
15 #include "base/file_util_proxy.h" | 16 #include "base/file_util_proxy.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/string_split.h" | 18 #include "base/string_split.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "content/renderer/renderer_clipboard_client.h" | 54 #include "content/renderer/renderer_clipboard_client.h" |
54 #include "content/renderer/webplugin_delegate_proxy.h" | 55 #include "content/renderer/webplugin_delegate_proxy.h" |
55 #include "ipc/ipc_channel_handle.h" | 56 #include "ipc/ipc_channel_handle.h" |
56 #include "media/video/capture/video_capture_proxy.h" | 57 #include "media/video/capture/video_capture_proxy.h" |
57 #include "ppapi/c/dev/pp_video_dev.h" | 58 #include "ppapi/c/dev/pp_video_dev.h" |
58 #include "ppapi/c/pp_errors.h" | 59 #include "ppapi/c/pp_errors.h" |
59 #include "ppapi/c/private/ppb_flash.h" | 60 #include "ppapi/c/private/ppb_flash.h" |
60 #include "ppapi/c/private/ppb_flash_net_connector.h" | 61 #include "ppapi/c/private/ppb_flash_net_connector.h" |
61 #include "ppapi/proxy/host_dispatcher.h" | 62 #include "ppapi/proxy/host_dispatcher.h" |
62 #include "ppapi/proxy/ppapi_messages.h" | 63 #include "ppapi/proxy/ppapi_messages.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/shared_impl/ppb_device_ref_shared.h" |
66 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 67 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
67 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
68 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" | 69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" |
69 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" | 70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" |
70 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
71 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
72 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
73 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" | 74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" |
74 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 75 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
75 #include "ui/gfx/size.h" | 76 #include "ui/gfx/size.h" |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 // Pending Listen request. | 1084 // Pending Listen request. |
1084 uninitialized_tcp_server_sockets_.Remove(temp_socket_id); | 1085 uninitialized_tcp_server_sockets_.Remove(temp_socket_id); |
1085 } | 1086 } |
1086 } else { | 1087 } else { |
1087 render_view_->Send( | 1088 render_view_->Send( |
1088 new PpapiHostMsg_PPBTCPServerSocket_Destroy(real_socket_id)); | 1089 new PpapiHostMsg_PPBTCPServerSocket_Destroy(real_socket_id)); |
1089 tcp_server_sockets_.Remove(real_socket_id); | 1090 tcp_server_sockets_.Remove(real_socket_id); |
1090 } | 1091 } |
1091 } | 1092 } |
1092 | 1093 |
| 1094 void PepperPluginDelegateImpl::RegisterHostResolver( |
| 1095 ppapi::PPB_HostResolver_Shared* host_resolver, |
| 1096 uint32 host_resolver_id) { |
| 1097 host_resolvers_.AddWithID(host_resolver, host_resolver_id); |
| 1098 } |
| 1099 |
| 1100 void PepperPluginDelegateImpl::HostResolverResolve( |
| 1101 uint32 host_resolver_id, |
| 1102 const ::ppapi::HostPortPair& host_port, |
| 1103 const PP_HostResolver_Private_Hint* hint) { |
| 1104 DCHECK(host_resolvers_.Lookup(host_resolver_id)); |
| 1105 if (!hint) { |
| 1106 PP_HostResolver_Private_Hint empty_hint; |
| 1107 empty_hint.family = PP_NETADDRESSFAMILY_UNSPECIFIED; |
| 1108 empty_hint.flags = static_cast<PP_HostResolver_Private_Flags>(0); |
| 1109 render_view_->Send( |
| 1110 new PpapiHostMsg_PPBHostResolver_Resolve( |
| 1111 GetRoutingID(), |
| 1112 0, |
| 1113 host_resolver_id, |
| 1114 host_port, |
| 1115 empty_hint)); |
| 1116 } else { |
| 1117 render_view_->Send( |
| 1118 new PpapiHostMsg_PPBHostResolver_Resolve( |
| 1119 GetRoutingID(), |
| 1120 0, |
| 1121 host_resolver_id, |
| 1122 host_port, |
| 1123 *hint)); |
| 1124 } |
| 1125 } |
| 1126 |
| 1127 void PepperPluginDelegateImpl::UnregisterHostResolver( |
| 1128 uint32 host_resolver_id) { |
| 1129 host_resolvers_.Remove(host_resolver_id); |
| 1130 } |
| 1131 |
1093 bool PepperPluginDelegateImpl::AddNetworkListObserver( | 1132 bool PepperPluginDelegateImpl::AddNetworkListObserver( |
1094 webkit_glue::NetworkListObserver* observer) { | 1133 webkit_glue::NetworkListObserver* observer) { |
1095 #if defined(ENABLE_P2P_APIS) | 1134 #if defined(ENABLE_P2P_APIS) |
1096 content::P2PSocketDispatcher* socket_dispatcher = | 1135 content::P2PSocketDispatcher* socket_dispatcher = |
1097 render_view_->p2p_socket_dispatcher(); | 1136 render_view_->p2p_socket_dispatcher(); |
1098 if (!socket_dispatcher) { | 1137 if (!socket_dispatcher) { |
1099 return false; | 1138 return false; |
1100 } | 1139 } |
1101 socket_dispatcher->AddNetworkListObserver(observer); | 1140 socket_dispatcher->AddNetworkListObserver(observer); |
1102 return true; | 1141 return true; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) | 1403 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) |
1365 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) | 1404 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) |
1366 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_BindACK, OnUDPSocketBindACK) | 1405 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_BindACK, OnUDPSocketBindACK) |
1367 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK, | 1406 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK, |
1368 OnUDPSocketRecvFromACK) | 1407 OnUDPSocketRecvFromACK) |
1369 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnUDPSocketSendToACK) | 1408 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnUDPSocketSendToACK) |
1370 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, | 1409 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_ListenACK, |
1371 OnTCPServerSocketListenACK) | 1410 OnTCPServerSocketListenACK) |
1372 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, | 1411 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPServerSocket_AcceptACK, |
1373 OnTCPServerSocketAcceptACK) | 1412 OnTCPServerSocketAcceptACK) |
| 1413 IPC_MESSAGE_HANDLER(PpapiMsg_PPBHostResolver_ResolveACK, |
| 1414 OnHostResolverResolveACK) |
1374 IPC_MESSAGE_UNHANDLED(handled = false) | 1415 IPC_MESSAGE_UNHANDLED(handled = false) |
1375 IPC_END_MESSAGE_MAP() | 1416 IPC_END_MESSAGE_MAP() |
1376 return handled; | 1417 return handled; |
1377 } | 1418 } |
1378 | 1419 |
1379 void PepperPluginDelegateImpl::OnDestruct() { | 1420 void PepperPluginDelegateImpl::OnDestruct() { |
1380 // Nothing to do here. Default implementation in RenderViewObserver does | 1421 // Nothing to do here. Default implementation in RenderViewObserver does |
1381 // 'delete this' but it's not suitable for PepperPluginDelegateImpl because | 1422 // 'delete this' but it's not suitable for PepperPluginDelegateImpl because |
1382 // it's non-pointer member in RenderViewImpl. | 1423 // it's non-pointer member in RenderViewImpl. |
1383 } | 1424 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 tcp_server_sockets_.Lookup(real_server_socket_id); | 1532 tcp_server_sockets_.Lookup(real_server_socket_id); |
1492 if (socket) { | 1533 if (socket) { |
1493 bool succeeded = accepted_socket_id != 0; | 1534 bool succeeded = accepted_socket_id != 0; |
1494 socket->OnAcceptCompleted(succeeded, | 1535 socket->OnAcceptCompleted(succeeded, |
1495 accepted_socket_id, | 1536 accepted_socket_id, |
1496 local_addr, | 1537 local_addr, |
1497 remote_addr); | 1538 remote_addr); |
1498 } | 1539 } |
1499 } | 1540 } |
1500 | 1541 |
| 1542 void PepperPluginDelegateImpl::OnHostResolverResolveACK( |
| 1543 uint32 plugin_dispatcher_id, |
| 1544 uint32 host_resolver_id, |
| 1545 bool succeeded, |
| 1546 const std::string& canonical_name, |
| 1547 const ppapi::NetAddressList& net_address_list) { |
| 1548 ppapi::PPB_HostResolver_Shared* host_resolver = |
| 1549 host_resolvers_.Lookup(host_resolver_id); |
| 1550 if (host_resolver) { |
| 1551 host_resolver->OnResolveCompleted(succeeded, |
| 1552 canonical_name, |
| 1553 net_address_list); |
| 1554 } |
| 1555 } |
| 1556 |
1501 int PepperPluginDelegateImpl::GetRoutingID() const { | 1557 int PepperPluginDelegateImpl::GetRoutingID() const { |
1502 return render_view_->routing_id(); | 1558 return render_view_->routing_id(); |
1503 } | 1559 } |
1504 | 1560 |
1505 int PepperPluginDelegateImpl::OpenDevice(PP_DeviceType_Dev type, | 1561 int PepperPluginDelegateImpl::OpenDevice(PP_DeviceType_Dev type, |
1506 const std::string& device_id, | 1562 const std::string& device_id, |
1507 const OpenDeviceCallback& callback) { | 1563 const OpenDeviceCallback& callback) { |
1508 int request_id = | 1564 int request_id = |
1509 device_enumeration_event_handler_->RegisterOpenDeviceCallback(callback); | 1565 device_enumeration_event_handler_->RegisterOpenDeviceCallback(callback); |
1510 | 1566 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); | 1638 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); |
1583 delete target; | 1639 delete target; |
1584 mouse_lock_instances_.erase(it); | 1640 mouse_lock_instances_.erase(it); |
1585 } | 1641 } |
1586 } | 1642 } |
1587 | 1643 |
1588 webkit_glue::ClipboardClient* | 1644 webkit_glue::ClipboardClient* |
1589 PepperPluginDelegateImpl::CreateClipboardClient() const { | 1645 PepperPluginDelegateImpl::CreateClipboardClient() const { |
1590 return new RendererClipboardClient; | 1646 return new RendererClipboardClient; |
1591 } | 1647 } |
OLD | NEW |