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_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // Navigation is disabled in Chrome Apps. We want to make sure guest-initiated | 231 // Navigation is disabled in Chrome Apps. We want to make sure guest-initiated |
232 // navigations still continue to function inside the app. | 232 // navigations still continue to function inside the app. |
233 renderer_prefs->browser_handles_all_top_level_requests = false; | 233 renderer_prefs->browser_handles_all_top_level_requests = false; |
234 // Disable "client blocked" error page for browser plugin. | 234 // Disable "client blocked" error page for browser plugin. |
235 renderer_prefs->disable_client_blocked_error_page = true; | 235 renderer_prefs->disable_client_blocked_error_page = true; |
236 | 236 |
237 embedder_web_contents_observer_.reset(new EmbedderWebContentsObserver(this)); | 237 embedder_web_contents_observer_.reset(new EmbedderWebContentsObserver(this)); |
238 | 238 |
239 OnResizeGuest(browser_plugin_instance_id_, params.resize_guest_params); | 239 OnResizeGuest(browser_plugin_instance_id_, params.resize_guest_params); |
240 | 240 |
241 // Create a swapped out RenderView for the guest in the embedder render | |
242 // process, so that the embedder can access the guest's window object. | |
243 int guest_routing_id = | |
244 GetWebContents()->CreateSwappedOutRenderView( | |
245 embedder_web_contents_->GetSiteInstance()); | |
246 | |
247 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will | 241 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will |
248 // be reset again the next time preferences are updated. | 242 // be reset again the next time preferences are updated. |
249 WebPreferences prefs = | 243 WebPreferences prefs = |
250 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences(); | 244 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences(); |
251 prefs.navigate_on_drag_drop = false; | 245 prefs.navigate_on_drag_drop = false; |
252 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); | 246 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); |
253 | 247 |
254 // Enable input method for guest if it's enabled for the embedder. | 248 // Enable input method for guest if it's enabled for the embedder. |
255 if (static_cast<RenderViewHostImpl*>( | 249 if (static_cast<RenderViewHostImpl*>( |
256 embedder_web_contents_->GetRenderViewHost())->input_method_active()) { | 250 embedder_web_contents_->GetRenderViewHost())->input_method_active()) { |
257 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 251 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
258 GetWebContents()->GetRenderViewHost()); | 252 GetWebContents()->GetRenderViewHost()); |
259 guest_rvh->SetInputMethodActive(true); | 253 guest_rvh->SetInputMethodActive(true); |
260 } | 254 } |
261 | 255 |
262 // Inform the embedder of the guest's attachment. | 256 // Inform the embedder of the guest's attachment. |
263 SendMessageToEmbedder( | 257 SendMessageToEmbedder( |
264 new BrowserPluginMsg_Attach_ACK(browser_plugin_instance_id_)); | 258 new BrowserPluginMsg_Attach_ACK(browser_plugin_instance_id_)); |
265 | |
266 SendMessageToEmbedder(new BrowserPluginMsg_GuestContentWindowReady( | |
267 browser_plugin_instance_id_, guest_routing_id)); | |
268 } | 259 } |
269 | 260 |
270 BrowserPluginGuest::~BrowserPluginGuest() { | 261 BrowserPluginGuest::~BrowserPluginGuest() { |
271 } | 262 } |
272 | 263 |
273 // static | 264 // static |
274 BrowserPluginGuest* BrowserPluginGuest::Create( | 265 BrowserPluginGuest* BrowserPluginGuest::Create( |
275 WebContentsImpl* web_contents, | 266 WebContentsImpl* web_contents, |
276 BrowserPluginGuestDelegate* delegate) { | 267 BrowserPluginGuestDelegate* delegate) { |
277 return new BrowserPluginGuest( | 268 return new BrowserPluginGuest( |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 #endif | 542 #endif |
552 } | 543 } |
553 | 544 |
554 void BrowserPluginGuest::Attach( | 545 void BrowserPluginGuest::Attach( |
555 int browser_plugin_instance_id, | 546 int browser_plugin_instance_id, |
556 WebContentsImpl* embedder_web_contents, | 547 WebContentsImpl* embedder_web_contents, |
557 const BrowserPluginHostMsg_Attach_Params& params) { | 548 const BrowserPluginHostMsg_Attach_Params& params) { |
558 if (attached()) | 549 if (attached()) |
559 return; | 550 return; |
560 | 551 |
561 delegate_->WillAttach(embedder_web_contents); | 552 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id); |
562 | 553 |
563 // If a RenderView has already been created for this new window, then we need | 554 // If a RenderView has already been created for this new window, then we need |
564 // to initialize the browser-side state now so that the RenderFrameHostManager | 555 // to initialize the browser-side state now so that the RenderFrameHostManager |
565 // does not create a new RenderView on navigation. | 556 // does not create a new RenderView on navigation. |
566 if (has_render_view_) { | 557 if (has_render_view_) { |
567 static_cast<RenderViewHostImpl*>( | 558 static_cast<RenderViewHostImpl*>( |
568 GetWebContents()->GetRenderViewHost())->Init(); | 559 GetWebContents()->GetRenderViewHost())->Init(); |
569 WebContentsViewGuest* new_view = | 560 WebContentsViewGuest* new_view = |
570 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 561 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
571 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); | 562 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); |
572 } | 563 } |
573 | 564 |
574 Initialize(browser_plugin_instance_id, params, embedder_web_contents); | 565 Initialize(browser_plugin_instance_id, params, embedder_web_contents); |
575 | 566 |
576 SendQueuedMessages(); | 567 SendQueuedMessages(); |
577 | 568 |
578 delegate_->DidAttach(); | 569 // Create a swapped out RenderView for the guest in the embedder render |
| 570 // process, so that the embedder can access the guest's window object. |
| 571 int guest_routing_id = |
| 572 GetWebContents()->CreateSwappedOutRenderView( |
| 573 embedder_web_contents_->GetSiteInstance()); |
| 574 |
| 575 delegate_->DidAttach(guest_routing_id); |
579 | 576 |
580 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); | 577 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); |
581 } | 578 } |
582 | 579 |
583 void BrowserPluginGuest::OnCompositorFrameSwappedACK( | 580 void BrowserPluginGuest::OnCompositorFrameSwappedACK( |
584 int browser_plugin_instance_id, | 581 int browser_plugin_instance_id, |
585 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { | 582 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { |
586 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, | 583 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, |
587 params.output_surface_id, | 584 params.output_surface_id, |
588 params.producing_host_id, | 585 params.producing_host_id, |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 836 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
840 const gfx::Range& range, | 837 const gfx::Range& range, |
841 const std::vector<gfx::Rect>& character_bounds) { | 838 const std::vector<gfx::Rect>& character_bounds) { |
842 static_cast<RenderWidgetHostViewBase*>( | 839 static_cast<RenderWidgetHostViewBase*>( |
843 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 840 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
844 range, character_bounds); | 841 range, character_bounds); |
845 } | 842 } |
846 #endif | 843 #endif |
847 | 844 |
848 } // namespace content | 845 } // namespace content |
OLD | NEW |