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

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

Issue 23530029: Support webview tag when the container extension is embedded in a webUI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 7 years, 2 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 | Annotate | Revision Log
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"
11 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/common/browser_plugin/browser_plugin_constants.h" 12 #include "content/common/browser_plugin/browser_plugin_constants.h"
13 #include "content/common/browser_plugin/browser_plugin_messages.h" 13 #include "content/common/browser_plugin/browser_plugin_messages.h"
14 #include "content/common/drag_messages.h" 14 #include "content/common/drag_messages.h"
15 #include "content/common/gpu/gpu_messages.h" 15 #include "content/common/gpu/gpu_messages.h"
16 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/content_browser_client.h" 17 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/browser/native_web_keyboard_event.h" 18 #include "content/public/browser/native_web_keyboard_event.h"
19 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/user_metrics.h" 20 #include "content/public/browser/user_metrics.h"
20 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
21 #include "content/public/common/result_codes.h" 22 #include "content/public/common/result_codes.h"
22 #include "content/public/common/url_constants.h" 23 #include "content/public/common/url_constants.h"
23 #include "net/base/escape.h" 24 #include "net/base/escape.h"
24 25
25 namespace content { 26 namespace content {
26 27
27 // static 28 // static
28 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; 29 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 const BrowserPluginHostMsg_Attach_Params& params, 171 const BrowserPluginHostMsg_Attach_Params& params,
171 const base::DictionaryValue& extra_params) { 172 const base::DictionaryValue& extra_params) {
172 if (!GetBrowserPluginGuestManager()->CanEmbedderAccessInstanceIDMaybeKill( 173 if (!GetBrowserPluginGuestManager()->CanEmbedderAccessInstanceIDMaybeKill(
173 web_contents()->GetRenderProcessHost()->GetID(), instance_id)) 174 web_contents()->GetRenderProcessHost()->GetID(), instance_id))
174 return; 175 return;
175 176
176 BrowserPluginGuest* guest = 177 BrowserPluginGuest* guest =
177 GetBrowserPluginGuestManager()->GetGuestByInstanceID( 178 GetBrowserPluginGuestManager()->GetGuestByInstanceID(
178 instance_id, web_contents()->GetRenderProcessHost()->GetID()); 179 instance_id, web_contents()->GetRenderProcessHost()->GetID());
179 180
181 RenderProcessHost* render_process_host =
182 web_contents()->GetRenderProcessHost();
183 GURL validated_frame_url(params.embedder_frame_url);
184 RenderViewHost::FilterURL(render_process_host, false, &validated_frame_url);
180 185
181 if (guest) { 186 if (guest) {
182 // There is an implicit order expectation here: 187 // There is an implicit order expectation here:
183 // 1. The content embedder is made aware of the attachment. 188 // 1. The content embedder is made aware of the attachment.
184 // 2. BrowserPluginGuest::Attach is called. 189 // 2. BrowserPluginGuest::Attach is called.
185 // 3. The content embedder issues queued events if any that happened 190 // 3. The content embedder issues queued events if any that happened
186 // prior to attachment. 191 // prior to attachment.
187 GetContentClient()->browser()->GuestWebContentsAttached( 192 GetContentClient()->browser()->GuestWebContentsAttached(
188 guest->GetWebContents(), 193 guest->GetWebContents(),
189 web_contents(), 194 web_contents(),
195 validated_frame_url,
190 extra_params); 196 extra_params);
191 guest->Attach( 197 guest->Attach(
192 static_cast<WebContentsImpl*>(web_contents()), params, extra_params); 198 static_cast<WebContentsImpl*>(web_contents()), params, extra_params);
193 return; 199 return;
194 } 200 }
195 201
196 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy()); 202 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params.DeepCopy());
197 guest = GetBrowserPluginGuestManager()->CreateGuest( 203 guest = GetBrowserPluginGuestManager()->CreateGuest(
198 web_contents()->GetSiteInstance(), 204 web_contents()->GetSiteInstance(),
199 instance_id, params, 205 instance_id, params,
200 copy_extra_params.Pass()); 206 copy_extra_params.Pass());
201 if (guest) { 207 if (guest) {
202 GetContentClient()->browser()->GuestWebContentsAttached( 208 GetContentClient()->browser()->GuestWebContentsAttached(
203 guest->GetWebContents(), 209 guest->GetWebContents(),
204 web_contents(), 210 web_contents(),
211 validated_frame_url,
205 extra_params); 212 extra_params);
206 guest->Initialize(static_cast<WebContentsImpl*>(web_contents()), params); 213 guest->Initialize(static_cast<WebContentsImpl*>(web_contents()), params);
207 } 214 }
208 } 215 }
209 216
210 void BrowserPluginEmbedder::OnPluginAtPositionResponse( 217 void BrowserPluginEmbedder::OnPluginAtPositionResponse(
211 int instance_id, int request_id, const gfx::Point& position) { 218 int instance_id, int request_id, const gfx::Point& position) {
212 const std::map<int, WebContents::GetRenderViewHostCallback>::iterator 219 const std::map<int, WebContents::GetRenderViewHostCallback>::iterator
213 callback_iter = pending_get_render_view_callbacks_.find(request_id); 220 callback_iter = pending_get_render_view_callbacks_.find(request_id);
214 if (callback_iter == pending_get_render_view_callbacks_.end()) 221 if (callback_iter == pending_get_render_view_callbacks_.end())
215 return; 222 return;
216 223
217 RenderViewHost* render_view_host; 224 RenderViewHost* render_view_host;
218 BrowserPluginGuest* guest = NULL; 225 BrowserPluginGuest* guest = NULL;
219 if (instance_id != browser_plugin::kInstanceIDNone) { 226 if (instance_id != browser_plugin::kInstanceIDNone) {
220 guest = GetBrowserPluginGuestManager()->GetGuestByInstanceID( 227 guest = GetBrowserPluginGuestManager()->GetGuestByInstanceID(
221 instance_id, web_contents()->GetRenderProcessHost()->GetID()); 228 instance_id, web_contents()->GetRenderProcessHost()->GetID());
222 } 229 }
223 230
224 if (guest) 231 if (guest)
225 render_view_host = guest->GetWebContents()->GetRenderViewHost(); 232 render_view_host = guest->GetWebContents()->GetRenderViewHost();
226 else // No plugin, use embedder's RenderViewHost. 233 else // No plugin, use embedder's RenderViewHost.
227 render_view_host = web_contents()->GetRenderViewHost(); 234 render_view_host = web_contents()->GetRenderViewHost();
228 235
229 callback_iter->second.Run(render_view_host, position.x(), position.y()); 236 callback_iter->second.Run(render_view_host, position.x(), position.y());
230 pending_get_render_view_callbacks_.erase(callback_iter); 237 pending_get_render_view_callbacks_.erase(callback_iter);
231 } 238 }
232 239
233 } // namespace content 240 } // namespace content
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/document_custom_bindings.cc ('k') | content/browser/browser_plugin/browser_plugin_guest_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698