diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index d65a78ada..320dd2438 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -1590,10 +1590,13 @@ CefRefPtr CefBrowserHostImpl::GetFrameForRequest( content::ResourceRequestInfo::ForRequest(request); if (!info) return nullptr; - // The value of |IsMainFrame| is unreliable when |IsDownload| returns true. + // The value of |IsMainFrame| is unreliable in these cases. + const bool is_main_frame_state_flaky = + info->IsDownload() || + info->GetResourceType() == content::RESOURCE_TYPE_XHR; return GetOrCreateFrame(info->GetRenderFrameID(), info->GetFrameTreeNodeId(), CefFrameHostImpl::kUnspecifiedFrameId, - info->IsMainFrame(), info->IsDownload(), + info->IsMainFrame(), is_main_frame_state_flaky, base::string16(), GURL()); } @@ -3224,7 +3227,7 @@ CefRefPtr CefBrowserHostImpl::GetOrCreateFrame( int frame_tree_node_id, int64 parent_frame_id, bool is_main_frame, - bool is_download, + bool is_main_frame_state_flaky, base::string16 frame_name, const GURL& frame_url) { // We need either a valid |frame_id| or a valid |frame_tree_node_id|. @@ -3245,13 +3248,13 @@ CefRefPtr CefBrowserHostImpl::GetOrCreateFrame( if (frame_id < 0) { // With PlzNavigate the renderer process representation might not exist yet. - if ((is_main_frame || is_download) && + if ((is_main_frame || is_main_frame_state_flaky) && main_frame_id_ != CefFrameHostImpl::kInvalidFrameId) { // Operating in the main frame. Continue using the existing main frame // object until the new renderer process representation is created. frame_id = main_frame_id_; } else { - if (is_main_frame || is_download) { + if (is_main_frame || is_main_frame_state_flaky) { // Always use the same pending object for the main frame. frame_tree_node_id = kMainFrameTreeNodeId; } @@ -3319,7 +3322,7 @@ CefRefPtr CefBrowserHostImpl::GetOrCreateFrame( } } - if (!frame_created && !is_download) + if (!frame_created && !is_main_frame_state_flaky) frame->SetAttributes(is_main_frame, url, name, parent_frame_id); #if DCHECK_IS_ON() diff --git a/libcef/browser/browser_host_impl.h b/libcef/browser/browser_host_impl.h index d09a082ed..da7e94132 100644 --- a/libcef/browser/browser_host_impl.h +++ b/libcef/browser/browser_host_impl.h @@ -586,13 +586,13 @@ class CefBrowserHostImpl : public CefBrowserHost, // if PlzNavigate is disabled; or >= 0 otherwise. |parent_frame_id| will be // CefFrameHostImpl::kUnspecifiedFrameId if unknown. In cases where |frame_id| // is < 0 either the existing main frame object or a pending object will be - // returned depending on current state. If |is_download| is true then the - // value of |is_main_frame| cannot be relied on. + // returned depending on current state. If |is_main_frame_state_flaky| is true + // then the value of |is_main_frame| cannot be relied on. CefRefPtr GetOrCreateFrame(int64 frame_id, int frame_tree_node_id, int64 parent_frame_id, bool is_main_frame, - bool is_download, + bool is_main_frame_state_flaky, base::string16 frame_name, const GURL& frame_url);