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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_socket_utils.cc

Issue 17029002: Change the permission check for Pepper socket API to support both the public and private APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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/browser/renderer_host/pepper/pepper_socket_utils.h" 5 #include "content/browser/renderer_host/pepper/pepper_socket_utils.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 15 matching lines...) Expand all
26 false); 26 false);
27 int port = 0; 27 int port = 0;
28 std::vector<unsigned char> address; 28 std::vector<unsigned char> address;
29 ppapi::NetAddressPrivateImpl::NetAddressToIPEndPoint(net_addr, 29 ppapi::NetAddressPrivateImpl::NetAddressToIPEndPoint(net_addr,
30 &address, 30 &address,
31 &port); 31 &port);
32 return SocketPermissionRequest(type, host, port); 32 return SocketPermissionRequest(type, host, port);
33 } 33 }
34 34
35 bool CanUseSocketAPIs(bool external_plugin, 35 bool CanUseSocketAPIs(bool external_plugin,
36 bool private_api,
36 const SocketPermissionRequest& params, 37 const SocketPermissionRequest& params,
37 RenderViewHost* render_view_host) { 38 RenderViewHost* render_view_host) {
38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
39 40
40 if (!external_plugin) { 41 if (!external_plugin) {
41 // Always allow socket APIs for out-process plugins (other than external 42 // Always allow socket APIs for out-process plugins (other than external
42 // plugins instantiated by the embeeder through 43 // plugins instantiated by the embeeder through
43 // BrowserPpapiHost::CreateExternalPluginProcess). 44 // BrowserPpapiHost::CreateExternalPluginProcess).
44 return true; 45 return true;
45 } 46 }
46 47
47 if (!render_view_host) 48 if (!render_view_host)
48 return false; 49 return false;
49 SiteInstance* site_instance = render_view_host->GetSiteInstance(); 50 SiteInstance* site_instance = render_view_host->GetSiteInstance();
50 if (!site_instance) 51 if (!site_instance)
51 return false; 52 return false;
52 if (!GetContentClient()->browser()->AllowPepperSocketAPI( 53 if (!GetContentClient()->browser()->AllowPepperSocketAPI(
53 site_instance->GetBrowserContext(), 54 site_instance->GetBrowserContext(),
54 site_instance->GetSiteURL(), 55 site_instance->GetSiteURL(),
56 private_api,
55 params)) { 57 params)) {
56 LOG(ERROR) << "Host " << site_instance->GetSiteURL().host() 58 LOG(ERROR) << "Host " << site_instance->GetSiteURL().host()
57 << " cannot use socket API or destination is not allowed"; 59 << " cannot use socket API or destination is not allowed";
58 return false; 60 return false;
59 } 61 }
60 62
61 return true; 63 return true;
62 } 64 }
63 65
64 } // namespace pepper_socket_utils 66 } // namespace pepper_socket_utils
65 } // namespace content 67 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698