OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/renderer_host/pepper/pepper_udp_socket_message_filter. h" | 5 #include "content/browser/renderer_host/pepper/pepper_udp_socket_message_filter. h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" | 11 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" |
12 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h" | 12 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/content_browser_client.h" | |
14 #include "content/public/common/process_type.h" | 15 #include "content/public/common/process_type.h" |
15 #include "content/public/common/socket_permission_request.h" | 16 #include "content/public/common/socket_permission_request.h" |
16 #include "ipc/ipc_message_macros.h" | 17 #include "ipc/ipc_message_macros.h" |
17 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/base/rand_callback.h" | 20 #include "net/base/rand_callback.h" |
20 #include "net/udp/udp_socket.h" | 21 #include "net/udp/udp_socket.h" |
21 #include "ppapi/c/pp_errors.h" | 22 #include "ppapi/c/pp_errors.h" |
22 #include "ppapi/c/private/ppb_net_address_private.h" | 23 #include "ppapi/c/private/ppb_net_address_private.h" |
23 #include "ppapi/host/dispatch_host_message.h" | 24 #include "ppapi/host/dispatch_host_message.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
53 PepperUDPSocketMessageFilter::PendingSend::~PendingSend() { | 54 PepperUDPSocketMessageFilter::PendingSend::~PendingSend() { |
54 } | 55 } |
55 | 56 |
56 PepperUDPSocketMessageFilter::PepperUDPSocketMessageFilter( | 57 PepperUDPSocketMessageFilter::PepperUDPSocketMessageFilter( |
57 BrowserPpapiHostImpl* host, | 58 BrowserPpapiHostImpl* host, |
58 PP_Instance instance, | 59 PP_Instance instance, |
59 bool private_api) | 60 bool private_api) |
60 : socket_options_(0), | 61 : socket_options_(0), |
61 rcvbuf_size_(0), | 62 rcvbuf_size_(0), |
62 sndbuf_size_(0), | 63 sndbuf_size_(0), |
64 multicast_ttl_(0), | |
63 closed_(false), | 65 closed_(false), |
64 remaining_recv_slots_(UDPSocketResourceBase::kPluginReceiveBufferSlots), | 66 remaining_recv_slots_(UDPSocketResourceBase::kPluginReceiveBufferSlots), |
65 external_plugin_(host->external_plugin()), | 67 external_plugin_(host->external_plugin()), |
66 private_api_(private_api), | 68 private_api_(private_api), |
67 render_process_id_(0), | 69 render_process_id_(0), |
68 render_frame_id_(0) { | 70 render_frame_id_(0) { |
69 ++g_num_instances; | 71 ++g_num_instances; |
70 DCHECK(host); | 72 DCHECK(host); |
71 | 73 |
72 if (!host->GetRenderFrameIDsForInstance( | 74 if (!host->GetRenderFrameIDsForInstance( |
(...skipping 15 matching lines...) Expand all Loading... | |
88 scoped_refptr<base::TaskRunner> | 90 scoped_refptr<base::TaskRunner> |
89 PepperUDPSocketMessageFilter::OverrideTaskRunnerForMessage( | 91 PepperUDPSocketMessageFilter::OverrideTaskRunnerForMessage( |
90 const IPC::Message& message) { | 92 const IPC::Message& message) { |
91 switch (message.type()) { | 93 switch (message.type()) { |
92 case PpapiHostMsg_UDPSocket_SetOption::ID: | 94 case PpapiHostMsg_UDPSocket_SetOption::ID: |
93 case PpapiHostMsg_UDPSocket_Close::ID: | 95 case PpapiHostMsg_UDPSocket_Close::ID: |
94 case PpapiHostMsg_UDPSocket_RecvSlotAvailable::ID: | 96 case PpapiHostMsg_UDPSocket_RecvSlotAvailable::ID: |
95 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 97 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
96 case PpapiHostMsg_UDPSocket_Bind::ID: | 98 case PpapiHostMsg_UDPSocket_Bind::ID: |
97 case PpapiHostMsg_UDPSocket_SendTo::ID: | 99 case PpapiHostMsg_UDPSocket_SendTo::ID: |
100 case PpapiHostMsg_UDPSocket_JoinGroup::ID: | |
101 case PpapiHostMsg_UDPSocket_LeaveGroup::ID: | |
98 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 102 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); |
99 } | 103 } |
100 return NULL; | 104 return NULL; |
101 } | 105 } |
102 | 106 |
103 int32_t PepperUDPSocketMessageFilter::OnResourceMessageReceived( | 107 int32_t PepperUDPSocketMessageFilter::OnResourceMessageReceived( |
104 const IPC::Message& msg, | 108 const IPC::Message& msg, |
105 ppapi::host::HostMessageContext* context) { | 109 ppapi::host::HostMessageContext* context) { |
106 PPAPI_BEGIN_MESSAGE_MAP(PepperUDPSocketMessageFilter, msg) | 110 PPAPI_BEGIN_MESSAGE_MAP(PepperUDPSocketMessageFilter, msg) |
107 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_SetOption, | 111 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_SetOption, |
108 OnMsgSetOption) | 112 OnMsgSetOption) |
109 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_Bind, OnMsgBind) | 113 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_Bind, OnMsgBind) |
110 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_SendTo, | 114 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_SendTo, |
111 OnMsgSendTo) | 115 OnMsgSendTo) |
112 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_UDPSocket_Close, | 116 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_UDPSocket_Close, |
113 OnMsgClose) | 117 OnMsgClose) |
114 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( | 118 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0( |
115 PpapiHostMsg_UDPSocket_RecvSlotAvailable, OnMsgRecvSlotAvailable) | 119 PpapiHostMsg_UDPSocket_RecvSlotAvailable, OnMsgRecvSlotAvailable) |
120 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_JoinGroup, | |
121 OnMsgJoinGroup) | |
122 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UDPSocket_LeaveGroup, | |
123 OnMsgLeaveGroup) | |
116 PPAPI_END_MESSAGE_MAP() | 124 PPAPI_END_MESSAGE_MAP() |
117 return PP_ERROR_FAILED; | 125 return PP_ERROR_FAILED; |
118 } | 126 } |
119 | 127 |
120 int32_t PepperUDPSocketMessageFilter::OnMsgSetOption( | 128 int32_t PepperUDPSocketMessageFilter::OnMsgSetOption( |
121 const ppapi::host::HostMessageContext* context, | 129 const ppapi::host::HostMessageContext* context, |
122 PP_UDPSocket_Option name, | 130 PP_UDPSocket_Option name, |
123 const ppapi::SocketOptionData& value) { | 131 const ppapi::SocketOptionData& value) { |
124 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
125 | 133 |
(...skipping 18 matching lines...) Expand all Loading... | |
144 } else { | 152 } else { |
145 socket_options_ &= ~SOCKET_OPTION_ADDRESS_REUSE; | 153 socket_options_ &= ~SOCKET_OPTION_ADDRESS_REUSE; |
146 } | 154 } |
147 return PP_OK; | 155 return PP_OK; |
148 } | 156 } |
149 case PP_UDPSOCKET_OPTION_BROADCAST: { | 157 case PP_UDPSOCKET_OPTION_BROADCAST: { |
150 bool boolean_value = false; | 158 bool boolean_value = false; |
151 if (!value.GetBool(&boolean_value)) | 159 if (!value.GetBool(&boolean_value)) |
152 return PP_ERROR_BADARGUMENT; | 160 return PP_ERROR_BADARGUMENT; |
153 | 161 |
154 // If the socket is already connected, proxy the value to TCPSocket. | 162 // If the socket is already bound, proxy the value to UDPSocket. |
155 if (socket_.get()) | 163 if (socket_.get()) |
156 return NetErrorToPepperError(socket_->SetBroadcast(boolean_value)); | 164 return NetErrorToPepperError(socket_->SetBroadcast(boolean_value)); |
157 | 165 |
158 // UDPSocket instance is not yet created, so remember the value here. | 166 // UDPSocket instance is not yet created, so remember the value here. |
159 if (boolean_value) { | 167 if (boolean_value) { |
160 socket_options_ |= SOCKET_OPTION_BROADCAST; | 168 socket_options_ |= SOCKET_OPTION_BROADCAST; |
161 } else { | 169 } else { |
162 socket_options_ &= ~SOCKET_OPTION_BROADCAST; | 170 socket_options_ &= ~SOCKET_OPTION_BROADCAST; |
163 } | 171 } |
164 return PP_OK; | 172 return PP_OK; |
165 } | 173 } |
166 case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE: { | 174 case PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE: { |
167 int32_t integer_value = 0; | 175 int32_t integer_value = 0; |
168 if (!value.GetInt32(&integer_value) || | 176 if (!value.GetInt32(&integer_value) || |
169 integer_value <= 0 || | 177 integer_value <= 0 || |
170 integer_value > | 178 integer_value > |
171 ppapi::proxy::UDPSocketResourceBase::kMaxSendBufferSize) | 179 ppapi::proxy::UDPSocketResourceBase::kMaxSendBufferSize) |
172 return PP_ERROR_BADARGUMENT; | 180 return PP_ERROR_BADARGUMENT; |
173 | 181 |
174 // If the socket is already connected, proxy the value to UDPSocket. | 182 // If the socket is already bound, proxy the value to UDPSocket. |
175 if (socket_.get()) { | 183 if (socket_.get()) { |
176 return NetErrorToPepperError( | 184 return NetErrorToPepperError( |
177 socket_->SetSendBufferSize(integer_value)); | 185 socket_->SetSendBufferSize(integer_value)); |
178 } | 186 } |
179 | 187 |
180 // UDPSocket instance is not yet created, so remember the value here. | 188 // UDPSocket instance is not yet created, so remember the value here. |
181 socket_options_ |= SOCKET_OPTION_SNDBUF_SIZE; | 189 socket_options_ |= SOCKET_OPTION_SNDBUF_SIZE; |
182 sndbuf_size_ = integer_value; | 190 sndbuf_size_ = integer_value; |
183 return PP_OK; | 191 return PP_OK; |
184 } | 192 } |
185 case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: { | 193 case PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE: { |
186 int32_t integer_value = 0; | 194 int32_t integer_value = 0; |
187 if (!value.GetInt32(&integer_value) || | 195 if (!value.GetInt32(&integer_value) || |
188 integer_value <= 0 || | 196 integer_value <= 0 || |
189 integer_value > | 197 integer_value > |
190 ppapi::proxy::UDPSocketResourceBase::kMaxReceiveBufferSize) | 198 ppapi::proxy::UDPSocketResourceBase::kMaxReceiveBufferSize) |
191 return PP_ERROR_BADARGUMENT; | 199 return PP_ERROR_BADARGUMENT; |
192 | 200 |
193 // If the socket is already connected, proxy the value to UDPSocket. | 201 // If the socket is already bound, proxy the value to UDPSocket. |
194 if (socket_.get()) { | 202 if (socket_.get()) { |
195 return NetErrorToPepperError( | 203 return NetErrorToPepperError( |
196 socket_->SetReceiveBufferSize(integer_value)); | 204 socket_->SetReceiveBufferSize(integer_value)); |
197 } | 205 } |
198 | 206 |
199 // UDPSocket instance is not yet created, so remember the value here. | 207 // UDPSocket instance is not yet created, so remember the value here. |
200 socket_options_ |= SOCKET_OPTION_RCVBUF_SIZE; | 208 socket_options_ |= SOCKET_OPTION_RCVBUF_SIZE; |
201 rcvbuf_size_ = integer_value; | 209 rcvbuf_size_ = integer_value; |
202 return PP_OK; | 210 return PP_OK; |
203 } | 211 } |
212 case PP_UDPSOCKET_OPTION_MULTICAST_LOOP: { | |
213 bool boolean_value = false; | |
214 if (!value.GetBool(&boolean_value)) | |
215 return PP_ERROR_BADARGUMENT; | |
216 | |
217 // If the socket is already bound, proxy the value to UDPSocket. | |
218 if (socket_) | |
bbudge
2015/03/10 01:30:50
See comment below: this should be:
if (socket_ &&
| |
219 return NetErrorToPepperError( | |
220 socket_->SetMulticastLoopbackMode(boolean_value)); | |
221 | |
222 // UDPSocket instance is not yet created, so remember the value here. | |
223 if (boolean_value) { | |
224 socket_options_ |= SOCKET_OPTION_MULTICAST_LOOP; | |
225 } else { | |
226 socket_options_ &= ~SOCKET_OPTION_MULTICAST_LOOP; | |
227 } | |
228 return PP_OK; | |
229 } | |
230 case PP_UDPSOCKET_OPTION_MULTICAST_TTL: { | |
231 int32_t integer_value = 0; | |
232 if (!value.GetInt32(&integer_value) || | |
233 integer_value < 0 || integer_value > 255) | |
234 return PP_ERROR_BADARGUMENT; | |
235 | |
236 // If the socket is already bound, proxy the value to UDPSocket. | |
237 if (socket_) | |
238 return NetErrorToPepperError( | |
239 socket_->SetMulticastTimeToLive(integer_value)); | |
240 | |
241 // UDPSocket instance is not yet created, so remember the value here. | |
242 socket_options_ |= SOCKET_OPTION_MULTICAST_TTL; | |
243 multicast_ttl_ = integer_value; | |
244 return PP_OK; | |
245 } | |
204 default: { | 246 default: { |
205 NOTREACHED(); | 247 NOTREACHED(); |
206 return PP_ERROR_BADARGUMENT; | 248 return PP_ERROR_BADARGUMENT; |
207 } | 249 } |
208 } | 250 } |
209 } | 251 } |
210 | 252 |
211 int32_t PepperUDPSocketMessageFilter::OnMsgBind( | 253 int32_t PepperUDPSocketMessageFilter::OnMsgBind( |
212 const ppapi::host::HostMessageContext* context, | 254 const ppapi::host::HostMessageContext* context, |
213 const PP_NetAddress_Private& addr) { | 255 const PP_NetAddress_Private& addr) { |
214 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 256 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
215 DCHECK(context); | 257 DCHECK(context); |
216 | 258 |
259 if (socket_options_ & SOCKET_OPTION_MULTICAST_TTL|| | |
260 socket_options_ & SOCKET_OPTION_MULTICAST_LOOP) { | |
261 PP_NetAddress_Private any_addr; | |
262 NetAddressPrivateImpl::GetAnyAddress(PP_FALSE, &any_addr); | |
263 int32_t ret = CanUseMulticastAPI(any_addr); | |
264 if (ret != PP_OK) | |
265 return ret; | |
266 } | |
bbudge
2015/03/10 01:30:50
Sorry if I wasn't clear in my earlier comment. Thi
| |
267 | |
217 SocketPermissionRequest request = | 268 SocketPermissionRequest request = |
218 pepper_socket_utils::CreateSocketPermissionRequest( | 269 pepper_socket_utils::CreateSocketPermissionRequest( |
219 SocketPermissionRequest::UDP_BIND, addr); | 270 SocketPermissionRequest::UDP_BIND, addr); |
220 if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_, | 271 if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_, |
221 private_api_, | 272 private_api_, |
222 &request, | 273 &request, |
223 render_process_id_, | 274 render_process_id_, |
224 render_frame_id_)) { | 275 render_frame_id_)) { |
225 return PP_ERROR_NOACCESS; | 276 return PP_ERROR_NOACCESS; |
226 } | 277 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 } | 330 } |
280 | 331 |
281 if (!recvfrom_buffer_.get() && !closed_ && socket_.get()) { | 332 if (!recvfrom_buffer_.get() && !closed_ && socket_.get()) { |
282 DCHECK_EQ(1u, remaining_recv_slots_); | 333 DCHECK_EQ(1u, remaining_recv_slots_); |
283 DoRecvFrom(); | 334 DoRecvFrom(); |
284 } | 335 } |
285 | 336 |
286 return PP_OK; | 337 return PP_OK; |
287 } | 338 } |
288 | 339 |
340 int32_t PepperUDPSocketMessageFilter::OnMsgJoinGroup( | |
341 const ppapi::host::HostMessageContext* context, | |
342 const PP_NetAddress_Private& addr) { | |
343 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
344 | |
345 int32_t ret = CanUseMulticastAPI(addr); | |
346 if (ret != PP_OK) | |
347 return ret; | |
348 | |
349 if (!socket_) | |
350 return PP_ERROR_FAILED; | |
351 | |
352 net::IPAddressNumber group; | |
353 uint16 port; | |
354 | |
355 if (!NetAddressPrivateImpl::NetAddressToIPEndPoint(addr, &group, &port)) | |
356 return PP_ERROR_ADDRESS_INVALID; | |
357 | |
358 return NetErrorToPepperError(socket_->JoinGroup(group)); | |
359 } | |
360 | |
361 int32_t PepperUDPSocketMessageFilter::OnMsgLeaveGroup( | |
362 const ppapi::host::HostMessageContext* context, | |
363 const PP_NetAddress_Private& addr) { | |
364 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
365 | |
366 int32_t ret = CanUseMulticastAPI(addr); | |
367 if (ret != PP_OK) | |
368 return ret; | |
369 | |
370 if (!socket_) | |
371 return PP_ERROR_FAILED; | |
372 | |
373 net::IPAddressNumber group; | |
374 uint16 port; | |
375 | |
376 if (!NetAddressPrivateImpl::NetAddressToIPEndPoint(addr, &group, &port)) | |
377 return PP_ERROR_ADDRESS_INVALID; | |
378 | |
379 return NetErrorToPepperError(socket_->LeaveGroup(group)); | |
380 } | |
381 | |
289 void PepperUDPSocketMessageFilter::DoBind( | 382 void PepperUDPSocketMessageFilter::DoBind( |
290 const ppapi::host::ReplyMessageContext& context, | 383 const ppapi::host::ReplyMessageContext& context, |
291 const PP_NetAddress_Private& addr) { | 384 const PP_NetAddress_Private& addr) { |
292 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 385 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
293 | 386 |
294 if (closed_ || socket_.get()) { | 387 if (closed_ || socket_.get()) { |
295 SendBindError(context, PP_ERROR_FAILED); | 388 SendBindError(context, PP_ERROR_FAILED); |
296 return; | 389 return; |
297 } | 390 } |
298 | 391 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 return; | 429 return; |
337 } | 430 } |
338 } | 431 } |
339 if (socket_options_ & SOCKET_OPTION_RCVBUF_SIZE) { | 432 if (socket_options_ & SOCKET_OPTION_RCVBUF_SIZE) { |
340 int net_result = socket->SetReceiveBufferSize(rcvbuf_size_); | 433 int net_result = socket->SetReceiveBufferSize(rcvbuf_size_); |
341 if (net_result != net::OK) { | 434 if (net_result != net::OK) { |
342 SendBindError(context, NetErrorToPepperError(net_result)); | 435 SendBindError(context, NetErrorToPepperError(net_result)); |
343 return; | 436 return; |
344 } | 437 } |
345 } | 438 } |
439 if (socket_options_ & SOCKET_OPTION_MULTICAST_LOOP) { | |
440 int net_result = socket->SetMulticastLoopbackMode(true); | |
441 if (net_result != net::OK) { | |
442 SendBindError(context, NetErrorToPepperError(net_result)); | |
443 return; | |
444 } | |
445 } | |
446 if (socket_options_ & SOCKET_OPTION_MULTICAST_TTL) { | |
447 int net_result = socket->SetMulticastInterface(multicast_ttl_); | |
448 if (net_result != net::OK) { | |
449 SendBindError(context, NetErrorToPepperError(net_result)); | |
450 return; | |
451 } | |
452 } | |
346 | 453 |
347 { | 454 { |
348 int net_result = socket->Bind(end_point); | 455 int net_result = socket->Bind(end_point); |
349 if (net_result != net::OK) { | 456 if (net_result != net::OK) { |
350 SendBindError(context, NetErrorToPepperError(net_result)); | 457 SendBindError(context, NetErrorToPepperError(net_result)); |
351 return; | 458 return; |
352 } | 459 } |
353 } | 460 } |
354 | 461 |
355 net::IPEndPoint bound_address; | 462 net::IPEndPoint bound_address; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 SendRecvFromResult(result, std::string(), | 670 SendRecvFromResult(result, std::string(), |
564 NetAddressPrivateImpl::kInvalidNetAddress); | 671 NetAddressPrivateImpl::kInvalidNetAddress); |
565 } | 672 } |
566 | 673 |
567 void PepperUDPSocketMessageFilter::SendSendToError( | 674 void PepperUDPSocketMessageFilter::SendSendToError( |
568 const ppapi::host::ReplyMessageContext& context, | 675 const ppapi::host::ReplyMessageContext& context, |
569 int32_t result) { | 676 int32_t result) { |
570 SendSendToReply(context, result, 0); | 677 SendSendToReply(context, result, 0); |
571 } | 678 } |
572 | 679 |
680 int32_t PepperUDPSocketMessageFilter::CanUseMulticastAPI( | |
681 const PP_NetAddress_Private& addr) { | |
682 // Check for Dev API. | |
683 // TODO(etrunko): remove check when Multicast API reaches beta/stable. | |
684 // https://crbug.com/464452 | |
685 ContentBrowserClient* content_browser_client = GetContentClient()->browser(); | |
686 if (!content_browser_client->IsPluginAllowedToUseDevChannelAPIs(nullptr, | |
687 GURL())) { | |
688 return PP_ERROR_FAILED; | |
689 } | |
690 | |
691 // Check for plugin permissions. | |
692 SocketPermissionRequest request = | |
693 pepper_socket_utils::CreateSocketPermissionRequest( | |
694 SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP, addr); | |
695 if (!pepper_socket_utils::CanUseSocketAPIs(external_plugin_, | |
696 private_api_, | |
697 &request, | |
698 render_process_id_, | |
699 render_frame_id_)) { | |
700 return PP_ERROR_NOACCESS; | |
701 } | |
702 | |
703 return PP_OK; | |
704 } | |
705 | |
573 } // namespace content | 706 } // namespace content |
OLD | NEW |