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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 if (guest) { | 181 if (guest) { |
182 // There is an implicit order expectation here: | 182 // There is an implicit order expectation here: |
183 // 1. The content embedder is made aware of the attachment. | 183 // 1. The content embedder is made aware of the attachment. |
184 // 2. BrowserPluginGuest::Attach is called. | 184 // 2. BrowserPluginGuest::Attach is called. |
185 // 3. The content embedder issues queued events if any that happened | 185 // 3. The content embedder issues queued events if any that happened |
186 // prior to attachment. | 186 // prior to attachment. |
187 GetContentClient()->browser()->GuestWebContentsAttached( | 187 GetContentClient()->browser()->GuestWebContentsAttached( |
188 guest->GetWebContents(), | 188 guest->GetWebContents(), |
189 web_contents(), | 189 web_contents(), |
190 params.browser_plugin_instance_id, | |
191 extra_params); | 190 extra_params); |
192 guest->Attach(static_cast<WebContentsImpl*>(web_contents()), params); | 191 guest->Attach(static_cast<WebContentsImpl*>(web_contents()), params); |
193 return; | 192 return; |
194 } | 193 } |
195 | 194 |
196 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy()); | 195 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy()); |
197 guest = GetBrowserPluginGuestManager()->CreateGuest( | 196 guest = GetBrowserPluginGuestManager()->CreateGuest( |
198 web_contents()->GetSiteInstance(), | 197 web_contents()->GetSiteInstance(), |
199 instance_id, params, | 198 instance_id, params, |
200 copy_extra_params.Pass()); | 199 copy_extra_params.Pass()); |
201 if (guest) { | 200 if (guest) { |
202 GetContentClient()->browser()->GuestWebContentsAttached( | 201 GetContentClient()->browser()->GuestWebContentsAttached( |
203 guest->GetWebContents(), | 202 guest->GetWebContents(), |
204 web_contents(), | 203 web_contents(), |
205 params.browser_plugin_instance_id, | |
206 extra_params); | 204 extra_params); |
207 guest->Initialize(static_cast<WebContentsImpl*>(web_contents()), params); | 205 guest->Initialize(static_cast<WebContentsImpl*>(web_contents()), params); |
208 } | 206 } |
209 } | 207 } |
210 | 208 |
211 void BrowserPluginEmbedder::OnPluginAtPositionResponse( | 209 void BrowserPluginEmbedder::OnPluginAtPositionResponse( |
212 int instance_id, int request_id, const gfx::Point& position) { | 210 int instance_id, int request_id, const gfx::Point& position) { |
213 const std::map<int, WebContents::GetRenderViewHostCallback>::iterator | 211 const std::map<int, WebContents::GetRenderViewHostCallback>::iterator |
214 callback_iter = pending_get_render_view_callbacks_.find(request_id); | 212 callback_iter = pending_get_render_view_callbacks_.find(request_id); |
215 if (callback_iter == pending_get_render_view_callbacks_.end()) | 213 if (callback_iter == pending_get_render_view_callbacks_.end()) |
216 return; | 214 return; |
217 | 215 |
218 RenderViewHost* render_view_host; | 216 RenderViewHost* render_view_host; |
219 BrowserPluginGuest* guest = NULL; | 217 BrowserPluginGuest* guest = NULL; |
220 if (instance_id != browser_plugin::kInstanceIDNone) { | 218 if (instance_id != browser_plugin::kInstanceIDNone) { |
221 guest = GetBrowserPluginGuestManager()->GetGuestByInstanceID( | 219 guest = GetBrowserPluginGuestManager()->GetGuestByInstanceID( |
222 instance_id, web_contents()->GetRenderProcessHost()->GetID()); | 220 instance_id, web_contents()->GetRenderProcessHost()->GetID()); |
223 } | 221 } |
224 | 222 |
225 if (guest) | 223 if (guest) |
226 render_view_host = guest->GetWebContents()->GetRenderViewHost(); | 224 render_view_host = guest->GetWebContents()->GetRenderViewHost(); |
227 else // No plugin, use embedder's RenderViewHost. | 225 else // No plugin, use embedder's RenderViewHost. |
228 render_view_host = web_contents()->GetRenderViewHost(); | 226 render_view_host = web_contents()->GetRenderViewHost(); |
229 | 227 |
230 callback_iter->second.Run(render_view_host, position.x(), position.y()); | 228 callback_iter->second.Run(render_view_host, position.x(), position.y()); |
231 pending_get_render_view_callbacks_.erase(callback_iter); | 229 pending_get_render_view_callbacks_.erase(callback_iter); |
232 } | 230 } |
233 | 231 |
234 } // namespace content | 232 } // namespace content |
OLD | NEW |