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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 host->GetContainerForInstance(instance); | 49 host->GetContainerForInstance(instance); |
50 if (!container) | 50 if (!container) |
51 return false; | 51 return false; |
52 | 52 |
53 GURL document_url = container->element().document().url(); | 53 GURL document_url = container->element().document().url(); |
54 ContentRendererClient* content_renderer_client = | 54 ContentRendererClient* content_renderer_client = |
55 GetContentClient()->renderer(); | 55 GetContentClient()->renderer(); |
56 return content_renderer_client->AllowPepperMediaStreamAPI(document_url); | 56 return content_renderer_client->AllowPepperMediaStreamAPI(document_url); |
57 } | 57 } |
58 | 58 |
| 59 bool CanUseCompositorAPI(const RendererPpapiHost* host, PP_Instance instance) { |
| 60 blink::WebPluginContainer* container = |
| 61 host->GetContainerForInstance(instance); |
| 62 if (!container) |
| 63 return false; |
| 64 |
| 65 GURL document_url = container->element().document().url(); |
| 66 ContentRendererClient* content_renderer_client = |
| 67 GetContentClient()->renderer(); |
| 68 return content_renderer_client->IsPluginAllowedToUseCompositorAPI( |
| 69 document_url); |
| 70 } |
| 71 |
| 72 bool CanUseVideoDecodeAPI(const RendererPpapiHost* host, PP_Instance instance) { |
| 73 blink::WebPluginContainer* container = |
| 74 host->GetContainerForInstance(instance); |
| 75 if (!container) |
| 76 return false; |
| 77 |
| 78 GURL document_url = container->element().document().url(); |
| 79 ContentRendererClient* content_renderer_client = |
| 80 GetContentClient()->renderer(); |
| 81 return content_renderer_client->IsPluginAllowedToUseVideoDecodeAPI( |
| 82 document_url); |
| 83 } |
| 84 |
59 } // namespace | 85 } // namespace |
60 #endif // defined(ENABLE_WEBRTC) | 86 #endif // defined(ENABLE_WEBRTC) |
61 | 87 |
62 ContentRendererPepperHostFactory::ContentRendererPepperHostFactory( | 88 ContentRendererPepperHostFactory::ContentRendererPepperHostFactory( |
63 RendererPpapiHostImpl* host) | 89 RendererPpapiHostImpl* host) |
64 : host_(host) {} | 90 : host_(host) {} |
65 | 91 |
66 ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() {} | 92 ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() {} |
67 | 93 |
68 scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( | 94 scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( |
69 ppapi::host::PpapiHost* host, | 95 ppapi::host::PpapiHost* host, |
70 const ppapi::proxy::ResourceMessageCallParams& params, | 96 const ppapi::proxy::ResourceMessageCallParams& params, |
71 PP_Instance instance, | 97 PP_Instance instance, |
72 const IPC::Message& message) { | 98 const IPC::Message& message) { |
73 DCHECK(host == host_->GetPpapiHost()); | 99 DCHECK(host == host_->GetPpapiHost()); |
74 | 100 |
75 // Make sure the plugin is giving us a valid instance for this resource. | 101 // Make sure the plugin is giving us a valid instance for this resource. |
76 if (!host_->IsValidInstance(instance)) | 102 if (!host_->IsValidInstance(instance)) |
77 return scoped_ptr<ResourceHost>(); | 103 return scoped_ptr<ResourceHost>(); |
78 | 104 |
79 PepperPluginInstanceImpl* instance_impl = | 105 PepperPluginInstanceImpl* instance_impl = |
80 host_->GetPluginInstanceImpl(instance); | 106 host_->GetPluginInstanceImpl(instance); |
81 if (!instance_impl->render_frame()) | 107 if (!instance_impl->render_frame()) |
82 return scoped_ptr<ResourceHost>(); | 108 return scoped_ptr<ResourceHost>(); |
83 | 109 |
84 // Public interfaces. | 110 // Public interfaces. |
85 switch (message.type()) { | 111 switch (message.type()) { |
86 case PpapiHostMsg_Compositor_Create::ID: { | 112 case PpapiHostMsg_Compositor_Create::ID: { |
87 return scoped_ptr<ResourceHost>( | 113 if (!CanUseCompositorAPI(host_, instance)) |
88 new PepperCompositorHost(host_, instance, params.pp_resource())); | 114 return scoped_ptr<ResourceHost>(); |
89 } | 115 return scoped_ptr<ResourceHost>( |
| 116 new PepperCompositorHost(host_, instance, params.pp_resource())); |
| 117 } |
90 case PpapiHostMsg_FileRef_CreateForFileAPI::ID: { | 118 case PpapiHostMsg_FileRef_CreateForFileAPI::ID: { |
91 PP_Resource file_system; | 119 PP_Resource file_system; |
92 std::string internal_path; | 120 std::string internal_path; |
93 if (!UnpackMessage<PpapiHostMsg_FileRef_CreateForFileAPI>( | 121 if (!UnpackMessage<PpapiHostMsg_FileRef_CreateForFileAPI>( |
94 message, &file_system, &internal_path)) { | 122 message, &file_system, &internal_path)) { |
95 NOTREACHED(); | 123 NOTREACHED(); |
96 return scoped_ptr<ResourceHost>(); | 124 return scoped_ptr<ResourceHost>(); |
97 } | 125 } |
98 return scoped_ptr<ResourceHost>(new PepperFileRefRendererHost( | 126 return scoped_ptr<ResourceHost>(new PepperFileRefRendererHost( |
99 host_, instance, params.pp_resource(), file_system, internal_path)); | 127 host_, instance, params.pp_resource(), file_system, internal_path)); |
(...skipping 22 matching lines...) Expand all Loading... |
122 PepperGraphics2DHost::Create(host_, | 150 PepperGraphics2DHost::Create(host_, |
123 instance, | 151 instance, |
124 params.pp_resource(), | 152 params.pp_resource(), |
125 size, | 153 size, |
126 is_always_opaque, | 154 is_always_opaque, |
127 image_data)); | 155 image_data)); |
128 } | 156 } |
129 case PpapiHostMsg_URLLoader_Create::ID: | 157 case PpapiHostMsg_URLLoader_Create::ID: |
130 return scoped_ptr<ResourceHost>(new PepperURLLoaderHost( | 158 return scoped_ptr<ResourceHost>(new PepperURLLoaderHost( |
131 host_, false, instance, params.pp_resource())); | 159 host_, false, instance, params.pp_resource())); |
132 case PpapiHostMsg_VideoDecoder_Create::ID: | 160 case PpapiHostMsg_VideoDecoder_Create::ID: { |
| 161 if (!CanUseVideoDecodeAPI(host_, instance)) |
| 162 return scoped_ptr<ResourceHost>(); |
133 return scoped_ptr<ResourceHost>( | 163 return scoped_ptr<ResourceHost>( |
134 new PepperVideoDecoderHost(host_, instance, params.pp_resource())); | 164 new PepperVideoDecoderHost(host_, instance, params.pp_resource())); |
| 165 } |
135 case PpapiHostMsg_WebSocket_Create::ID: | 166 case PpapiHostMsg_WebSocket_Create::ID: |
136 return scoped_ptr<ResourceHost>( | 167 return scoped_ptr<ResourceHost>( |
137 new PepperWebSocketHost(host_, instance, params.pp_resource())); | 168 new PepperWebSocketHost(host_, instance, params.pp_resource())); |
138 #if defined(ENABLE_WEBRTC) | 169 #if defined(ENABLE_WEBRTC) |
139 case PpapiHostMsg_MediaStreamVideoTrack_Create::ID: | 170 case PpapiHostMsg_MediaStreamVideoTrack_Create::ID: |
140 return scoped_ptr<ResourceHost>(new PepperMediaStreamVideoTrackHost( | 171 return scoped_ptr<ResourceHost>(new PepperMediaStreamVideoTrackHost( |
141 host_, instance, params.pp_resource())); | 172 host_, instance, params.pp_resource())); |
142 // These private MediaStream interfaces are exposed as if they were public | 173 // These private MediaStream interfaces are exposed as if they were public |
143 // so they can be used by NaCl plugins. However, they are available only | 174 // so they can be used by NaCl plugins. However, they are available only |
144 // for whitelisted apps. | 175 // for whitelisted apps. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 221 |
191 return scoped_ptr<ResourceHost>(); | 222 return scoped_ptr<ResourceHost>(); |
192 } | 223 } |
193 | 224 |
194 const ppapi::PpapiPermissions& | 225 const ppapi::PpapiPermissions& |
195 ContentRendererPepperHostFactory::GetPermissions() const { | 226 ContentRendererPepperHostFactory::GetPermissions() const { |
196 return host_->GetPpapiHost()->permissions(); | 227 return host_->GetPpapiHost()->permissions(); |
197 } | 228 } |
198 | 229 |
199 } // namespace content | 230 } // namespace content |
OLD | NEW |