Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
don't resume loading for renderer initiated navigations unless a rend…
Browse files Browse the repository at this point in the history
…er widget view exists for the webcontents

fix brave/browser-laptop#14405
  • Loading branch information
bridiver committed Jun 25, 2018
1 parent 17f64d4 commit 55aac2b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion brave/browser/guest_view/tab_view/tab_view_guest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "components/guest_view/browser/guest_view_event.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/guest_view/common/guest_view_constants.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/web_contents/web_contents_view_guest.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/guest_host.h"
#include "content/public/browser/navigation_entry.h"
Expand Down Expand Up @@ -171,7 +173,7 @@ void TabViewGuest::Load() {
auto tab_helper = extensions::TabHelper::FromWebContents(web_contents());
if (tab_helper && !tab_helper->IsDiscarded()) {
if (!web_contents()->HasOpener())
api_web_contents_->ResumeLoadingCreatedWebContents();
web_contents()->ResumeLoadingCreatedWebContents();

web_contents()->WasHidden();
web_contents()->WasShown();
Expand Down Expand Up @@ -322,6 +324,24 @@ void TabViewGuest::ApplyAttributes(const base::DictionaryValue& params) {
if (new_window_info.changed || !web_contents()->HasOpener()) {
NavigateGuest(
new_window_info.url.spec(), false /* force_navigation */);
} else if (web_contents()->HasOpener()) {
// if the renderer process creates the RenderView, ensure that
// a view exists for the widget before the provisional load commit
// or the RenderWidgetHost won't get the new content_source_id
// see RenderFrameHostImpl::DidCommitProvisionalLoad
if (web_contents()->GetMainFrame()->IsRenderFrameLive()) {
auto* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents());
content::WebContentsViewGuest* web_contents_view =
static_cast<content::WebContentsViewGuest*>(
web_contents_impl->GetView());
if (!web_contents()->GetRenderViewHost()->GetWidget()->GetView()) {
web_contents_view->CreateViewForWidget(
web_contents()->GetRenderViewHost()->GetWidget(), true);
}
}
// now it's safe to resume loading
web_contents()->ResumeLoadingCreatedWebContents();
}

// Once a new guest is attached to the DOM of the embedder page the
Expand Down

0 comments on commit 55aac2b

Please sign in to comment.