Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/content_renderer_pepper_host_factory.h" | 5 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "content/common/content_switches_internal.h" | 9 #include "content/common/content_switches_internal.h" |
| 10 #include "content/public/common/content_client.h" | 10 #include "content/public/common/content_client.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 if (!container) | 54 if (!container) |
| 55 return false; | 55 return false; |
| 56 | 56 |
| 57 GURL document_url = container->element().document().url(); | 57 GURL document_url = container->element().document().url(); |
| 58 ContentRendererClient* content_renderer_client = | 58 ContentRendererClient* content_renderer_client = |
| 59 GetContentClient()->renderer(); | 59 GetContentClient()->renderer(); |
| 60 return content_renderer_client->AllowPepperMediaStreamAPI(document_url); | 60 return content_renderer_client->AllowPepperMediaStreamAPI(document_url); |
| 61 } | 61 } |
| 62 #endif // defined(ENABLE_WEBRTC) | 62 #endif // defined(ENABLE_WEBRTC) |
| 63 | 63 |
| 64 static bool CanUseCameraDeviceAPI(const RendererPpapiHost* host, | |
| 65 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
| |
| 66 blink::WebPluginContainer* container = | |
| 67 host->GetContainerForInstance(instance); | |
| 68 if (!container) | |
| 69 return false; | |
| 70 | |
| 71 GURL document_url = container->element().document().url(); | |
| 72 ContentRendererClient* content_renderer_client = | |
| 73 GetContentClient()->renderer(); | |
| 74 return content_renderer_client->IsPluginAllowedToUseCameraDeviceAPI( | |
| 75 document_url); | |
| 76 } | |
| 77 | |
| 64 bool CanUseCompositorAPI(const RendererPpapiHost* host, PP_Instance instance) { | 78 bool CanUseCompositorAPI(const RendererPpapiHost* host, PP_Instance instance) { |
| 65 blink::WebPluginContainer* container = | 79 blink::WebPluginContainer* container = |
| 66 host->GetContainerForInstance(instance); | 80 host->GetContainerForInstance(instance); |
| 67 if (!container) | 81 if (!container) |
| 68 return false; | 82 return false; |
| 69 | 83 |
| 70 GURL document_url = container->element().document().url(); | 84 GURL document_url = container->element().document().url(); |
| 71 ContentRendererClient* content_renderer_client = | 85 ContentRendererClient* content_renderer_client = |
| 72 GetContentClient()->renderer(); | 86 GetContentClient()->renderer(); |
| 73 return content_renderer_client->IsPluginAllowedToUseCompositorAPI( | 87 return content_renderer_client->IsPluginAllowedToUseCompositorAPI( |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 new PepperVideoCaptureHost(host_, instance, resource); | 208 new PepperVideoCaptureHost(host_, instance, resource); |
| 195 if (!host->Init()) { | 209 if (!host->Init()) { |
| 196 delete host; | 210 delete host; |
| 197 return scoped_ptr<ResourceHost>(); | 211 return scoped_ptr<ResourceHost>(); |
| 198 } | 212 } |
| 199 return scoped_ptr<ResourceHost>(host); | 213 return scoped_ptr<ResourceHost>(host); |
| 200 } | 214 } |
| 201 } | 215 } |
| 202 } | 216 } |
| 203 | 217 |
| 204 // Private interfaces. | 218 // Permissions of the following interfaces are available for whitelisted apps |
| 205 if (GetPermissions().HasPermission(ppapi::PERMISSION_PRIVATE)) { | 219 // which may not have access to the other private interfaces. |
| 206 switch (message.type()) { | 220 if (message.type() == PpapiHostMsg_CameraDevice_Create::ID) { |
| 207 case PpapiHostMsg_CameraDevice_Create::ID: { | 221 if (!GetPermissions().HasPermission(ppapi::PERMISSION_PRIVATE) && |
| 208 scoped_ptr<PepperCameraDeviceHost> host( | 222 !CanUseCameraDeviceAPI(host_, instance)) |
| 209 new PepperCameraDeviceHost(host_, instance, resource)); | 223 return nullptr; |
| 210 return host->Init() ? host.Pass() : nullptr; | 224 scoped_ptr<PepperCameraDeviceHost> host( |
| 211 } | 225 new PepperCameraDeviceHost(host_, instance, resource)); |
| 212 } | 226 return host->Init() ? host.Pass() : nullptr; |
| 213 } | 227 } |
| 214 | 228 |
| 215 return scoped_ptr<ResourceHost>(); | 229 return scoped_ptr<ResourceHost>(); |
| 216 } | 230 } |
| 217 | 231 |
| 218 const ppapi::PpapiPermissions& | 232 const ppapi::PpapiPermissions& |
| 219 ContentRendererPepperHostFactory::GetPermissions() const { | 233 ContentRendererPepperHostFactory::GetPermissions() const { |
| 220 return host_->GetPpapiHost()->permissions(); | 234 return host_->GetPpapiHost()->permissions(); |
| 221 } | 235 } |
| 222 | 236 |
| 223 } // namespace content | 237 } // namespace content |
| OLD | NEW |