Chromium Code Reviews| 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>(); |