| 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 "content/renderer/pepper/pepper_instance_state_accessor.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/pepper/pepper_file_chooser_host.h" | 8 #include "content/renderer/pepper/pepper_file_chooser_host.h" |
| 9 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 9 #include "ppapi/host/resource_host.h" | 10 #include "ppapi/host/resource_host.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 11 | 12 |
| 12 using ppapi::host::ResourceHost; | 13 using ppapi::host::ResourceHost; |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 ContentRendererPepperHostFactory::ContentRendererPepperHostFactory( | 17 ContentRendererPepperHostFactory::ContentRendererPepperHostFactory( |
| 17 RenderViewImpl* render_view, | 18 RendererPpapiHostImpl* host) |
| 18 const ppapi::PpapiPermissions& permissions, | 19 : host_(host) { |
| 19 PepperInstanceStateAccessor* state) | |
| 20 : render_view_(render_view), | |
| 21 permissions_(permissions), | |
| 22 instance_state_(state) { | |
| 23 } | 20 } |
| 24 | 21 |
| 25 ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() { | 22 ContentRendererPepperHostFactory::~ContentRendererPepperHostFactory() { |
| 26 } | 23 } |
| 27 | 24 |
| 28 scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( | 25 scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost( |
| 29 ppapi::host::PpapiHost* host, | 26 ppapi::host::PpapiHost* host, |
| 30 const ppapi::proxy::ResourceMessageCallParams& params, | 27 const ppapi::proxy::ResourceMessageCallParams& params, |
| 31 PP_Instance instance, | 28 PP_Instance instance, |
| 32 const IPC::Message& message) { | 29 const IPC::Message& message) { |
| 30 DCHECK(host == host_->GetPpapiHost()); |
| 31 |
| 33 // Make sure the plugin is giving us a valid instance for this resource. | 32 // Make sure the plugin is giving us a valid instance for this resource. |
| 34 if (!instance_state_->IsValidInstance(instance)) | 33 if (!host_->IsValidInstance(instance)) |
| 35 return scoped_ptr<ResourceHost>(); | 34 return scoped_ptr<ResourceHost>(); |
| 36 | 35 |
| 37 // Resources for dev interfaces. | 36 // Resources for dev interfaces. |
| 38 // TODO(brettw) when we support any public or private interfaces, put them in | 37 // TODO(brettw) when we support any public or private interfaces, put them in |
| 39 // a separate switch above. | 38 // a separate switch above. |
| 40 if (permissions_.HasPermission(ppapi::PERMISSION_DEV)) { | 39 if (GetPermissions().HasPermission(ppapi::PERMISSION_DEV)) { |
| 41 switch (message.type()) { | 40 switch (message.type()) { |
| 42 case PpapiHostMsg_FileChooser_Create::ID: | 41 case PpapiHostMsg_FileChooser_Create::ID: |
| 43 return scoped_ptr<ResourceHost>(new PepperFileChooserHost( | 42 return scoped_ptr<ResourceHost>(new PepperFileChooserHost( |
| 44 host, instance, params.pp_resource(), render_view_, | 43 host_, instance, params.pp_resource())); |
| 45 instance_state_)); | |
| 46 } | 44 } |
| 47 } | 45 } |
| 48 return scoped_ptr<ResourceHost>(); | 46 return scoped_ptr<ResourceHost>(); |
| 49 } | 47 } |
| 50 | 48 |
| 49 const ppapi::PpapiPermissions& |
| 50 ContentRendererPepperHostFactory::GetPermissions() const { |
| 51 return host_->GetPpapiHost()->permissions(); |
| 52 } |
| 53 |
| 51 } // namespace content | 54 } // namespace content |
| OLD | NEW |