Ignore load of excluded PDF renderer frames
Starting with M125 we get WebContentsObserver callbacks for speculative PDF renderer frames. These callbacks should be ignored.
This commit is contained in:
parent
b67cbc47e3
commit
65234a6830
|
@ -569,6 +569,10 @@ void CefBrowserContentsDelegate::DidFinishLoad(
|
|||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url) {
|
||||
auto frame = browser_info_->GetFrameForHost(render_frame_host);
|
||||
if (!frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
frame->RefreshAttributes();
|
||||
|
||||
int http_status_code = 0;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/browser_info_manager.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/frame_util.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
@ -98,6 +99,11 @@ void CefBrowserInfo::MaybeCreateFrame(content::RenderFrameHost* host,
|
|||
bool is_guest_view) {
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
if (CefBrowserInfoManager::IsExcludedFrameHost(host)) {
|
||||
// Don't create a FrameHost for an excluded type.
|
||||
return;
|
||||
}
|
||||
|
||||
const auto global_id = host->GetGlobalId();
|
||||
const bool is_main_frame = (host->GetParent() == nullptr);
|
||||
|
||||
|
@ -212,10 +218,11 @@ void CefBrowserInfo::FrameHostStateChanged(
|
|||
base::AutoLock lock_scope(lock_);
|
||||
|
||||
auto it = frame_id_map_.find(host->GetGlobalId());
|
||||
DCHECK(it != frame_id_map_.end());
|
||||
DCHECK((!it->second->is_in_bfcache_ && added_to_bfcache) ||
|
||||
(it->second->is_in_bfcache_ && removed_from_bfcache));
|
||||
it->second->is_in_bfcache_ = added_to_bfcache;
|
||||
if (it != frame_id_map_.end()) {
|
||||
DCHECK((!it->second->is_in_bfcache_ && added_to_bfcache) ||
|
||||
(it->second->is_in_bfcache_ && removed_from_bfcache));
|
||||
it->second->is_in_bfcache_ = added_to_bfcache;
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
|
||||
|
@ -225,7 +232,9 @@ void CefBrowserInfo::RemoveFrame(content::RenderFrameHost* host) {
|
|||
|
||||
const auto global_id = host->GetGlobalId();
|
||||
auto it = frame_id_map_.find(global_id);
|
||||
DCHECK(it != frame_id_map_.end());
|
||||
if (it == frame_id_map_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto frame_info = it->second;
|
||||
|
||||
|
|
|
@ -551,6 +551,31 @@ CefRefPtr<CefFrameHostImpl> CefBrowserInfoManager::GetFrameHost(
|
|||
return frame;
|
||||
}
|
||||
|
||||
// static
|
||||
bool CefBrowserInfoManager::IsExcludedFrameHost(content::RenderFrameHost* rfh) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(rfh);
|
||||
|
||||
const bool is_pdf_process = rfh->GetProcess()->IsPdf();
|
||||
if (is_pdf_process) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(rfh);
|
||||
const bool is_browser_process_guest =
|
||||
extensions::IsBrowserPluginGuest(web_contents);
|
||||
if (is_browser_process_guest) {
|
||||
return true;
|
||||
}
|
||||
const bool is_print_preview_dialog =
|
||||
extensions::IsPrintPreviewDialog(web_contents);
|
||||
if (is_print_preview_dialog) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CefBrowserInfoManager::BrowserInfoList
|
||||
CefBrowserInfoManager::GetBrowserInfoList() {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
|
|
|
@ -160,6 +160,9 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
|||
CefBrowserInfo** browser_info,
|
||||
bool* excluded_type);
|
||||
|
||||
// Returns true if |rfh| should be excluded (no FrameHost created).
|
||||
static bool IsExcludedFrameHost(content::RenderFrameHost* rfh);
|
||||
|
||||
private:
|
||||
// RenderProcessHostObserver methods:
|
||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
|
|
|
@ -92,7 +92,7 @@ class PdfViewerTestHandler : public TestHandler, public CefContextMenuHandler {
|
|||
int httpStatusCode) override {
|
||||
bool is_pdf1 = false;
|
||||
const std::string& url = frame->GetURL();
|
||||
if (url == "about:blank") {
|
||||
if (url == "about:blank" || url.find("chrome-extension://") == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue