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/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "content/renderer/pepper/pepper_audio_input_host.h" | 9 #include "content/renderer/pepper/pepper_audio_input_host.h" |
| 10 #include "content/renderer/pepper/pepper_directory_reader_host.h" | 10 #include "content/renderer/pepper/pepper_directory_reader_host.h" |
| 11 #include "content/renderer/pepper/pepper_file_chooser_host.h" | 11 #include "content/renderer/pepper/pepper_file_chooser_host.h" |
| 12 #include "content/renderer/pepper/pepper_file_io_host.h" | 12 #include "content/renderer/pepper/pepper_file_io_host.h" |
| 13 #include "content/renderer/pepper/pepper_file_system_host.h" | |
| 13 #include "content/renderer/pepper/pepper_graphics_2d_host.h" | 14 #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
| 14 #include "content/renderer/pepper/pepper_truetype_font_host.h" | 15 #include "content/renderer/pepper/pepper_truetype_font_host.h" |
| 15 #include "content/renderer/pepper/pepper_video_capture_host.h" | 16 #include "content/renderer/pepper/pepper_video_capture_host.h" |
| 16 #include "content/renderer/pepper/pepper_websocket_host.h" | 17 #include "content/renderer/pepper/pepper_websocket_host.h" |
| 17 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 18 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 18 #include "ppapi/host/resource_host.h" | 19 #include "ppapi/host/resource_host.h" |
| 19 #include "ppapi/proxy/ppapi_messages.h" | 20 #include "ppapi/proxy/ppapi_messages.h" |
| 20 #include "ppapi/proxy/serialized_structs.h" | 21 #include "ppapi/proxy/serialized_structs.h" |
| 21 | 22 |
| 22 using ppapi::host::ResourceHost; | 23 using ppapi::host::ResourceHost; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 38 PP_Instance instance, | 39 PP_Instance instance, |
| 39 const IPC::Message& message) { | 40 const IPC::Message& message) { |
| 40 DCHECK(host == host_->GetPpapiHost()); | 41 DCHECK(host == host_->GetPpapiHost()); |
| 41 | 42 |
| 42 // Make sure the plugin is giving us a valid instance for this resource. | 43 // Make sure the plugin is giving us a valid instance for this resource. |
| 43 if (!host_->IsValidInstance(instance)) | 44 if (!host_->IsValidInstance(instance)) |
| 44 return scoped_ptr<ResourceHost>(); | 45 return scoped_ptr<ResourceHost>(); |
| 45 | 46 |
| 46 // Public interfaces. | 47 // Public interfaces. |
| 47 switch (message.type()) { | 48 switch (message.type()) { |
| 49 case PpapiHostMsg_FileIO_Create::ID: | |
| 50 return scoped_ptr<ResourceHost>(new PepperFileIOHost( | |
| 51 host_, instance, params.pp_resource())); | |
| 52 case PpapiHostMsg_FileSystem_Create::ID: { | |
| 53 PpapiHostMsg_FileSystem_Create::Schema::Param msg_params; | |
| 54 if (!PpapiHostMsg_FileSystem_Create::Read(&message, &msg_params)) { | |
|
yzshen1
2013/04/08 21:05:16
Please use UnpackMessage() defined in ppapi_messag
victorhsieh
2013/04/08 23:44:38
Done.
| |
| 55 NOTREACHED(); | |
| 56 return scoped_ptr<ResourceHost>(); | |
| 57 } | |
| 58 return scoped_ptr<ResourceHost>(new PepperFileSystemHost( | |
| 59 host_, instance, params.pp_resource(), | |
| 60 msg_params.a /* PP_FileSystemType */)); | |
| 61 } | |
| 48 case PpapiHostMsg_Graphics2D_Create::ID: { | 62 case PpapiHostMsg_Graphics2D_Create::ID: { |
| 49 PpapiHostMsg_Graphics2D_Create::Schema::Param msg_params; | 63 PpapiHostMsg_Graphics2D_Create::Schema::Param msg_params; |
| 50 if (!PpapiHostMsg_Graphics2D_Create::Read(&message, &msg_params)) { | 64 if (!PpapiHostMsg_Graphics2D_Create::Read(&message, &msg_params)) { |
| 51 NOTREACHED(); | 65 NOTREACHED(); |
| 52 return scoped_ptr<ResourceHost>(); | 66 return scoped_ptr<ResourceHost>(); |
| 53 } | 67 } |
| 54 return scoped_ptr<ResourceHost>( | 68 return scoped_ptr<ResourceHost>( |
| 55 PepperGraphics2DHost::Create(host_, instance, params.pp_resource(), | 69 PepperGraphics2DHost::Create(host_, instance, params.pp_resource(), |
| 56 msg_params.a /* PP_Size */, | 70 msg_params.a /* PP_Size */, |
| 57 msg_params.b /* PP_Bool */)); | 71 msg_params.b /* PP_Bool */)); |
| 58 } | 72 } |
| 59 case PpapiHostMsg_WebSocket_Create::ID: | 73 case PpapiHostMsg_WebSocket_Create::ID: |
| 60 return scoped_ptr<ResourceHost>(new PepperWebSocketHost( | 74 return scoped_ptr<ResourceHost>(new PepperWebSocketHost( |
| 61 host_, instance, params.pp_resource())); | 75 host_, instance, params.pp_resource())); |
| 62 case PpapiHostMsg_FileIO_Create::ID: | |
| 63 return scoped_ptr<ResourceHost>(new PepperFileIOHost( | |
| 64 host_, instance, params.pp_resource())); | |
| 65 } | 76 } |
| 66 | 77 |
| 67 // Dev interfaces. | 78 // Dev interfaces. |
| 68 if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { | 79 if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { |
| 69 switch (message.type()) { | 80 switch (message.type()) { |
| 70 case PpapiHostMsg_AudioInput_Create::ID: | 81 case PpapiHostMsg_AudioInput_Create::ID: |
| 71 return scoped_ptr<ResourceHost>(new PepperAudioInputHost( | 82 return scoped_ptr<ResourceHost>(new PepperAudioInputHost( |
| 72 host_, instance, params.pp_resource())); | 83 host_, instance, params.pp_resource())); |
| 73 case PpapiHostMsg_DirectoryReader_Create::ID: | 84 case PpapiHostMsg_DirectoryReader_Create::ID: |
| 74 return scoped_ptr<ResourceHost>(new PepperDirectoryReaderHost( | 85 return scoped_ptr<ResourceHost>(new PepperDirectoryReaderHost( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 105 | 116 |
| 106 return scoped_ptr<ResourceHost>(); | 117 return scoped_ptr<ResourceHost>(); |
| 107 } | 118 } |
| 108 | 119 |
| 109 const ppapi::PpapiPermissions& | 120 const ppapi::PpapiPermissions& |
| 110 ContentRendererPepperHostFactory::GetPermissions() const { | 121 ContentRendererPepperHostFactory::GetPermissions() const { |
| 111 return host_->GetPpapiHost()->permissions(); | 122 return host_->GetPpapiHost()->permissions(); |
| 112 } | 123 } |
| 113 | 124 |
| 114 } // namespace content | 125 } // namespace content |
| OLD | NEW |