Chromium Code Reviews| 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 // Note that all IPC sent out from this class will be dropped on the | |
|
Fady Samuel
2015/03/04 20:44:47
I'd like to better understand what we do and don't
| |
| 6 // floor b/c we don't have a BrowserPlugin anymore. | |
| 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 7 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 6 | 8 |
| 7 #include <algorithm> | 9 #include <algorithm> |
| 8 | 10 |
| 9 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 10 #include "base/pickle.h" | 12 #include "base/pickle.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 12 #include "content/browser/browser_plugin/browser_plugin_embedder.h" | 14 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
| 13 #include "content/browser/browser_thread_impl.h" | 15 #include "content/browser/browser_thread_impl.h" |
| 14 #include "content/browser/child_process_security_policy_impl.h" | 16 #include "content/browser/child_process_security_policy_impl.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 blink::WebFocusTypeNone); | 237 blink::WebFocusTypeNone); |
| 236 | 238 |
| 237 guest_visible_ = params.visible; | 239 guest_visible_ = params.visible; |
| 238 UpdateVisibility(); | 240 UpdateVisibility(); |
| 239 | 241 |
| 240 is_full_page_plugin_ = params.is_full_page_plugin; | 242 is_full_page_plugin_ = params.is_full_page_plugin; |
| 241 guest_window_rect_ = gfx::Rect(params.origin, | 243 guest_window_rect_ = gfx::Rect(params.origin, |
| 242 params.resize_guest_params.view_size); | 244 params.resize_guest_params.view_size); |
| 243 | 245 |
| 244 if (owner_web_contents_ != owner_web_contents) { | 246 if (owner_web_contents_ != owner_web_contents) { |
| 245 WebContentsViewGuest* new_view = | 247 // View is not created yet in the case if OOPIF |
| 246 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 248 //WebContentsViewGuest* new_view = |
| 247 if (owner_web_contents_) | 249 // static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
| 248 new_view->OnGuestDetached(owner_web_contents_->GetView()); | 250 //if (owner_web_contents_) |
| 251 // new_view->OnGuestDetached(owner_web_contents_->GetView()); | |
| 249 | 252 |
| 250 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | 253 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to |
| 251 // be attached. | 254 // be attached. |
| 252 owner_web_contents_ = owner_web_contents; | 255 owner_web_contents_ = owner_web_contents; |
| 253 new_view->OnGuestAttached(owner_web_contents_->GetView()); | 256 //new_view->OnGuestAttached(owner_web_contents_->GetView()); |
| 254 } | 257 } |
| 255 | 258 |
| 256 RendererPreferences* renderer_prefs = | 259 RendererPreferences* renderer_prefs = |
| 257 GetWebContents()->GetMutableRendererPrefs(); | 260 GetWebContents()->GetMutableRendererPrefs(); |
| 258 std::string guest_user_agent_override = renderer_prefs->user_agent_override; | 261 std::string guest_user_agent_override = renderer_prefs->user_agent_override; |
| 259 // Copy renderer preferences (and nothing else) from the embedder's | 262 // Copy renderer preferences (and nothing else) from the embedder's |
| 260 // WebContents to the guest. | 263 // WebContents to the guest. |
| 261 // | 264 // |
| 262 // For GTK and Aura this is necessary to get proper renderer configuration | 265 // For GTK and Aura this is necessary to get proper renderer configuration |
| 263 // values for caret blinking interval, colors related to selection and | 266 // values for caret blinking interval, colors related to selection and |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 last_pending_frame_->producing_host_id, | 600 last_pending_frame_->producing_host_id, |
| 598 ack); | 601 ack); |
| 599 last_pending_frame_.reset(); | 602 last_pending_frame_.reset(); |
| 600 } | 603 } |
| 601 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id, | 604 delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id, |
| 602 params.is_full_page_plugin); | 605 params.is_full_page_plugin); |
| 603 | 606 |
| 604 // If a RenderView has already been created for this new window, then we need | 607 // If a RenderView has already been created for this new window, then we need |
| 605 // to initialize the browser-side state now so that the RenderFrameHostManager | 608 // to initialize the browser-side state now so that the RenderFrameHostManager |
| 606 // does not create a new RenderView on navigation. | 609 // does not create a new RenderView on navigation. |
| 607 if (has_render_view_) { | 610 //if (has_render_view_) { |
| 608 // This will trigger a callback to RenderViewReady after a round-trip IPC. | 611 // // This will trigger a callback to RenderViewReady after a round-trip IPC. |
| 609 static_cast<RenderViewHostImpl*>( | 612 // static_cast<RenderViewHostImpl*>( |
| 610 GetWebContents()->GetRenderViewHost())->Init(); | 613 // GetWebContents()->GetRenderViewHost())->Init(); |
| 611 WebContentsViewGuest* web_contents_view = | 614 // WebContentsViewGuest* web_contents_view = |
| 612 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 615 // static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
| 613 if (!web_contents()->GetRenderViewHost()->GetView()) { | 616 // if (!web_contents()->GetRenderViewHost()->GetView()) { |
| 614 web_contents_view->CreateViewForWidget( | 617 // web_contents_view->CreateViewForWidget( |
| 615 web_contents()->GetRenderViewHost(), true); | 618 // web_contents()->GetRenderViewHost(), true); |
| 616 } | 619 // } |
| 617 } | 620 //} |
| 618 | 621 |
| 619 InitInternal(params, embedder_web_contents); | 622 InitInternal(params, embedder_web_contents); |
| 620 | 623 |
| 621 attached_ = true; | 624 attached_ = true; |
| 622 SendQueuedMessages(); | 625 SendQueuedMessages(); |
| 623 | 626 |
| 624 // Create a swapped out RenderView for the guest in the embedder render | 627 // Create a swapped out RenderView for the guest in the embedder render |
| 625 // process, so that the embedder can access the guest's window object. | 628 // process, so that the embedder can access the guest's window object. |
| 626 // On reattachment, we can reuse the same swapped out RenderView because | 629 // On reattachment, we can reuse the same swapped out RenderView because |
| 627 // the embedder process will always be the same even if the embedder | 630 // the embedder process will always be the same even if the embedder |
| 628 // WebContents changes. | 631 // WebContents changes. |
| 629 if (guest_proxy_routing_id_ == MSG_ROUTING_NONE) { | 632 // Don't create the proxy here, we'll create it later. |
| 630 guest_proxy_routing_id_ = | 633 //if (guest_proxy_routing_id_ == MSG_ROUTING_NONE) { |
| 631 GetWebContents()->CreateSwappedOutRenderView( | 634 // guest_proxy_routing_id_ = |
| 632 owner_web_contents_->GetSiteInstance()); | 635 // GetWebContents()->CreateSwappedOutRenderView( |
| 633 } | 636 // owner_web_contents_->GetSiteInstance()); |
| 637 //} | |
| 634 | 638 |
| 635 delegate_->DidAttach(guest_proxy_routing_id_); | 639 delegate_->DidAttach(guest_proxy_routing_id_); |
| 636 | 640 |
| 637 has_render_view_ = true; | 641 //has_render_view_ = true; |
| 638 | 642 |
| 639 // Enable input method for guest if it's enabled for the embedder. | 643 //// Enable input method for guest if it's enabled for the embedder. |
| 640 if (static_cast<RenderViewHostImpl*>( | 644 //if (static_cast<RenderViewHostImpl*>( |
| 641 owner_web_contents_->GetRenderViewHost())->input_method_active()) { | 645 // owner_web_contents_->GetRenderViewHost())->input_method_active()) { |
| 642 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 646 // RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
| 643 GetWebContents()->GetRenderViewHost()); | 647 // GetWebContents()->GetRenderViewHost()); |
| 644 guest_rvh->SetInputMethodActive(true); | 648 // guest_rvh->SetInputMethodActive(true); |
| 645 } | 649 //} |
| 646 | 650 |
| 647 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); | 651 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Attached")); |
| 648 } | 652 } |
| 649 | 653 |
| 650 void BrowserPluginGuest::OnCompositorFrameSwappedACK( | 654 void BrowserPluginGuest::OnCompositorFrameSwappedACK( |
| 651 int browser_plugin_instance_id, | 655 int browser_plugin_instance_id, |
| 652 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { | 656 const FrameHostMsg_CompositorFrameSwappedACK_Params& params) { |
| 653 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, | 657 RenderWidgetHostImpl::SendSwapCompositorFrameAck(params.producing_route_id, |
| 654 params.output_surface_id, | 658 params.output_surface_id, |
| 655 params.producing_host_id, | 659 params.producing_host_id, |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 904 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 908 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
| 905 const gfx::Range& range, | 909 const gfx::Range& range, |
| 906 const std::vector<gfx::Rect>& character_bounds) { | 910 const std::vector<gfx::Rect>& character_bounds) { |
| 907 static_cast<RenderWidgetHostViewBase*>( | 911 static_cast<RenderWidgetHostViewBase*>( |
| 908 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 912 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
| 909 range, character_bounds); | 913 range, character_bounds); |
| 910 } | 914 } |
| 911 #endif | 915 #endif |
| 912 | 916 |
| 913 } // namespace content | 917 } // namespace content |
| OLD | NEW |