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/pepper_in_process_resource_creation.h" | 5 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" | 10 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h" |
| 11 #include "content/renderer/render_view_impl.h" |
11 #include "ipc/ipc_message.h" | 12 #include "ipc/ipc_message.h" |
12 #include "ipc/ipc_message_macros.h" | 13 #include "ipc/ipc_message_macros.h" |
13 #include "ppapi/host/ppapi_host.h" | 14 #include "ppapi/host/ppapi_host.h" |
14 #include "ppapi/proxy/file_chooser_resource.h" | 15 #include "ppapi/proxy/file_chooser_resource.h" |
15 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
16 #include "ppapi/shared_impl/ppapi_globals.h" | 17 #include "ppapi/shared_impl/ppapi_globals.h" |
17 #include "ppapi/shared_impl/ppapi_permissions.h" | 18 #include "ppapi/shared_impl/ppapi_permissions.h" |
18 #include "ppapi/shared_impl/resource_tracker.h" | 19 #include "ppapi/shared_impl/resource_tracker.h" |
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
20 | 21 |
21 // Note that the code in the creation functions in this file should generally | 22 // Note that the code in the creation functions in this file should generally |
22 // be the same as that in ppapi/proxy/resource_creation_proxy.cc. See | 23 // be the same as that in ppapi/proxy/resource_creation_proxy.cc. See |
23 // pepper_in_process_resource_creation.h for what this file is for. | 24 // pepper_in_process_resource_creation.h for what this file is for. |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 | 27 |
27 class PepperInProcessResourceCreation::PluginToHostRouter | 28 class PepperInProcessResourceCreation::PluginToHostRouter |
28 : public IPC::Sender { | 29 : public IPC::Sender { |
29 public: | 30 public: |
30 PluginToHostRouter(RenderViewImpl* render_view, | 31 PluginToHostRouter(RenderViewImpl* render_view, |
31 PepperInstanceStateAccessor* state, | 32 PepperInstanceStateAccessor* state, |
32 IPC::Sender* host_to_plugin_sender, | 33 IPC::Sender* host_to_plugin_sender, |
33 const ppapi::PpapiPermissions& perms); | 34 const ppapi::PpapiPermissions& perms); |
34 virtual ~PluginToHostRouter() {} | 35 virtual ~PluginToHostRouter() {} |
35 | 36 |
| 37 ppapi::host::PpapiHost& host() { return host_; } |
| 38 |
36 // Sender implementation. | 39 // Sender implementation. |
37 virtual bool Send(IPC::Message* msg) OVERRIDE; | 40 virtual bool Send(IPC::Message* msg) OVERRIDE; |
38 | 41 |
39 private: | 42 private: |
40 void DoSend(IPC::Message* msg); | 43 void DoSend(IPC::Message* msg); |
41 | 44 |
42 base::WeakPtrFactory<PluginToHostRouter> weak_factory_; | 45 base::WeakPtrFactory<PluginToHostRouter> weak_factory_; |
43 | 46 |
44 ContentRendererPepperHostFactory factory_; | 47 ContentRendererPepperHostFactory factory_; |
45 ppapi::host::PpapiHost host_; | 48 ppapi::host::PpapiHost host_; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 RenderViewImpl* render_view, | 142 RenderViewImpl* render_view, |
140 webkit::ppapi::PluginInstance* instance, | 143 webkit::ppapi::PluginInstance* instance, |
141 const ppapi::PpapiPermissions& perms) | 144 const ppapi::PpapiPermissions& perms) |
142 : ResourceCreationImpl(instance), | 145 : ResourceCreationImpl(instance), |
143 instance_state_(instance->module()), | 146 instance_state_(instance->module()), |
144 host_to_plugin_router_(new HostToPluginRouter), | 147 host_to_plugin_router_(new HostToPluginRouter), |
145 plugin_to_host_router_( | 148 plugin_to_host_router_( |
146 new PluginToHostRouter(render_view, &instance_state_, | 149 new PluginToHostRouter(render_view, &instance_state_, |
147 host_to_plugin_router_.get(), | 150 host_to_plugin_router_.get(), |
148 perms)) { | 151 perms)) { |
| 152 render_view->PpapiPluginCreated(&plugin_to_host_router_->host()); |
149 } | 153 } |
150 | 154 |
151 PepperInProcessResourceCreation::~PepperInProcessResourceCreation() { | 155 PepperInProcessResourceCreation::~PepperInProcessResourceCreation() { |
152 } | 156 } |
153 | 157 |
154 PP_Resource PepperInProcessResourceCreation::CreateFileChooser( | 158 PP_Resource PepperInProcessResourceCreation::CreateFileChooser( |
155 PP_Instance instance, | 159 PP_Instance instance, |
156 PP_FileChooserMode_Dev mode, | 160 PP_FileChooserMode_Dev mode, |
157 const char* accept_types) { | 161 const char* accept_types) { |
158 return (new ppapi::proxy::FileChooserResource( | 162 return (new ppapi::proxy::FileChooserResource( |
159 plugin_to_host_router_.get(), | 163 plugin_to_host_router_.get(), |
160 instance, mode, accept_types))->GetReference(); | 164 instance, mode, accept_types))->GetReference(); |
161 } | 165 } |
162 | 166 |
163 } // namespace content | 167 } // namespace content |
OLD | NEW |