diff --git a/libcef/browser/alloy/alloy_content_browser_client.cc b/libcef/browser/alloy/alloy_content_browser_client.cc index 0215a1ed9..f3aeeee84 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.cc +++ b/libcef/browser/alloy/alloy_content_browser_client.cc @@ -1523,6 +1523,18 @@ bool AlloyContentBrowserClient::ShouldAllowPluginCreation( return true; } +void AlloyContentBrowserClient::OnWebContentsCreated( + content::WebContents* web_contents) { + // Attach universal WebContentsObservers. These are quite rare, and in most + // cases CefBrowserPlatformDelegateAlloy::BrowserCreated and/or + // CefExtensionsAPIClient::AttachWebContentsHelpers should be used instead. + + if (extensions::ExtensionsEnabled()) { + extensions::CefExtensionWebContentsObserver::CreateForWebContents( + web_contents); + } +} + bool AlloyContentBrowserClient::IsFindInPageDisabledForOrigin( const url::Origin& origin) { // For PDF viewing with the PPAPI-free PDF Viewer, find-in-page should only diff --git a/libcef/browser/alloy/alloy_content_browser_client.h b/libcef/browser/alloy/alloy_content_browser_client.h index 7be46fc2d..037776ed5 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.h +++ b/libcef/browser/alloy/alloy_content_browser_client.h @@ -236,6 +236,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient { bool ShouldAllowPluginCreation( const url::Origin& embedder_origin, const content::PepperPluginInfo& plugin_info) override; + void OnWebContentsCreated(content::WebContents* web_contents) override; bool IsFindInPageDisabledForOrigin(const url::Origin& origin) override; CefRefPtr request_context() const; diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/libcef/browser/alloy/browser_platform_delegate_alloy.cc index b254c0e07..6280f2f8c 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.cc +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.cc @@ -179,9 +179,6 @@ void CefBrowserPlatformDelegateAlloy::BrowserCreated( printing::CefPrintViewManager::CreateForWebContents(web_contents_); if (extensions::ExtensionsEnabled()) { - extensions::CefExtensionWebContentsObserver::CreateForWebContents( - web_contents_); - // Used by the tabs extension API. zoom::ZoomController::CreateForWebContents(web_contents_); } diff --git a/libcef/browser/extensions/extensions_api_client.cc b/libcef/browser/extensions/extensions_api_client.cc index 131b46211..e9e49a103 100644 --- a/libcef/browser/extensions/extensions_api_client.cc +++ b/libcef/browser/extensions/extensions_api_client.cc @@ -52,8 +52,6 @@ void CefExtensionsAPIClient::AttachWebContentsHelpers( PrefsTabHelper::CreateForWebContents(web_contents); printing::CefPrintViewManager::CreateForWebContents(web_contents); - CefExtensionWebContentsObserver::CreateForWebContents(web_contents); - // Used by the PDF extension. pdf::PDFWebContentsHelper::CreateForWebContentsWithClient( web_contents, std::unique_ptr(