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 "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h" | 5 #include "chrome/renderer/pepper/chrome_renderer_pepper_host_factory.h" |
6 | 6 |
| 7 #include "base/logging.h" |
| 8 #include "chrome/renderer/pepper/pepper_flash_font_file_host.h" |
| 9 #include "content/public/renderer/renderer_ppapi_host.h" |
| 10 #include "ppapi/host/ppapi_host.h" |
7 #include "ppapi/host/resource_host.h" | 11 #include "ppapi/host/resource_host.h" |
8 #include "ppapi/proxy/ppapi_messages.h" | 12 #include "ppapi/proxy/ppapi_messages.h" |
| 13 #include "ppapi/shared_impl/ppapi_permissions.h" |
9 | 14 |
10 using ppapi::host::ResourceHost; | 15 using ppapi::host::ResourceHost; |
11 | 16 |
12 namespace chrome { | 17 namespace chrome { |
13 | 18 |
14 ChromeRendererPepperHostFactory::ChromeRendererPepperHostFactory() { | 19 ChromeRendererPepperHostFactory::ChromeRendererPepperHostFactory( |
| 20 content::RendererPpapiHost* host) |
| 21 : host_(host) { |
15 } | 22 } |
16 | 23 |
17 ChromeRendererPepperHostFactory::~ChromeRendererPepperHostFactory() { | 24 ChromeRendererPepperHostFactory::~ChromeRendererPepperHostFactory() { |
18 } | 25 } |
19 | 26 |
20 scoped_ptr<ResourceHost> | 27 scoped_ptr<ResourceHost> |
21 ChromeRendererPepperHostFactory::CreateResourceHost( | 28 ChromeRendererPepperHostFactory::CreateResourceHost( |
22 ppapi::host::PpapiHost* host, | 29 ppapi::host::PpapiHost* host, |
23 const ppapi::proxy::ResourceMessageCallParams& params, | 30 const ppapi::proxy::ResourceMessageCallParams& params, |
24 PP_Instance instance, | 31 PP_Instance instance, |
25 const IPC::Message& message) { | 32 const IPC::Message& message) { |
26 // There are no Chrome-side implementations of resources. | 33 DCHECK(host == host_->GetPpapiHost()); |
| 34 |
| 35 // Make sure the plugin is giving us a valid instance for this resource. |
| 36 if (!host_->IsValidInstance(instance)) |
| 37 return scoped_ptr<ResourceHost>(); |
| 38 |
| 39 if (host_->GetPpapiHost()->permissions().HasPermission( |
| 40 ppapi::PERMISSION_FLASH)) { |
| 41 switch (message.type()) { |
| 42 case PpapiHostMsg_FlashFontFile_Create::ID: |
| 43 PpapiHostMsg_FlashFontFile_Create::Param param; |
| 44 if (PpapiHostMsg_FlashFontFile_Create::Read(&message, ¶m)) { |
| 45 return scoped_ptr<ResourceHost>(new PepperFlashFontFileHost( |
| 46 host_, instance, params.pp_resource(), param.a, param.b)); |
| 47 } |
| 48 break; |
| 49 } |
| 50 } |
| 51 |
27 return scoped_ptr<ResourceHost>(); | 52 return scoped_ptr<ResourceHost>(); |
28 } | 53 } |
29 | 54 |
30 } // namespace chrome | 55 } // namespace chrome |
OLD | NEW |