diff --git a/libcef/browser/alloy/alloy_content_browser_client.cc b/libcef/browser/alloy/alloy_content_browser_client.cc index 63a688a6f..1cbf52f3e 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.cc +++ b/libcef/browser/alloy/alloy_content_browser_client.cc @@ -1518,6 +1518,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 4305aa16f..d6bd90e8f 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.h +++ b/libcef/browser/alloy/alloy_content_browser_client.h @@ -237,6 +237,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 9ecf1ef0e..fd863c0a5 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 5cef9fc7e..323d1db1a 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(