| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 25 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 26 #include "content/renderer/pepper/pepper_url_loader_host.h" | 26 #include "content/renderer/pepper/pepper_url_loader_host.h" |
| 27 #include "content/renderer/pepper/pepper_video_capture_host.h" | 27 #include "content/renderer/pepper/pepper_video_capture_host.h" |
| 28 #include "content/renderer/pepper/pepper_video_decoder_host.h" | 28 #include "content/renderer/pepper/pepper_video_decoder_host.h" |
| 29 #include "content/renderer/pepper/pepper_video_destination_host.h" | 29 #include "content/renderer/pepper/pepper_video_destination_host.h" |
| 30 #include "content/renderer/pepper/pepper_video_encoder_host.h" | 30 #include "content/renderer/pepper/pepper_video_encoder_host.h" |
| 31 #include "content/renderer/pepper/pepper_video_source_host.h" | 31 #include "content/renderer/pepper/pepper_video_source_host.h" |
| 32 #include "content/renderer/pepper/pepper_websocket_host.h" | 32 #include "content/renderer/pepper/pepper_websocket_host.h" |
| 33 #include "content/renderer/pepper/ppb_image_data_impl.h" | 33 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| 34 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 34 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 35 #include "media/media_features.h" |
| 35 #include "ppapi/host/resource_host.h" | 36 #include "ppapi/host/resource_host.h" |
| 36 #include "ppapi/proxy/ppapi_message_utils.h" | 37 #include "ppapi/proxy/ppapi_message_utils.h" |
| 37 #include "ppapi/proxy/ppapi_messages.h" | 38 #include "ppapi/proxy/ppapi_messages.h" |
| 38 #include "ppapi/proxy/serialized_structs.h" | 39 #include "ppapi/proxy/serialized_structs.h" |
| 39 #include "ppapi/shared_impl/ppb_image_data_shared.h" | 40 #include "ppapi/shared_impl/ppb_image_data_shared.h" |
| 40 #include "third_party/WebKit/public/platform/WebURL.h" | 41 #include "third_party/WebKit/public/platform/WebURL.h" |
| 41 #include "third_party/WebKit/public/web/WebDocument.h" | 42 #include "third_party/WebKit/public/web/WebDocument.h" |
| 42 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 43 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 43 | 44 |
| 44 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 45 #include "base/win/windows_version.h" | 46 #include "base/win/windows_version.h" |
| 46 #endif | 47 #endif |
| 47 | 48 |
| 48 using ppapi::host::ResourceHost; | 49 using ppapi::host::ResourceHost; |
| 49 using ppapi::UnpackMessage; | 50 using ppapi::UnpackMessage; |
| 50 | 51 |
| 51 namespace content { | 52 namespace content { |
| 52 | 53 |
| 53 namespace { | 54 namespace { |
| 54 | 55 |
| 55 #if defined(ENABLE_WEBRTC) | 56 #if BUILDFLAG(ENABLE_WEBRTC) |
| 56 bool CanUseMediaStreamAPI(const RendererPpapiHost* host, PP_Instance instance) { | 57 bool CanUseMediaStreamAPI(const RendererPpapiHost* host, PP_Instance instance) { |
| 57 blink::WebPluginContainer* container = | 58 blink::WebPluginContainer* container = |
| 58 host->GetContainerForInstance(instance); | 59 host->GetContainerForInstance(instance); |
| 59 if (!container) | 60 if (!container) |
| 60 return false; | 61 return false; |
| 61 | 62 |
| 62 GURL document_url = container->document().url(); | 63 GURL document_url = container->document().url(); |
| 63 ContentRendererClient* content_renderer_client = | 64 ContentRendererClient* content_renderer_client = |
| 64 GetContentClient()->renderer(); | 65 GetContentClient()->renderer(); |
| 65 return content_renderer_client->AllowPepperMediaStreamAPI(document_url); | 66 return content_renderer_client->AllowPepperMediaStreamAPI(document_url); |
| 66 } | 67 } |
| 67 #endif // defined(ENABLE_WEBRTC) | 68 #endif // BUILDFLAG(ENABLE_WEBRTC) |
| 68 | 69 |
| 69 static bool CanUseCameraDeviceAPI(const RendererPpapiHost* host, | 70 static bool CanUseCameraDeviceAPI(const RendererPpapiHost* host, |
| 70 PP_Instance instance) { | 71 PP_Instance instance) { |
| 71 blink::WebPluginContainer* container = | 72 blink::WebPluginContainer* container = |
| 72 host->GetContainerForInstance(instance); | 73 host->GetContainerForInstance(instance); |
| 73 if (!container) | 74 if (!container) |
| 74 return false; | 75 return false; |
| 75 | 76 |
| 76 GURL document_url = container->document().url(); | 77 GURL document_url = container->document().url(); |
| 77 ContentRendererClient* content_renderer_client = | 78 ContentRendererClient* content_renderer_client = |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 return base::MakeUnique<PepperURLLoaderHost>(host_, false, instance, | 177 return base::MakeUnique<PepperURLLoaderHost>(host_, false, instance, |
| 177 resource); | 178 resource); |
| 178 case PpapiHostMsg_VideoDecoder_Create::ID: | 179 case PpapiHostMsg_VideoDecoder_Create::ID: |
| 179 return base::MakeUnique<PepperVideoDecoderHost>(host_, instance, | 180 return base::MakeUnique<PepperVideoDecoderHost>(host_, instance, |
| 180 resource); | 181 resource); |
| 181 case PpapiHostMsg_VideoEncoder_Create::ID: | 182 case PpapiHostMsg_VideoEncoder_Create::ID: |
| 182 return base::MakeUnique<PepperVideoEncoderHost>(host_, instance, | 183 return base::MakeUnique<PepperVideoEncoderHost>(host_, instance, |
| 183 resource); | 184 resource); |
| 184 case PpapiHostMsg_WebSocket_Create::ID: | 185 case PpapiHostMsg_WebSocket_Create::ID: |
| 185 return base::MakeUnique<PepperWebSocketHost>(host_, instance, resource); | 186 return base::MakeUnique<PepperWebSocketHost>(host_, instance, resource); |
| 186 #if defined(ENABLE_WEBRTC) | 187 #if BUILDFLAG(ENABLE_WEBRTC) |
| 187 case PpapiHostMsg_MediaStreamVideoTrack_Create::ID: | 188 case PpapiHostMsg_MediaStreamVideoTrack_Create::ID: |
| 188 return base::MakeUnique<PepperMediaStreamVideoTrackHost>(host_, instance, | 189 return base::MakeUnique<PepperMediaStreamVideoTrackHost>(host_, instance, |
| 189 resource); | 190 resource); |
| 190 // These private MediaStream interfaces are exposed as if they were public | 191 // These private MediaStream interfaces are exposed as if they were public |
| 191 // so they can be used by NaCl plugins. However, they are available only | 192 // so they can be used by NaCl plugins. However, they are available only |
| 192 // for whitelisted apps. | 193 // for whitelisted apps. |
| 193 case PpapiHostMsg_VideoDestination_Create::ID: | 194 case PpapiHostMsg_VideoDestination_Create::ID: |
| 194 if (CanUseMediaStreamAPI(host_, instance)) | 195 if (CanUseMediaStreamAPI(host_, instance)) |
| 195 return base::MakeUnique<PepperVideoDestinationHost>(host_, instance, | 196 return base::MakeUnique<PepperVideoDestinationHost>(host_, instance, |
| 196 resource); | 197 resource); |
| 197 case PpapiHostMsg_VideoSource_Create::ID: | 198 case PpapiHostMsg_VideoSource_Create::ID: |
| 198 if (CanUseMediaStreamAPI(host_, instance)) | 199 if (CanUseMediaStreamAPI(host_, instance)) |
| 199 return base::MakeUnique<PepperVideoSourceHost>(host_, instance, | 200 return base::MakeUnique<PepperVideoSourceHost>(host_, instance, |
| 200 resource); | 201 resource); |
| 201 #endif // defined(ENABLE_WEBRTC) | 202 #endif // BUILDFLAG(ENABLE_WEBRTC) |
| 202 } | 203 } |
| 203 | 204 |
| 204 // Dev interfaces. | 205 // Dev interfaces. |
| 205 if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { | 206 if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { |
| 206 switch (message.type()) { | 207 switch (message.type()) { |
| 207 case PpapiHostMsg_AudioEncoder_Create::ID: | 208 case PpapiHostMsg_AudioEncoder_Create::ID: |
| 208 return base::MakeUnique<PepperAudioEncoderHost>(host_, instance, | 209 return base::MakeUnique<PepperAudioEncoderHost>(host_, instance, |
| 209 resource); | 210 resource); |
| 210 case PpapiHostMsg_AudioInput_Create::ID: | 211 case PpapiHostMsg_AudioInput_Create::ID: |
| 211 return base::MakeUnique<PepperAudioInputHost>(host_, instance, | 212 return base::MakeUnique<PepperAudioInputHost>(host_, instance, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 234 | 235 |
| 235 return nullptr; | 236 return nullptr; |
| 236 } | 237 } |
| 237 | 238 |
| 238 const ppapi::PpapiPermissions& | 239 const ppapi::PpapiPermissions& |
| 239 ContentRendererPepperHostFactory::GetPermissions() const { | 240 ContentRendererPepperHostFactory::GetPermissions() const { |
| 240 return host_->GetPpapiHost()->permissions(); | 241 return host_->GetPpapiHost()->permissions(); |
| 241 } | 242 } |
| 242 | 243 |
| 243 } // namespace content | 244 } // namespace content |
| OLD | NEW |