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/string_util.h" |
8 #include "content/renderer/pepper/pepper_audio_input_host.h" | 9 #include "content/renderer/pepper/pepper_audio_input_host.h" |
9 #include "content/renderer/pepper/pepper_directory_reader_host.h" | 10 #include "content/renderer/pepper/pepper_directory_reader_host.h" |
10 #include "content/renderer/pepper/pepper_file_chooser_host.h" | 11 #include "content/renderer/pepper/pepper_file_chooser_host.h" |
11 #include "content/renderer/pepper/pepper_file_io_host.h" | 12 #include "content/renderer/pepper/pepper_file_io_host.h" |
12 #include "content/renderer/pepper/pepper_graphics_2d_host.h" | 13 #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
| 14 #include "content/renderer/pepper/pepper_truetype_font_host.h" |
13 #include "content/renderer/pepper/pepper_video_capture_host.h" | 15 #include "content/renderer/pepper/pepper_video_capture_host.h" |
14 #include "content/renderer/pepper/pepper_websocket_host.h" | 16 #include "content/renderer/pepper/pepper_websocket_host.h" |
15 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 17 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
16 #include "ppapi/host/resource_host.h" | 18 #include "ppapi/host/resource_host.h" |
17 #include "ppapi/proxy/ppapi_messages.h" | 19 #include "ppapi/proxy/ppapi_messages.h" |
| 20 #include "ppapi/proxy/serialized_structs.h" |
18 | 21 |
19 using ppapi::host::ResourceHost; | 22 using ppapi::host::ResourceHost; |
| 23 using ppapi::proxy::SerializedTrueTypeFontDesc; |
20 | 24 |
21 namespace content { | 25 namespace content { |
22 | 26 |
23 ContentRendererPepperHostFactory::ContentRendererPepperHostFactory( | 27 ContentRendererPepperHostFactory::ContentRendererPepperHostFactory( |
24 RendererPpapiHostImpl* host) | 28 RendererPpapiHostImpl* host) |
25 : host_(host) { | 29 : host_(host) { |
26 } | 30 } |
27 | 31 |
28 ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() { | 32 ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() { |
29 } | 33 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 switch (message.type()) { | 69 switch (message.type()) { |
66 case PpapiHostMsg_AudioInput_Create::ID: | 70 case PpapiHostMsg_AudioInput_Create::ID: |
67 return scoped_ptr<ResourceHost>(new PepperAudioInputHost( | 71 return scoped_ptr<ResourceHost>(new PepperAudioInputHost( |
68 host_, instance, params.pp_resource())); | 72 host_, instance, params.pp_resource())); |
69 case PpapiHostMsg_DirectoryReader_Create::ID: | 73 case PpapiHostMsg_DirectoryReader_Create::ID: |
70 return scoped_ptr<ResourceHost>(new PepperDirectoryReaderHost( | 74 return scoped_ptr<ResourceHost>(new PepperDirectoryReaderHost( |
71 host_, instance, params.pp_resource())); | 75 host_, instance, params.pp_resource())); |
72 case PpapiHostMsg_FileChooser_Create::ID: | 76 case PpapiHostMsg_FileChooser_Create::ID: |
73 return scoped_ptr<ResourceHost>(new PepperFileChooserHost( | 77 return scoped_ptr<ResourceHost>(new PepperFileChooserHost( |
74 host_, instance, params.pp_resource())); | 78 host_, instance, params.pp_resource())); |
| 79 case PpapiHostMsg_TrueTypeFont_Create::ID: { |
| 80 PpapiHostMsg_TrueTypeFont_Create::Schema::Param msg_params; |
| 81 if (!PpapiHostMsg_TrueTypeFont_Create::Read(&message, &msg_params)) { |
| 82 NOTREACHED(); |
| 83 return scoped_ptr<ResourceHost>(); |
| 84 } |
| 85 // Check that the family name is valid UTF-8 before passing it to the |
| 86 // host OS. |
| 87 const SerializedTrueTypeFontDesc& desc = msg_params.a; |
| 88 if (IsStringUTF8(desc.family)) { |
| 89 return scoped_ptr<ResourceHost>(new PepperTrueTypeFontHost( |
| 90 host_, instance, params.pp_resource(), desc)); |
| 91 } |
| 92 break; // Drop through and return null host. |
| 93 } |
75 case PpapiHostMsg_VideoCapture_Create::ID: { | 94 case PpapiHostMsg_VideoCapture_Create::ID: { |
76 PepperVideoCaptureHost* host = new PepperVideoCaptureHost( | 95 PepperVideoCaptureHost* host = new PepperVideoCaptureHost( |
77 host_, instance, params.pp_resource()); | 96 host_, instance, params.pp_resource()); |
78 if (!host->Init()) { | 97 if (!host->Init()) { |
79 delete host; | 98 delete host; |
80 return scoped_ptr<ResourceHost>(); | 99 return scoped_ptr<ResourceHost>(); |
81 } | 100 } |
82 return scoped_ptr<ResourceHost>(host); | 101 return scoped_ptr<ResourceHost>(host); |
83 } | 102 } |
84 } | 103 } |
85 } | 104 } |
86 | 105 |
87 return scoped_ptr<ResourceHost>(); | 106 return scoped_ptr<ResourceHost>(); |
88 } | 107 } |
89 | 108 |
90 const ppapi::PpapiPermissions& | 109 const ppapi::PpapiPermissions& |
91 ContentRendererPepperHostFactory::GetPermissions() const { | 110 ContentRendererPepperHostFactory::GetPermissions() const { |
92 return host_->GetPpapiHost()->permissions(); | 111 return host_->GetPpapiHost()->permissions(); |
93 } | 112 } |
94 | 113 |
95 } // namespace content | 114 } // namespace content |
OLD | NEW |