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

Side by Side Diff: chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc

Issue 1985093002: ppapi: PPB_VpnProvider: Implement permission check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to reviews. Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/plugins/chrome_content_browser_client_plugins_part.h" 5 #include "chrome/browser/plugins/chrome_content_browser_client_plugins_part.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/plugins/plugin_info_message_filter.h" 8 #include "chrome/browser/plugins/plugin_info_message_filter.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory .h" 10 #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory .h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 // Allow both public and private APIs if the command line says so. 108 // Allow both public and private APIs if the command line says so.
109 return chrome::IsHostAllowedByCommandLine(url, extension_set, 109 return chrome::IsHostAllowedByCommandLine(url, extension_set,
110 ::switches::kAllowNaClSocketAPI); 110 ::switches::kAllowNaClSocketAPI);
111 #else 111 #else
112 return false; 112 return false;
113 #endif 113 #endif
114 } 114 }
115 115
116 bool ChromeContentBrowserClientPluginsPart::IsPepperVpnProviderAPIAllowed(
117 content::BrowserContext* browser_context,
118 const GURL& url) {
119 #if defined(ENABLE_EXTENSIONS)
120 Profile* profile = Profile::FromBrowserContext(browser_context);
121 if (!profile) {
sky 2016/05/17 21:12:40 nit: no {}
adrian.belgun 2016/05/18 09:09:54 Done.
122 return false;
123 }
124 const extensions::ExtensionSet* extension_set =
125 &extensions::ExtensionRegistry::Get(profile)->enabled_extensions();
126 if (!extension_set) {
sky 2016/05/17 21:12:39 nit: no {}
adrian.belgun 2016/05/18 09:09:54 Done.
127 return false;
128 }
129
130 // Access to the vpnProvider API is controlled by extension permissions.
131 if (url.is_valid() && url.SchemeIs(extensions::kExtensionScheme)) {
132 const extensions::Extension* extension = extension_set->GetByID(url.host());
133 if (extension) {
134 const extensions::PermissionsData* permissions_data =
135 extension->permissions_data();
136 if (permissions_data->HasAPIPermission(
bbudge 2016/05/18 07:28:35 nit: Instead of local permissions_data, just: if
adrian.belgun 2016/05/18 09:09:54 Done.
137 extensions::APIPermission::kVpnProvider)) {
138 return true;
139 }
140 }
141 }
142 #endif
143
144 return false;
145 }
146
116 bool ChromeContentBrowserClientPluginsPart::IsPluginAllowedToUseDevChannelAPIs( 147 bool ChromeContentBrowserClientPluginsPart::IsPluginAllowedToUseDevChannelAPIs(
117 content::BrowserContext* browser_context, 148 content::BrowserContext* browser_context,
118 const GURL& url, 149 const GURL& url,
119 const std::set<std::string>& allowed_dev_channel_origins) { 150 const std::set<std::string>& allowed_dev_channel_origins) {
120 // Allow access for tests. 151 // Allow access for tests.
121 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 152 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
122 switches::kEnablePepperTesting)) { 153 switches::kEnablePepperTesting)) {
123 return true; 154 return true;
124 } 155 }
125 156
(...skipping 19 matching lines...) Expand all
145 } 176 }
146 177
147 void ChromeContentBrowserClientPluginsPart::DidCreatePpapiPlugin( 178 void ChromeContentBrowserClientPluginsPart::DidCreatePpapiPlugin(
148 content::BrowserPpapiHost* browser_host) { 179 content::BrowserPpapiHost* browser_host) {
149 browser_host->GetPpapiHost()->AddHostFactoryFilter( 180 browser_host->GetPpapiHost()->AddHostFactoryFilter(
150 std::unique_ptr<ppapi::host::HostFactory>( 181 std::unique_ptr<ppapi::host::HostFactory>(
151 new ChromeBrowserPepperHostFactory(browser_host))); 182 new ChromeBrowserPepperHostFactory(browser_host)));
152 } 183 }
153 184
154 } // namespace plugins 185 } // namespace plugins
OLDNEW
« no previous file with comments | « chrome/browser/plugins/chrome_content_browser_client_plugins_part.h ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698