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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { | 159 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { |
160 *handled = (guest_dragging_over_.get() != NULL); | 160 *handled = (guest_dragging_over_.get() != NULL); |
161 } | 161 } |
162 | 162 |
163 void BrowserPluginEmbedder::OnAllocateInstanceID(int request_id) { | 163 void BrowserPluginEmbedder::OnAllocateInstanceID(int request_id) { |
164 int instance_id = GetBrowserPluginGuestManager()->GetNextInstanceID(); | 164 int instance_id = GetBrowserPluginGuestManager()->GetNextInstanceID(); |
165 Send(new BrowserPluginMsg_AllocateInstanceID_ACK( | 165 Send(new BrowserPluginMsg_AllocateInstanceID_ACK( |
166 routing_id(), request_id, instance_id)); | 166 routing_id(), request_id, instance_id)); |
167 } | 167 } |
168 | 168 |
169 void BrowserPluginEmbedder::OnAttach( | 169 void BrowserPluginEmbedder::GuestCallback( |
170 int instance_id, | 170 int instance_id, |
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 BrowserPluginGuest* guest) { |
173 BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager(); | 174 BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager(); |
174 if (!guest_manager->CanEmbedderAccessInstanceIDMaybeKill( | |
175 GetWebContents()->GetRenderProcessHost()->GetID(), instance_id)) | |
176 return; | |
177 | |
178 BrowserPluginGuest* guest = | |
179 guest_manager->GetGuestByInstanceID( | |
180 instance_id, GetWebContents()->GetRenderProcessHost()->GetID()); | |
181 | |
182 if (guest) { | 175 if (guest) { |
183 // There is an implicit order expectation here: | 176 // There is an implicit order expectation here: |
184 // 1. The content embedder is made aware of the attachment. | 177 // 1. The content embedder is made aware of the attachment. |
185 // 2. BrowserPluginGuest::Attach is called. | 178 // 2. BrowserPluginGuest::Attach is called. |
186 // 3. The content embedder issues queued events if any that happened | 179 // 3. The content embedder issues queued events if any that happened |
187 // prior to attachment. | 180 // prior to attachment. |
188 GetContentClient()->browser()->GuestWebContentsAttached( | 181 GetContentClient()->browser()->GuestWebContentsAttached( |
189 guest->GetWebContents(), | 182 guest->GetWebContents(), |
190 GetWebContents(), | 183 GetWebContents(), |
191 extra_params); | 184 *extra_params); |
192 guest->Attach(GetWebContents(), params, extra_params); | 185 guest->Attach(GetWebContents(), params, *extra_params); |
193 return; | 186 return; |
194 } | 187 } |
195 | 188 |
196 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy()); | 189 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params->DeepCopy()); |
197 guest = guest_manager->CreateGuest( | 190 guest = guest_manager->CreateGuest( |
198 GetWebContents()->GetSiteInstance(), | 191 GetWebContents()->GetSiteInstance(), |
199 instance_id, params, | 192 instance_id, params, |
200 copy_extra_params.Pass()); | 193 copy_extra_params.Pass()); |
201 if (guest) { | 194 if (guest) { |
202 GetContentClient()->browser()->GuestWebContentsAttached( | 195 GetContentClient()->browser()->GuestWebContentsAttached( |
203 guest->GetWebContents(), | 196 guest->GetWebContents(), |
204 GetWebContents(), | 197 GetWebContents(), |
205 extra_params); | 198 *extra_params); |
206 guest->Initialize(params, GetWebContents()); | 199 guest->Initialize(params, GetWebContents()); |
207 } | 200 } |
208 } | 201 } |
209 | 202 |
| 203 void BrowserPluginEmbedder::OnAttach( |
| 204 int instance_id, |
| 205 const BrowserPluginHostMsg_Attach_Params& params, |
| 206 const base::DictionaryValue& extra_params) { |
| 207 GetBrowserPluginGuestManager()->MaybeGetGuestByInstanceIDOrKill( |
| 208 instance_id, GetWebContents()->GetRenderProcessHost()->GetID(), |
| 209 base::Bind(&BrowserPluginEmbedder::GuestCallback, |
| 210 base::Unretained(this), |
| 211 instance_id, |
| 212 params, |
| 213 &extra_params)); |
| 214 } |
| 215 |
210 } // namespace content | 216 } // namespace content |
OLD | NEW |