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