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

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

Powered by Google App Engine
This is Rietveld 408576698