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