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/renderer_ppapi_host_impl.h" | 5 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetPluginInstanceImpl( | 126 PepperPluginInstanceImpl* RendererPpapiHostImpl::GetPluginInstanceImpl( |
127 PP_Instance instance) const { | 127 PP_Instance instance) const { |
128 return GetAndValidateInstance(instance); | 128 return GetAndValidateInstance(instance); |
129 } | 129 } |
130 | 130 |
131 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { | 131 ppapi::host::PpapiHost* RendererPpapiHostImpl::GetPpapiHost() { |
132 return ppapi_host_.get(); | 132 return ppapi_host_.get(); |
133 } | 133 } |
134 | 134 |
| 135 RenderFrame* RendererPpapiHostImpl::GetRenderFrameForInstance( |
| 136 PP_Instance instance) const { |
| 137 PepperPluginInstanceImpl* instance_object = GetAndValidateInstance(instance); |
| 138 if (!instance_object) |
| 139 return NULL; |
| 140 |
| 141 // Since we're the embedder, we can make assumptions about the helper on |
| 142 // the instance and get back to our RenderFrame. |
| 143 return instance_object->render_frame(); |
| 144 } |
| 145 |
135 RenderView* RendererPpapiHostImpl::GetRenderViewForInstance( | 146 RenderView* RendererPpapiHostImpl::GetRenderViewForInstance( |
136 PP_Instance instance) const { | 147 PP_Instance instance) const { |
137 PepperPluginInstanceImpl* instance_object = GetAndValidateInstance(instance); | 148 PepperPluginInstanceImpl* instance_object = GetAndValidateInstance(instance); |
138 if (!instance_object) | 149 if (!instance_object) |
139 return NULL; | 150 return NULL; |
140 | 151 |
141 // Since we're the embedder, we can make assumptions about the helper on | 152 // Since we're the embedder, we can make assumptions about the helper on |
142 // the instance and get back to our RenderView. | 153 // the instance and get back to our RenderView. |
143 return instance_object->render_frame()->render_view(); | 154 return instance_object->render_frame()->render_view(); |
144 } | 155 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 235 } |
225 | 236 |
226 bool RendererPpapiHostImpl::IsRunningInProcess() const { | 237 bool RendererPpapiHostImpl::IsRunningInProcess() const { |
227 return is_running_in_process_; | 238 return is_running_in_process_; |
228 } | 239 } |
229 | 240 |
230 void RendererPpapiHostImpl::CreateBrowserResourceHosts( | 241 void RendererPpapiHostImpl::CreateBrowserResourceHosts( |
231 PP_Instance instance, | 242 PP_Instance instance, |
232 const std::vector<IPC::Message>& nested_msgs, | 243 const std::vector<IPC::Message>& nested_msgs, |
233 const base::Callback<void(const std::vector<int>&)>& callback) const { | 244 const base::Callback<void(const std::vector<int>&)>& callback) const { |
234 RenderView* render_view = GetRenderViewForInstance(instance); | 245 RenderFrame* render_frame = GetRenderFrameForInstance(instance); |
235 PepperBrowserConnection* browser_connection = | 246 PepperBrowserConnection* browser_connection = |
236 PepperBrowserConnection::Get(render_view); | 247 PepperBrowserConnection::Get(render_frame); |
237 if (!browser_connection) { | 248 if (!browser_connection) { |
238 base::MessageLoop::current()->PostTask(FROM_HERE, | 249 base::MessageLoop::current()->PostTask(FROM_HERE, |
239 base::Bind(callback, std::vector<int>(nested_msgs.size(), 0))); | 250 base::Bind(callback, std::vector<int>(nested_msgs.size(), 0))); |
240 } else { | 251 } else { |
241 browser_connection->SendBrowserCreate(module_->GetPluginChildId(), | 252 browser_connection->SendBrowserCreate(module_->GetPluginChildId(), |
242 instance, | 253 instance, |
243 nested_msgs, | 254 nested_msgs, |
244 callback); | 255 callback); |
245 } | 256 } |
246 } | 257 } |
(...skipping 11 matching lines...) Expand all Loading... |
258 PepperPluginInstanceImpl* instance = | 269 PepperPluginInstanceImpl* instance = |
259 HostGlobals::Get()->GetInstance(pp_instance); | 270 HostGlobals::Get()->GetInstance(pp_instance); |
260 if (!instance) | 271 if (!instance) |
261 return NULL; | 272 return NULL; |
262 if (!instance->IsValidInstanceOf(module_)) | 273 if (!instance->IsValidInstanceOf(module_)) |
263 return NULL; | 274 return NULL; |
264 return instance; | 275 return instance; |
265 } | 276 } |
266 | 277 |
267 } // namespace content | 278 } // namespace content |
OLD | NEW |