diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-09 20:17:33 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-09 20:17:33 +0000 |
commit | 8020da75c9009e6033bf491184affd7daa4572f9 (patch) | |
tree | 97e9ebaa51f7484719217621d297e925db2c621a /content/browser/renderer_host/pepper | |
parent | 96f55b819d54e6c3fee0ecfaf4e25bc25c3614d8 (diff) | |
download | chromium_src-8020da75c9009e6033bf491184affd7daa4572f9.zip chromium_src-8020da75c9009e6033bf491184affd7daa4572f9.tar.gz chromium_src-8020da75c9009e6033bf491184affd7daa4572f9.tar.bz2 |
Add pepper permissions checks to network monitor and host resolver
BUG=
Review URL: https://codereview.chromium.org/11360159
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166969 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host/pepper')
3 files changed, 37 insertions, 6 deletions
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc index 2cb3522..c654a77 100644 --- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc +++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc @@ -26,6 +26,7 @@ BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess( channel->AddFilter( new PepperMessageFilter(PepperMessageFilter::NACL, + permissions, host_resolver, render_process_id, render_view_id)); diff --git a/content/browser/renderer_host/pepper/pepper_message_filter.cc b/content/browser/renderer_host/pepper/pepper_message_filter.cc index eae1606..3b1f2e9 100644 --- a/content/browser/renderer_host/pepper/pepper_message_filter.cc +++ b/content/browser/renderer_host/pepper/pepper_message_filter.cc @@ -89,6 +89,7 @@ PepperMessageFilter::PepperMessageFilter(ProcessType type, int process_id, BrowserContext* browser_context) : process_type_(type), + permissions_(), process_id_(process_id), nacl_render_view_id_(0), resource_context_(browser_context->GetResourceContext()), @@ -102,9 +103,12 @@ PepperMessageFilter::PepperMessageFilter(ProcessType type, DCHECK(resource_context_); } -PepperMessageFilter::PepperMessageFilter(ProcessType type, - net::HostResolver* host_resolver) +PepperMessageFilter::PepperMessageFilter( + ProcessType type, + const ppapi::PpapiPermissions& permissions, + net::HostResolver* host_resolver) : process_type_(type), + permissions_(permissions), process_id_(0), nacl_render_view_id_(0), resource_context_(NULL), @@ -115,11 +119,14 @@ PepperMessageFilter::PepperMessageFilter(ProcessType type, DCHECK(host_resolver); } -PepperMessageFilter::PepperMessageFilter(ProcessType type, - net::HostResolver* host_resolver, - int process_id, - int render_view_id) +PepperMessageFilter::PepperMessageFilter( + ProcessType type, + const ppapi::PpapiPermissions& permissions, + net::HostResolver* host_resolver, + int process_id, + int render_view_id) : process_type_(type), + permissions_(permissions), process_id_(process_id), nacl_render_view_id_(render_view_id), resource_context_(NULL), @@ -595,6 +602,11 @@ void PepperMessageFilter::OnHostResolverResolve( uint32 host_resolver_id, const ppapi::HostPortPair& host_port, const PP_HostResolver_Private_Hint& hint) { + // Support all in-process plugins, and ones with "private" permissions. + if (process_type_ != RENDERER && + !permissions_.HasPermission(ppapi::PERMISSION_PRIVATE)) + return; + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); net::HostResolver::RequestInfo request_info( net::HostPortPair(host_port.host, host_port.port)); @@ -678,6 +690,11 @@ bool PepperMessageFilter::SendHostResolverResolveACKError( } void PepperMessageFilter::OnNetworkMonitorStart(uint32 plugin_dispatcher_id) { + // Support all in-process plugins, and ones with "private" permissions. + if (process_type_ != RENDERER && + !permissions_.HasPermission(ppapi::PERMISSION_PRIVATE)) + return; + if (network_monitor_ids_.empty()) net::NetworkChangeNotifier::AddIPAddressObserver(this); @@ -686,6 +703,11 @@ void PepperMessageFilter::OnNetworkMonitorStart(uint32 plugin_dispatcher_id) { } void PepperMessageFilter::OnNetworkMonitorStop(uint32 plugin_dispatcher_id) { + // Support all in-process plugins, and ones with "private" permissions. + if (process_type_ != RENDERER && + !permissions_.HasPermission(ppapi::PERMISSION_PRIVATE)) + return; + network_monitor_ids_.erase(plugin_dispatcher_id); if (network_monitor_ids_.empty()) net::NetworkChangeNotifier::RemoveIPAddressObserver(this); diff --git a/content/browser/renderer_host/pepper/pepper_message_filter.h b/content/browser/renderer_host/pepper/pepper_message_filter.h index 7d840ee..f8608a0 100644 --- a/content/browser/renderer_host/pepper/pepper_message_filter.h +++ b/content/browser/renderer_host/pepper/pepper_message_filter.h @@ -73,11 +73,13 @@ class PepperMessageFilter // Constructor when used in the context of a PPAPI process (the argument is // provided for sanity checking and must be PLUGIN). PepperMessageFilter(ProcessType type, + const ppapi::PpapiPermissions& permissions, net::HostResolver* host_resolver); // Constructor when used in the context of a NaCl process (the argument is // provided for sanity checking and must be NACL). PepperMessageFilter(ProcessType type, + const ppapi::PpapiPermissions& permissions, net::HostResolver* host_resolver, int process_id, int render_view_id); @@ -253,6 +255,12 @@ class PepperMessageFilter ProcessType process_type_; + // When attached to an out-of-process plugin (be it native or NaCl) this + // will have the Pepper permissions for the plugin. When attached to the + // renderer channel, this will have no permissions listed (since there may + // be many plugins sharing this channel). + ppapi::PpapiPermissions permissions_; + // Render process ID. int process_id_; |