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

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: Nits 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)
122 return false;
123
124 const extensions::ExtensionSet* extension_set =
125 &extensions::ExtensionRegistry::Get(profile)->enabled_extensions();
126 if (!extension_set)
127 return false;
128
129 // Access to the vpnProvider API is controlled by extension permissions.
130 if (url.is_valid() && url.SchemeIs(extensions::kExtensionScheme)) {
131 const extensions::Extension* extension = extension_set->GetByID(url.host());
132 if (extension) {
133 if (extension->permissions_data()->HasAPIPermission(
134 extensions::APIPermission::kVpnProvider)) {
135 return true;
136 }
137 }
138 }
139 #endif
140
141 return false;
142 }
143
116 bool ChromeContentBrowserClientPluginsPart::IsPluginAllowedToUseDevChannelAPIs( 144 bool ChromeContentBrowserClientPluginsPart::IsPluginAllowedToUseDevChannelAPIs(
117 content::BrowserContext* browser_context, 145 content::BrowserContext* browser_context,
118 const GURL& url, 146 const GURL& url,
119 const std::set<std::string>& allowed_dev_channel_origins) { 147 const std::set<std::string>& allowed_dev_channel_origins) {
120 // Allow access for tests. 148 // Allow access for tests.
121 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 149 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
122 switches::kEnablePepperTesting)) { 150 switches::kEnablePepperTesting)) {
123 return true; 151 return true;
124 } 152 }
125 153
(...skipping 19 matching lines...) Expand all
145 } 173 }
146 174
147 void ChromeContentBrowserClientPluginsPart::DidCreatePpapiPlugin( 175 void ChromeContentBrowserClientPluginsPart::DidCreatePpapiPlugin(
148 content::BrowserPpapiHost* browser_host) { 176 content::BrowserPpapiHost* browser_host) {
149 browser_host->GetPpapiHost()->AddHostFactoryFilter( 177 browser_host->GetPpapiHost()->AddHostFactoryFilter(
150 std::unique_ptr<ppapi::host::HostFactory>( 178 std::unique_ptr<ppapi::host::HostFactory>(
151 new ChromeBrowserPepperHostFactory(browser_host))); 179 new ChromeBrowserPepperHostFactory(browser_host)));
152 } 180 }
153 181
154 } // namespace plugins 182 } // 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