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

Unified Diff: content/renderer/pepper/content_renderer_pepper_host_factory.cc

Issue 944033002: PPAPI: Whitelist PPB_CameraDevice_Private for some apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/renderer/content_renderer_client.cc ('k') | ppapi/ppapi_proxy.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/content_renderer_pepper_host_factory.cc
diff --git a/content/renderer/pepper/content_renderer_pepper_host_factory.cc b/content/renderer/pepper/content_renderer_pepper_host_factory.cc
index 2df65f785a483a5a6142f03c9d264a27caae29c7..0187d7d0f464f1f13d022ae94562d36ae7299c5f 100644
--- a/content/renderer/pepper/content_renderer_pepper_host_factory.cc
+++ b/content/renderer/pepper/content_renderer_pepper_host_factory.cc
@@ -62,6 +62,20 @@ bool CanUseMediaStreamAPI(const RendererPpapiHost* host, PP_Instance instance) {
}
#endif // defined(ENABLE_WEBRTC)
+static bool CanUseCameraDeviceAPI(const RendererPpapiHost* host,
+ PP_Instance instance) {
+ blink::WebPluginContainer* container =
+ host->GetContainerForInstance(instance);
+ if (!container)
+ return false;
+
+ GURL document_url = container->element().document().url();
+ ContentRendererClient* content_renderer_client =
+ GetContentClient()->renderer();
+ return content_renderer_client->IsPluginAllowedToUseCameraDeviceAPI(
+ document_url);
+}
+
bool CanUseCompositorAPI(const RendererPpapiHost* host, PP_Instance instance) {
blink::WebPluginContainer* container =
host->GetContainerForInstance(instance);
@@ -205,15 +219,15 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost(
}
}
- // Private interfaces.
- if (GetPermissions().HasPermission(ppapi::PERMISSION_PRIVATE)) {
- switch (message.type()) {
- case PpapiHostMsg_CameraDevice_Create::ID: {
- scoped_ptr<PepperCameraDeviceHost> host(
- new PepperCameraDeviceHost(host_, instance, resource));
- return host->Init() ? host.Pass() : nullptr;
- }
- }
+ // Permissions of the following interfaces are available for whitelisted apps
+ // which may not have access to the other private interfaces.
+ if (message.type() == PpapiHostMsg_CameraDevice_Create::ID) {
+ if (!GetPermissions().HasPermission(ppapi::PERMISSION_PRIVATE) &&
+ !CanUseCameraDeviceAPI(host_, instance))
+ return nullptr;
+ scoped_ptr<PepperCameraDeviceHost> host(
+ new PepperCameraDeviceHost(host_, instance, resource));
+ return host->Init() ? host.Pass() : nullptr;
}
return scoped_ptr<ResourceHost>();
« no previous file with comments | « content/public/renderer/content_renderer_client.cc ('k') | ppapi/ppapi_proxy.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698