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/browser/browser_plugin/browser_plugin_embedder.h" | 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 8 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
9 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h" |
10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 const BrowserPluginHostMsg_Attach_Params& params, | 171 const BrowserPluginHostMsg_Attach_Params& params, |
172 const base::DictionaryValue& extra_params) { | 172 const base::DictionaryValue& extra_params) { |
173 if (!GetBrowserPluginGuestManager()->CanEmbedderAccessInstanceIDMaybeKill( | 173 if (!GetBrowserPluginGuestManager()->CanEmbedderAccessInstanceIDMaybeKill( |
174 web_contents()->GetRenderProcessHost()->GetID(), instance_id)) | 174 web_contents()->GetRenderProcessHost()->GetID(), instance_id)) |
175 return; | 175 return; |
176 | 176 |
177 BrowserPluginGuest* guest = | 177 BrowserPluginGuest* guest = |
178 GetBrowserPluginGuestManager()->GetGuestByInstanceID( | 178 GetBrowserPluginGuestManager()->GetGuestByInstanceID( |
179 instance_id, web_contents()->GetRenderProcessHost()->GetID()); | 179 instance_id, web_contents()->GetRenderProcessHost()->GetID()); |
180 | 180 |
181 RenderProcessHost* render_process_host = | |
182 web_contents()->GetRenderProcessHost(); | |
183 GURL validated_frame_url(params.embedder_frame_url); | |
Charlie Reis
2013/10/30 20:42:20
Are we using embedder_frame_url somewhere else?
Fady Samuel
2013/10/31 17:25:17
See BrowserPluginGuestManager::CreateGuest. The gu
| |
184 RenderViewHost::FilterURL(render_process_host, false, &validated_frame_url); | |
185 | |
186 if (guest) { | 181 if (guest) { |
187 // There is an implicit order expectation here: | 182 // There is an implicit order expectation here: |
188 // 1. The content embedder is made aware of the attachment. | 183 // 1. The content embedder is made aware of the attachment. |
189 // 2. BrowserPluginGuest::Attach is called. | 184 // 2. BrowserPluginGuest::Attach is called. |
190 // 3. The content embedder issues queued events if any that happened | 185 // 3. The content embedder issues queued events if any that happened |
191 // prior to attachment. | 186 // prior to attachment. |
192 GetContentClient()->browser()->GuestWebContentsAttached( | 187 GetContentClient()->browser()->GuestWebContentsAttached( |
193 guest->GetWebContents(), | 188 guest->GetWebContents(), |
194 web_contents(), | 189 web_contents(), |
195 validated_frame_url, | |
196 extra_params); | 190 extra_params); |
197 guest->Attach( | 191 guest->Attach( |
198 static_cast<WebContentsImpl*>(web_contents()), params, extra_params); | 192 static_cast<WebContentsImpl*>(web_contents()), params, extra_params); |
199 return; | 193 return; |
200 } | 194 } |
201 | 195 |
202 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy()); | 196 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy()); |
203 guest = GetBrowserPluginGuestManager()->CreateGuest( | 197 guest = GetBrowserPluginGuestManager()->CreateGuest( |
204 web_contents()->GetSiteInstance(), | 198 web_contents()->GetSiteInstance(), |
205 instance_id, params, | 199 instance_id, params, |
206 copy_extra_params.Pass()); | 200 copy_extra_params.Pass()); |
207 if (guest) { | 201 if (guest) { |
208 GetContentClient()->browser()->GuestWebContentsAttached( | 202 GetContentClient()->browser()->GuestWebContentsAttached( |
209 guest->GetWebContents(), | 203 guest->GetWebContents(), |
210 web_contents(), | 204 web_contents(), |
211 validated_frame_url, | |
212 extra_params); | 205 extra_params); |
213 guest->Initialize(static_cast<WebContentsImpl*>(web_contents()), params); | 206 guest->Initialize(static_cast<WebContentsImpl*>(web_contents()), params); |
214 } | 207 } |
215 } | 208 } |
216 | 209 |
217 void BrowserPluginEmbedder::OnPluginAtPositionResponse( | 210 void BrowserPluginEmbedder::OnPluginAtPositionResponse( |
218 int instance_id, int request_id, const gfx::Point& position) { | 211 int instance_id, int request_id, const gfx::Point& position) { |
219 const std::map<int, WebContents::GetRenderViewHostCallback>::iterator | 212 const std::map<int, WebContents::GetRenderViewHostCallback>::iterator |
220 callback_iter = pending_get_render_view_callbacks_.find(request_id); | 213 callback_iter = pending_get_render_view_callbacks_.find(request_id); |
221 if (callback_iter == pending_get_render_view_callbacks_.end()) | 214 if (callback_iter == pending_get_render_view_callbacks_.end()) |
222 return; | 215 return; |
223 | 216 |
224 RenderViewHost* render_view_host; | 217 RenderViewHost* render_view_host; |
225 BrowserPluginGuest* guest = NULL; | 218 BrowserPluginGuest* guest = NULL; |
226 if (instance_id != browser_plugin::kInstanceIDNone) { | 219 if (instance_id != browser_plugin::kInstanceIDNone) { |
227 guest = GetBrowserPluginGuestManager()->GetGuestByInstanceID( | 220 guest = GetBrowserPluginGuestManager()->GetGuestByInstanceID( |
228 instance_id, web_contents()->GetRenderProcessHost()->GetID()); | 221 instance_id, web_contents()->GetRenderProcessHost()->GetID()); |
229 } | 222 } |
230 | 223 |
231 if (guest) | 224 if (guest) |
232 render_view_host = guest->GetWebContents()->GetRenderViewHost(); | 225 render_view_host = guest->GetWebContents()->GetRenderViewHost(); |
233 else // No plugin, use embedder's RenderViewHost. | 226 else // No plugin, use embedder's RenderViewHost. |
234 render_view_host = web_contents()->GetRenderViewHost(); | 227 render_view_host = web_contents()->GetRenderViewHost(); |
235 | 228 |
236 callback_iter->second.Run(render_view_host, position.x(), position.y()); | 229 callback_iter->second.Run(render_view_host, position.x(), position.y()); |
237 pending_get_render_view_callbacks_.erase(callback_iter); | 230 pending_get_render_view_callbacks_.erase(callback_iter); |
238 } | 231 } |
239 | 232 |
240 } // namespace content | 233 } // namespace content |
OLD | NEW |