Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_embedder.cc

Issue 264943006: BrowserPlugin: Simplify content/public API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_v1
Patch Set: Fixed nit Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 bool BrowserPluginEmbedder::DidSendScreenRectsCallback( 75 bool BrowserPluginEmbedder::DidSendScreenRectsCallback(
76 BrowserPluginGuest* guest) { 76 BrowserPluginGuest* guest) {
77 static_cast<RenderViewHostImpl*>( 77 static_cast<RenderViewHostImpl*>(
78 guest->GetWebContents()->GetRenderViewHost())->SendScreenRects(); 78 guest->GetWebContents()->GetRenderViewHost())->SendScreenRects();
79 // Not handled => Iterate over all guests. 79 // Not handled => Iterate over all guests.
80 return false; 80 return false;
81 } 81 }
82 82
83 void BrowserPluginEmbedder::DidSendScreenRects() { 83 void BrowserPluginEmbedder::DidSendScreenRects() {
84 GetBrowserPluginGuestManager()->ForEachGuest(GetWebContents(), base::Bind( 84 BrowserPluginGuestManager::FromBrowserContext(
85 &BrowserPluginEmbedder::DidSendScreenRectsCallback, 85 GetWebContents()->GetBrowserContext())->ForEachGuest(
86 base::Unretained(this))); 86 GetWebContents(), base::Bind(
87 &BrowserPluginEmbedder::DidSendScreenRectsCallback,
88 base::Unretained(this)));
87 } 89 }
88 90
89 bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback( 91 bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(
90 const NativeWebKeyboardEvent& event, 92 const NativeWebKeyboardEvent& event,
91 BrowserPluginGuest* guest) { 93 BrowserPluginGuest* guest) {
92 return guest->UnlockMouseIfNecessary(event); 94 return guest->UnlockMouseIfNecessary(event);
93 } 95 }
94 96
95 bool BrowserPluginEmbedder::HandleKeyboardEvent( 97 bool BrowserPluginEmbedder::HandleKeyboardEvent(
96 const NativeWebKeyboardEvent& event) { 98 const NativeWebKeyboardEvent& event) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { 161 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) {
160 *handled = (guest_dragging_over_.get() != NULL); 162 *handled = (guest_dragging_over_.get() != NULL);
161 } 163 }
162 164
163 void BrowserPluginEmbedder::OnAllocateInstanceID(int request_id) { 165 void BrowserPluginEmbedder::OnAllocateInstanceID(int request_id) {
164 int instance_id = GetBrowserPluginGuestManager()->GetNextInstanceID(); 166 int instance_id = GetBrowserPluginGuestManager()->GetNextInstanceID();
165 Send(new BrowserPluginMsg_AllocateInstanceID_ACK( 167 Send(new BrowserPluginMsg_AllocateInstanceID_ACK(
166 routing_id(), request_id, instance_id)); 168 routing_id(), request_id, instance_id));
167 } 169 }
168 170
169 void BrowserPluginEmbedder::OnAttach( 171 void BrowserPluginEmbedder::OnGuestCallback(
170 int instance_id, 172 int instance_id,
171 const BrowserPluginHostMsg_Attach_Params& params, 173 const BrowserPluginHostMsg_Attach_Params& params,
172 const base::DictionaryValue& extra_params) { 174 const base::DictionaryValue* extra_params,
175 BrowserPluginGuest* guest) {
173 BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager(); 176 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) { 177 if (guest) {
183 // There is an implicit order expectation here: 178 // There is an implicit order expectation here:
184 // 1. The content embedder is made aware of the attachment. 179 // 1. The content embedder is made aware of the attachment.
185 // 2. BrowserPluginGuest::Attach is called. 180 // 2. BrowserPluginGuest::Attach is called.
186 // 3. The content embedder issues queued events if any that happened 181 // 3. The content embedder issues queued events if any that happened
187 // prior to attachment. 182 // prior to attachment.
188 GetContentClient()->browser()->GuestWebContentsAttached( 183 GetContentClient()->browser()->GuestWebContentsAttached(
189 guest->GetWebContents(), 184 guest->GetWebContents(),
190 GetWebContents(), 185 GetWebContents(),
191 extra_params); 186 *extra_params);
192 guest->Attach(GetWebContents(), params, extra_params); 187 guest->Attach(GetWebContents(), params, *extra_params);
193 return; 188 return;
194 } 189 }
195 190
196 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy()); 191 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params->DeepCopy());
197 guest = guest_manager->CreateGuest( 192 guest = guest_manager->CreateGuest(
198 GetWebContents()->GetSiteInstance(), 193 GetWebContents()->GetSiteInstance(),
199 instance_id, params, 194 instance_id, params,
200 copy_extra_params.Pass()); 195 copy_extra_params.Pass());
201 if (guest) { 196 if (guest) {
202 GetContentClient()->browser()->GuestWebContentsAttached( 197 GetContentClient()->browser()->GuestWebContentsAttached(
203 guest->GetWebContents(), 198 guest->GetWebContents(),
204 GetWebContents(), 199 GetWebContents(),
205 extra_params); 200 *extra_params);
206 guest->Initialize(params, GetWebContents()); 201 guest->Initialize(params, GetWebContents());
207 } 202 }
208 } 203 }
209 204
205 void BrowserPluginEmbedder::OnAttach(
206 int instance_id,
207 const BrowserPluginHostMsg_Attach_Params& params,
208 const base::DictionaryValue& extra_params) {
209 GetBrowserPluginGuestManager()->MaybeGetGuestByInstanceIDOrKill(
210 instance_id, GetWebContents()->GetRenderProcessHost()->GetID(),
211 base::Bind(&BrowserPluginEmbedder::OnGuestCallback,
212 base::Unretained(this),
213 instance_id,
214 params,
215 &extra_params));
216 }
217
210 } // namespace content 218 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698