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

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: Prepare whitelist in constructor 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
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 143fb18cdb7ba3834a7d3c245a1f9988b739306a..2cd83d52892fac239169e2bed94f466061e03f30 100644
--- a/content/renderer/pepper/content_renderer_pepper_host_factory.cc
+++ b/content/renderer/pepper/content_renderer_pepper_host_factory.cc
@@ -61,6 +61,20 @@ bool CanUseMediaStreamAPI(const RendererPpapiHost* host, PP_Instance instance) {
}
#endif // defined(ENABLE_WEBRTC)
+static bool CanUseCameraDeviceAPI(const RendererPpapiHost* host,
+ PP_Instance instance) {
dmichael (off chromium) 2015/02/24 18:24:10 nit: indentation off. You might want to run git cl
Justin Chuang 2015/02/25 03:59:02 Oops. Thanks
+ 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);
@@ -201,15 +215,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>();

Powered by Google App Engine
This is Rietveld 408576698