| 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" |
| 11 #include "content/renderer/pepper/pepper_audio_input_host.h" | 11 #include "content/renderer/pepper/pepper_audio_input_host.h" |
| 12 #include "content/renderer/pepper/pepper_compositor_host.h" | 12 #include "content/renderer/pepper/pepper_compositor_host.h" |
| 13 #include "content/renderer/pepper/pepper_file_chooser_host.h" | 13 #include "content/renderer/pepper/pepper_file_chooser_host.h" |
| 14 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" | 14 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" |
| 15 #include "content/renderer/pepper/pepper_file_system_host.h" | 15 #include "content/renderer/pepper/pepper_file_system_host.h" |
| 16 #include "content/renderer/pepper/pepper_graphics_2d_host.h" | 16 #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
| 17 #include "content/renderer/pepper/pepper_media_stream_video_track_host.h" | 17 #include "content/renderer/pepper/pepper_media_stream_video_track_host.h" |
| 18 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 18 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 19 #include "content/renderer/pepper/pepper_truetype_font_host.h" | |
| 20 #include "content/renderer/pepper/pepper_url_loader_host.h" | 19 #include "content/renderer/pepper/pepper_url_loader_host.h" |
| 21 #include "content/renderer/pepper/pepper_video_capture_host.h" | 20 #include "content/renderer/pepper/pepper_video_capture_host.h" |
| 22 #include "content/renderer/pepper/pepper_video_decoder_host.h" | 21 #include "content/renderer/pepper/pepper_video_decoder_host.h" |
| 23 #include "content/renderer/pepper/pepper_video_destination_host.h" | 22 #include "content/renderer/pepper/pepper_video_destination_host.h" |
| 24 #include "content/renderer/pepper/pepper_video_source_host.h" | 23 #include "content/renderer/pepper/pepper_video_source_host.h" |
| 25 #include "content/renderer/pepper/pepper_websocket_host.h" | 24 #include "content/renderer/pepper/pepper_websocket_host.h" |
| 26 #include "content/renderer/pepper/ppb_image_data_impl.h" | 25 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| 27 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 26 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 28 #include "ppapi/host/resource_host.h" | 27 #include "ppapi/host/resource_host.h" |
| 29 #include "ppapi/proxy/ppapi_message_utils.h" | 28 #include "ppapi/proxy/ppapi_message_utils.h" |
| 30 #include "ppapi/proxy/ppapi_messages.h" | 29 #include "ppapi/proxy/ppapi_messages.h" |
| 31 #include "ppapi/proxy/serialized_structs.h" | 30 #include "ppapi/proxy/serialized_structs.h" |
| 32 #include "ppapi/shared_impl/ppb_image_data_shared.h" | 31 #include "ppapi/shared_impl/ppb_image_data_shared.h" |
| 33 #include "third_party/WebKit/public/platform/WebURL.h" | 32 #include "third_party/WebKit/public/platform/WebURL.h" |
| 34 #include "third_party/WebKit/public/web/WebDocument.h" | 33 #include "third_party/WebKit/public/web/WebDocument.h" |
| 35 #include "third_party/WebKit/public/web/WebElement.h" | 34 #include "third_party/WebKit/public/web/WebElement.h" |
| 36 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 35 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 37 | 36 |
| 38 using ppapi::host::ResourceHost; | 37 using ppapi::host::ResourceHost; |
| 39 using ppapi::proxy::SerializedTrueTypeFontDesc; | |
| 40 using ppapi::UnpackMessage; | 38 using ppapi::UnpackMessage; |
| 41 | 39 |
| 42 namespace content { | 40 namespace content { |
| 43 | 41 |
| 44 #if defined(ENABLE_WEBRTC) | 42 #if defined(ENABLE_WEBRTC) |
| 45 namespace { | 43 namespace { |
| 46 | 44 |
| 47 bool CanUseMediaStreamAPI(const RendererPpapiHost* host, PP_Instance instance) { | 45 bool CanUseMediaStreamAPI(const RendererPpapiHost* host, PP_Instance instance) { |
| 48 blink::WebPluginContainer* container = | 46 blink::WebPluginContainer* container = |
| 49 host->GetContainerForInstance(instance); | 47 host->GetContainerForInstance(instance); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 153 |
| 156 // Dev interfaces. | 154 // Dev interfaces. |
| 157 if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { | 155 if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { |
| 158 switch (message.type()) { | 156 switch (message.type()) { |
| 159 case PpapiHostMsg_AudioInput_Create::ID: | 157 case PpapiHostMsg_AudioInput_Create::ID: |
| 160 return scoped_ptr<ResourceHost>( | 158 return scoped_ptr<ResourceHost>( |
| 161 new PepperAudioInputHost(host_, instance, params.pp_resource())); | 159 new PepperAudioInputHost(host_, instance, params.pp_resource())); |
| 162 case PpapiHostMsg_FileChooser_Create::ID: | 160 case PpapiHostMsg_FileChooser_Create::ID: |
| 163 return scoped_ptr<ResourceHost>( | 161 return scoped_ptr<ResourceHost>( |
| 164 new PepperFileChooserHost(host_, instance, params.pp_resource())); | 162 new PepperFileChooserHost(host_, instance, params.pp_resource())); |
| 165 case PpapiHostMsg_TrueTypeFont_Create::ID: { | |
| 166 SerializedTrueTypeFontDesc desc; | |
| 167 if (!UnpackMessage<PpapiHostMsg_TrueTypeFont_Create>(message, &desc)) { | |
| 168 NOTREACHED(); | |
| 169 return scoped_ptr<ResourceHost>(); | |
| 170 } | |
| 171 // Check that the family name is valid UTF-8 before passing it to the | |
| 172 // host OS. | |
| 173 if (base::IsStringUTF8(desc.family)) { | |
| 174 return scoped_ptr<ResourceHost>(new PepperTrueTypeFontHost( | |
| 175 host_, instance, params.pp_resource(), desc)); | |
| 176 } | |
| 177 break; // Drop through and return null host. | |
| 178 } | |
| 179 case PpapiHostMsg_VideoCapture_Create::ID: { | 163 case PpapiHostMsg_VideoCapture_Create::ID: { |
| 180 PepperVideoCaptureHost* host = | 164 PepperVideoCaptureHost* host = |
| 181 new PepperVideoCaptureHost(host_, instance, params.pp_resource()); | 165 new PepperVideoCaptureHost(host_, instance, params.pp_resource()); |
| 182 if (!host->Init()) { | 166 if (!host->Init()) { |
| 183 delete host; | 167 delete host; |
| 184 return scoped_ptr<ResourceHost>(); | 168 return scoped_ptr<ResourceHost>(); |
| 185 } | 169 } |
| 186 return scoped_ptr<ResourceHost>(host); | 170 return scoped_ptr<ResourceHost>(host); |
| 187 } | 171 } |
| 188 } | 172 } |
| 189 } | 173 } |
| 190 | 174 |
| 191 return scoped_ptr<ResourceHost>(); | 175 return scoped_ptr<ResourceHost>(); |
| 192 } | 176 } |
| 193 | 177 |
| 194 const ppapi::PpapiPermissions& | 178 const ppapi::PpapiPermissions& |
| 195 ContentRendererPepperHostFactory::GetPermissions() const { | 179 ContentRendererPepperHostFactory::GetPermissions() const { |
| 196 return host_->GetPpapiHost()->permissions(); | 180 return host_->GetPpapiHost()->permissions(); |
| 197 } | 181 } |
| 198 | 182 |
| 199 } // namespace content | 183 } // namespace content |
| OLD | NEW |