Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1143)

Side by Side Diff: content/renderer/pepper_plugin_delegate_impl.cc

Issue 9379002: Move socket API restriction check to browser process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_plugin_delegate_impl.h" 5 #include "content/renderer/pepper_plugin_delegate_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 const PP_NetAddress_Private& local_addr, 1642 const PP_NetAddress_Private& local_addr,
1643 const PP_NetAddress_Private& remote_addr) { 1643 const PP_NetAddress_Private& remote_addr) {
1644 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector = 1644 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector =
1645 *pending_connect_tcps_.Lookup(request_id); 1645 *pending_connect_tcps_.Lookup(request_id);
1646 pending_connect_tcps_.Remove(request_id); 1646 pending_connect_tcps_.Remove(request_id);
1647 1647
1648 connector->CompleteConnectTcp(socket, local_addr, remote_addr); 1648 connector->CompleteConnectTcp(socket, local_addr, remote_addr);
1649 } 1649 }
1650 1650
1651 uint32 PepperPluginDelegateImpl::TCPSocketCreate() { 1651 uint32 PepperPluginDelegateImpl::TCPSocketCreate() {
1652 if (!CanUseSocketAPIs())
1653 return 0;
1654
1655 uint32 socket_id = 0; 1652 uint32 socket_id = 0;
1656 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Create( 1653 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Create(
1657 render_view_->routing_id(), 0, &socket_id)); 1654 render_view_->routing_id(), 0, &socket_id));
1658 return socket_id; 1655 return socket_id;
1659 } 1656 }
1660 1657
1661 void PepperPluginDelegateImpl::TCPSocketConnect( 1658 void PepperPluginDelegateImpl::TCPSocketConnect(
1662 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, 1659 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1663 uint32 socket_id, 1660 uint32 socket_id,
1664 const std::string& host, 1661 const std::string& host,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 1698
1702 void PepperPluginDelegateImpl::TCPSocketDisconnect(uint32 socket_id) { 1699 void PepperPluginDelegateImpl::TCPSocketDisconnect(uint32 socket_id) {
1703 // There are no DCHECK(tcp_sockets_.Lookup(socket_id)) because it 1700 // There are no DCHECK(tcp_sockets_.Lookup(socket_id)) because it
1704 // can be called before 1701 // can be called before
1705 // TCPSocketConnect/TCPSocketConnectWithNetAddress is called. 1702 // TCPSocketConnect/TCPSocketConnectWithNetAddress is called.
1706 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id)); 1703 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id));
1707 tcp_sockets_.Remove(socket_id); 1704 tcp_sockets_.Remove(socket_id);
1708 } 1705 }
1709 1706
1710 uint32 PepperPluginDelegateImpl::UDPSocketCreate() { 1707 uint32 PepperPluginDelegateImpl::UDPSocketCreate() {
1711 if (!CanUseSocketAPIs())
1712 return 0;
1713
1714 uint32 socket_id = 0; 1708 uint32 socket_id = 0;
1715 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create( 1709 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create(
1716 render_view_->routing_id(), 0, &socket_id)); 1710 render_view_->routing_id(), 0, &socket_id));
1717 return socket_id; 1711 return socket_id;
1718 } 1712 }
1719 1713
1720 void PepperPluginDelegateImpl::UDPSocketBind( 1714 void PepperPluginDelegateImpl::UDPSocketBind(
1721 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket, 1715 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1722 uint32 socket_id, 1716 uint32 socket_id,
1723 const PP_NetAddress_Private& addr) { 1717 const PP_NetAddress_Private& addr) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 return NULL; 2069 return NULL;
2076 if (!context->makeContextCurrent() || context->isContextLost()) 2070 if (!context->makeContextCurrent() || context->isContextLost())
2077 return NULL; 2071 return NULL;
2078 2072
2079 ContentGLContext* parent_context = context->context(); 2073 ContentGLContext* parent_context = context->context();
2080 if (!parent_context) 2074 if (!parent_context)
2081 return NULL; 2075 return NULL;
2082 return parent_context; 2076 return parent_context;
2083 } 2077 }
2084 2078
2085 bool PepperPluginDelegateImpl::CanUseSocketAPIs() {
2086 WebView* webview = render_view_->webview();
2087 WebFrame* main_frame = webview ? webview->mainFrame() : NULL;
2088 GURL url(main_frame ? GURL(main_frame->document().url()) : GURL());
2089 if (!url.is_valid())
2090 return false;
2091
2092 return content::GetContentClient()->renderer()->AllowSocketAPI(url);
2093 }
2094
2095 MouseLockDispatcher::LockTarget* 2079 MouseLockDispatcher::LockTarget*
2096 PepperPluginDelegateImpl::GetOrCreateLockTargetAdapter( 2080 PepperPluginDelegateImpl::GetOrCreateLockTargetAdapter(
2097 webkit::ppapi::PluginInstance* instance) { 2081 webkit::ppapi::PluginInstance* instance) {
2098 MouseLockDispatcher::LockTarget* target = mouse_lock_instances_[instance]; 2082 MouseLockDispatcher::LockTarget* target = mouse_lock_instances_[instance];
2099 if (target) 2083 if (target)
2100 return target; 2084 return target;
2101 2085
2102 return mouse_lock_instances_[instance] = 2086 return mouse_lock_instances_[instance] =
2103 new PluginInstanceLockTarget(instance); 2087 new PluginInstanceLockTarget(instance);
2104 } 2088 }
2105 2089
2106 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter( 2090 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter(
2107 webkit::ppapi::PluginInstance* instance) { 2091 webkit::ppapi::PluginInstance* instance) {
2108 LockTargetMap::iterator it = mouse_lock_instances_.find(instance); 2092 LockTargetMap::iterator it = mouse_lock_instances_.find(instance);
2109 if (it != mouse_lock_instances_.end()) { 2093 if (it != mouse_lock_instances_.end()) {
2110 MouseLockDispatcher::LockTarget* target = it->second; 2094 MouseLockDispatcher::LockTarget* target = it->second;
2111 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); 2095 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target);
2112 delete target; 2096 delete target;
2113 mouse_lock_instances_.erase(it); 2097 mouse_lock_instances_.erase(it);
2114 } 2098 }
2115 } 2099 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698