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/public/common/content_client.h" | 9 #include "content/public/common/content_client.h" |
| 10 #include "content/public/renderer/content_renderer_client.h" | 10 #include "content/public/renderer/content_renderer_client.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 if (!container) | 67 if (!container) |
| 68 return false; | 68 return false; |
| 69 | 69 |
| 70 GURL document_url = container->element().document().url(); | 70 GURL document_url = container->element().document().url(); |
| 71 ContentRendererClient* content_renderer_client = | 71 ContentRendererClient* content_renderer_client = |
| 72 GetContentClient()->renderer(); | 72 GetContentClient()->renderer(); |
| 73 return content_renderer_client->IsPluginAllowedToUseCompositorAPI( | 73 return content_renderer_client->IsPluginAllowedToUseCompositorAPI( |
| 74 document_url); | 74 document_url); |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool CanUseVideoDecodeAPI(const RendererPpapiHost* host, PP_Instance instance) { | |
| 78 blink::WebPluginContainer* container = | |
| 79 host->GetContainerForInstance(instance); | |
| 80 if (!container) | |
| 81 return false; | |
| 82 | |
| 83 GURL document_url = container->element().document().url(); | |
| 84 ContentRendererClient* content_renderer_client = | |
| 85 GetContentClient()->renderer(); | |
| 86 return content_renderer_client->IsPluginAllowedToUseVideoDecodeAPI( | |
| 87 document_url); | |
| 88 } | |
| 89 | |
| 90 } // namespace | 77 } // namespace |
| 91 | 78 |
| 92 ContentRendererPepperHostFactory::ContentRendererPepperHostFactory( | 79 ContentRendererPepperHostFactory::ContentRendererPepperHostFactory( |
| 93 RendererPpapiHostImpl* host) | 80 RendererPpapiHostImpl* host) |
| 94 : host_(host) {} | 81 : host_(host) {} |
| 95 | 82 |
| 96 ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() {} | 83 ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() {} |
| 97 | 84 |
| 98 scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( | 85 scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( |
| 99 ppapi::host::PpapiHost* host, | 86 ppapi::host::PpapiHost* host, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 #endif | 152 #endif |
| 166 scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( | 153 scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( |
| 167 instance, image_type)); | 154 instance, image_type)); |
| 168 return scoped_ptr<ResourceHost>(PepperGraphics2DHost::Create( | 155 return scoped_ptr<ResourceHost>(PepperGraphics2DHost::Create( |
| 169 host_, instance, resource, size, is_always_opaque, image_data)); | 156 host_, instance, resource, size, is_always_opaque, image_data)); |
| 170 } | 157 } |
| 171 case PpapiHostMsg_URLLoader_Create::ID: | 158 case PpapiHostMsg_URLLoader_Create::ID: |
| 172 return scoped_ptr<ResourceHost>( | 159 return scoped_ptr<ResourceHost>( |
| 173 new PepperURLLoaderHost(host_, false, instance, resource)); | 160 new PepperURLLoaderHost(host_, false, instance, resource)); |
| 174 case PpapiHostMsg_VideoDecoder_Create::ID: { | 161 case PpapiHostMsg_VideoDecoder_Create::ID: { |
| 175 if (!CanUseVideoDecodeAPI(host_, instance)) | |
| 176 return scoped_ptr<ResourceHost>(); | |
| 177 return scoped_ptr<ResourceHost>( | 162 return scoped_ptr<ResourceHost>( |
| 178 new PepperVideoDecoderHost(host_, instance, resource)); | 163 new PepperVideoDecoderHost(host_, instance, resource)); |
| 179 } | 164 } |
|
Avi (use Gerrit)
2015/01/09 23:07:08
To match the style of the surrounding code, drop t
bbudge
2015/01/09 23:22:04
Good eye. Done!
| |
| 180 case PpapiHostMsg_WebSocket_Create::ID: | 165 case PpapiHostMsg_WebSocket_Create::ID: |
| 181 return scoped_ptr<ResourceHost>( | 166 return scoped_ptr<ResourceHost>( |
| 182 new PepperWebSocketHost(host_, instance, resource)); | 167 new PepperWebSocketHost(host_, instance, resource)); |
| 183 #if defined(ENABLE_WEBRTC) | 168 #if defined(ENABLE_WEBRTC) |
| 184 case PpapiHostMsg_MediaStreamVideoTrack_Create::ID: | 169 case PpapiHostMsg_MediaStreamVideoTrack_Create::ID: |
| 185 return scoped_ptr<ResourceHost>( | 170 return scoped_ptr<ResourceHost>( |
| 186 new PepperMediaStreamVideoTrackHost(host_, instance, resource)); | 171 new PepperMediaStreamVideoTrackHost(host_, instance, resource)); |
| 187 // These private MediaStream interfaces are exposed as if they were public | 172 // These private MediaStream interfaces are exposed as if they were public |
| 188 // so they can be used by NaCl plugins. However, they are available only | 173 // so they can be used by NaCl plugins. However, they are available only |
| 189 // for whitelisted apps. | 174 // for whitelisted apps. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 | 206 |
| 222 return scoped_ptr<ResourceHost>(); | 207 return scoped_ptr<ResourceHost>(); |
| 223 } | 208 } |
| 224 | 209 |
| 225 const ppapi::PpapiPermissions& | 210 const ppapi::PpapiPermissions& |
| 226 ContentRendererPepperHostFactory::GetPermissions() const { | 211 ContentRendererPepperHostFactory::GetPermissions() const { |
| 227 return host_->GetPpapiHost()->permissions(); | 212 return host_->GetPpapiHost()->permissions(); |
| 228 } | 213 } |
| 229 | 214 |
| 230 } // namespace content | 215 } // namespace content |
| OLD | NEW |