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

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: rebase 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 <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 10
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 const PP_NetAddress_Private& local_addr, 1739 const PP_NetAddress_Private& local_addr,
1740 const PP_NetAddress_Private& remote_addr) { 1740 const PP_NetAddress_Private& remote_addr) {
1741 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector = 1741 scoped_refptr<webkit::ppapi::PPB_Flash_NetConnector_Impl> connector =
1742 *pending_connect_tcps_.Lookup(request_id); 1742 *pending_connect_tcps_.Lookup(request_id);
1743 pending_connect_tcps_.Remove(request_id); 1743 pending_connect_tcps_.Remove(request_id);
1744 1744
1745 connector->CompleteConnectTcp(socket, local_addr, remote_addr); 1745 connector->CompleteConnectTcp(socket, local_addr, remote_addr);
1746 } 1746 }
1747 1747
1748 uint32 PepperPluginDelegateImpl::TCPSocketCreate() { 1748 uint32 PepperPluginDelegateImpl::TCPSocketCreate() {
1749 if (!CanUseSocketAPIs())
1750 return 0;
1751
1752 uint32 socket_id = 0; 1749 uint32 socket_id = 0;
1753 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Create( 1750 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Create(
1754 render_view_->routing_id(), 0, &socket_id)); 1751 render_view_->routing_id(), 0, &socket_id));
1755 return socket_id; 1752 return socket_id;
1756 } 1753 }
1757 1754
1758 void PepperPluginDelegateImpl::TCPSocketConnect( 1755 void PepperPluginDelegateImpl::TCPSocketConnect(
1759 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, 1756 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1760 uint32 socket_id, 1757 uint32 socket_id,
1761 const std::string& host, 1758 const std::string& host,
1762 uint16_t port) { 1759 uint16_t port) {
1763 tcp_sockets_.AddWithID(socket, socket_id); 1760 tcp_sockets_.AddWithID(socket, socket_id);
1764 render_view_->Send( 1761 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Connect(
1765 new PpapiHostMsg_PPBTCPSocket_Connect(socket_id, host, port)); 1762 render_view_->routing_id(), socket_id, host, port));
1766 } 1763 }
1767 1764
1768 void PepperPluginDelegateImpl::TCPSocketConnectWithNetAddress( 1765 void PepperPluginDelegateImpl::TCPSocketConnectWithNetAddress(
1769 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket, 1766 webkit::ppapi::PPB_TCPSocket_Private_Impl* socket,
1770 uint32 socket_id, 1767 uint32 socket_id,
1771 const PP_NetAddress_Private& addr) { 1768 const PP_NetAddress_Private& addr) {
1772 tcp_sockets_.AddWithID(socket, socket_id); 1769 tcp_sockets_.AddWithID(socket, socket_id);
1773 render_view_->Send( 1770 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress(
1774 new PpapiHostMsg_PPBTCPSocket_ConnectWithNetAddress(socket_id, addr)); 1771 render_view_->routing_id(), socket_id, addr));
1775 } 1772 }
1776 1773
1777 void PepperPluginDelegateImpl::TCPSocketSSLHandshake( 1774 void PepperPluginDelegateImpl::TCPSocketSSLHandshake(
1778 uint32 socket_id, 1775 uint32 socket_id,
1779 const std::string& server_name, 1776 const std::string& server_name,
1780 uint16_t server_port) { 1777 uint16_t server_port) {
1781 DCHECK(tcp_sockets_.Lookup(socket_id)); 1778 DCHECK(tcp_sockets_.Lookup(socket_id));
1782 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_SSLHandshake( 1779 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_SSLHandshake(
1783 socket_id, server_name, server_port)); 1780 socket_id, server_name, server_port));
1784 } 1781 }
(...skipping 13 matching lines...) Expand all
1798 1795
1799 void PepperPluginDelegateImpl::TCPSocketDisconnect(uint32 socket_id) { 1796 void PepperPluginDelegateImpl::TCPSocketDisconnect(uint32 socket_id) {
1800 // There are no DCHECK(tcp_sockets_.Lookup(socket_id)) because it 1797 // There are no DCHECK(tcp_sockets_.Lookup(socket_id)) because it
1801 // can be called before 1798 // can be called before
1802 // TCPSocketConnect/TCPSocketConnectWithNetAddress is called. 1799 // TCPSocketConnect/TCPSocketConnectWithNetAddress is called.
1803 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id)); 1800 render_view_->Send(new PpapiHostMsg_PPBTCPSocket_Disconnect(socket_id));
1804 tcp_sockets_.Remove(socket_id); 1801 tcp_sockets_.Remove(socket_id);
1805 } 1802 }
1806 1803
1807 uint32 PepperPluginDelegateImpl::UDPSocketCreate() { 1804 uint32 PepperPluginDelegateImpl::UDPSocketCreate() {
1808 if (!CanUseSocketAPIs())
1809 return 0;
1810
1811 uint32 socket_id = 0; 1805 uint32 socket_id = 0;
1812 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create( 1806 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Create(
1813 render_view_->routing_id(), 0, &socket_id)); 1807 render_view_->routing_id(), 0, &socket_id));
1814 return socket_id; 1808 return socket_id;
1815 } 1809 }
1816 1810
1817 void PepperPluginDelegateImpl::UDPSocketBind( 1811 void PepperPluginDelegateImpl::UDPSocketBind(
1818 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket, 1812 webkit::ppapi::PPB_UDPSocket_Private_Impl* socket,
1819 uint32 socket_id, 1813 uint32 socket_id,
1820 const PP_NetAddress_Private& addr) { 1814 const PP_NetAddress_Private& addr) {
1821 udp_sockets_.AddWithID(socket, socket_id); 1815 udp_sockets_.AddWithID(socket, socket_id);
1822 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind(socket_id, addr)); 1816 render_view_->Send(new PpapiHostMsg_PPBUDPSocket_Bind(
1817 render_view_->routing_id(), socket_id, addr));
1823 } 1818 }
1824 1819
1825 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id, 1820 void PepperPluginDelegateImpl::UDPSocketRecvFrom(uint32 socket_id,
1826 int32_t num_bytes) { 1821 int32_t num_bytes) {
1827 DCHECK(udp_sockets_.Lookup(socket_id)); 1822 DCHECK(udp_sockets_.Lookup(socket_id));
1828 render_view_->Send( 1823 render_view_->Send(
1829 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes)); 1824 new PpapiHostMsg_PPBUDPSocket_RecvFrom(socket_id, num_bytes));
1830 } 1825 }
1831 1826
1832 void PepperPluginDelegateImpl::UDPSocketSendTo( 1827 void PepperPluginDelegateImpl::UDPSocketSendTo(
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 return NULL; 2209 return NULL;
2215 if (!context->makeContextCurrent() || context->isContextLost()) 2210 if (!context->makeContextCurrent() || context->isContextLost())
2216 return NULL; 2211 return NULL;
2217 2212
2218 ContentGLContext* parent_context = context->context(); 2213 ContentGLContext* parent_context = context->context();
2219 if (!parent_context) 2214 if (!parent_context)
2220 return NULL; 2215 return NULL;
2221 return parent_context; 2216 return parent_context;
2222 } 2217 }
2223 2218
2224 bool PepperPluginDelegateImpl::CanUseSocketAPIs() {
2225 WebView* webview = render_view_->webview();
2226 WebFrame* main_frame = webview ? webview->mainFrame() : NULL;
2227 GURL url(main_frame ? GURL(main_frame->document().url()) : GURL());
2228 if (!url.is_valid())
2229 return false;
2230
2231 return content::GetContentClient()->renderer()->AllowSocketAPI(url);
2232 }
2233
2234 MouseLockDispatcher::LockTarget* 2219 MouseLockDispatcher::LockTarget*
2235 PepperPluginDelegateImpl::GetOrCreateLockTargetAdapter( 2220 PepperPluginDelegateImpl::GetOrCreateLockTargetAdapter(
2236 webkit::ppapi::PluginInstance* instance) { 2221 webkit::ppapi::PluginInstance* instance) {
2237 MouseLockDispatcher::LockTarget* target = mouse_lock_instances_[instance]; 2222 MouseLockDispatcher::LockTarget* target = mouse_lock_instances_[instance];
2238 if (target) 2223 if (target)
2239 return target; 2224 return target;
2240 2225
2241 return mouse_lock_instances_[instance] = 2226 return mouse_lock_instances_[instance] =
2242 new PluginInstanceLockTarget(instance); 2227 new PluginInstanceLockTarget(instance);
2243 } 2228 }
2244 2229
2245 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter( 2230 void PepperPluginDelegateImpl::UnSetAndDeleteLockTargetAdapter(
2246 webkit::ppapi::PluginInstance* instance) { 2231 webkit::ppapi::PluginInstance* instance) {
2247 LockTargetMap::iterator it = mouse_lock_instances_.find(instance); 2232 LockTargetMap::iterator it = mouse_lock_instances_.find(instance);
2248 if (it != mouse_lock_instances_.end()) { 2233 if (it != mouse_lock_instances_.end()) {
2249 MouseLockDispatcher::LockTarget* target = it->second; 2234 MouseLockDispatcher::LockTarget* target = it->second;
2250 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target); 2235 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(target);
2251 delete target; 2236 delete target;
2252 mouse_lock_instances_.erase(it); 2237 mouse_lock_instances_.erase(it);
2253 } 2238 }
2254 } 2239 }
OLDNEW
« no previous file with comments | « content/renderer/pepper_plugin_delegate_impl.h ('k') | content/shell/shell_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698