diff --git a/include/cef_client.h b/include/cef_client.h index ccef36a460a16290e73401c11f9c69c18f66e035..413492cdf6e170a2a491592a213da297a03f3560 100644 --- a/include/cef_client.h +++ b/include/cef_client.h @@ -321,6 +321,12 @@ class CefClient : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void OnPullToRefreshPull(float offset_x, float offset_y) {} + + /// + /// Notify the web activated by window.open. + /// + /*--cef()--*/ + virtual void OnActivateContent() {} #endif #if defined(OHOS_CUSTOM_VIDEO_PLAYER) diff --git a/include/cef_focus_handler.h b/include/cef_focus_handler.h index 5f05e50497bb9a3b6a5520e7e7d5dadfb5da416c..ab6d3377c00d2c42a7d71f36cb8aa12092f5c7ff 100644 --- a/include/cef_focus_handler.h +++ b/include/cef_focus_handler.h @@ -76,6 +76,14 @@ class CefFocusHandler : public virtual CefBaseRefCounted { /// /*--cef()--*/ virtual void OnGotFocus(CefRefPtr browser) {} + +#if defined(OHOS_MULTI_WINDOW) + /// + /// Notify the web activated by window.open. + /// + /*--cef()--*/ + virtual void OnActivateContent() {} +#endif }; #endif // CEF_INCLUDE_CEF_FOCUS_HANDLER_H_ diff --git a/libcef/browser/alloy/alloy_browser_host_impl.cc b/libcef/browser/alloy/alloy_browser_host_impl.cc index c1ebc140ce80256305aec44ac972c773a34baa73..c7e60ff4f0a95e629623a9b135f88429d49b0153 100644 --- a/libcef/browser/alloy/alloy_browser_host_impl.cc +++ b/libcef/browser/alloy/alloy_browser_host_impl.cc @@ -1964,10 +1964,13 @@ content::PreloadingEligibility AlloyBrowserHostImpl::IsPrerender2Supported( #endif } -#ifdef OHOS_FOCUS +#if defined(OHOS_MULTI_WINDOW) void AlloyBrowserHostImpl::ActivateContents(content::WebContents* contents) { LOG(INFO) << "AlloyBrowserHostImpl::ActivateContents"; OnSetFocus(FOCUS_SOURCE_SYSTEM); + if (contents_delegate_) { + contents_delegate_->OnActivateContent(); + } } #endif diff --git a/libcef/browser/browser_contents_delegate.cc b/libcef/browser/browser_contents_delegate.cc index fb9e3c8bf0d232132e4a0624c21db0c915ea41bc..ab258b209ce69f7424ca0c4f3c0fdb11c80ef558 100644 --- a/libcef/browser/browser_contents_delegate.cc +++ b/libcef/browser/browser_contents_delegate.cc @@ -1044,6 +1044,17 @@ bool CefBrowserContentsDelegate::OnSetFocus(cef_focus_source_t source) { return false; } +#if defined(OHOS_MULTI_WINDOW) +void CefBrowserContentsDelegate::OnActivateContent() { + LOG(INFO) << "CefBrowserContentsDelegate::ActivateContent"; + if (auto c = client()) { + if (auto handler = c->GetFocusHandler()) { + handler->OnActivateContent(); + } + } +} +#endif + CefRefPtr CefBrowserContentsDelegate::client() const { if (auto b = browser()) { return b->GetHost()->GetClient(); diff --git a/libcef/browser/browser_contents_delegate.h b/libcef/browser/browser_contents_delegate.h index a1f06bf07c8309efeb7806eedf4d89d882d8b54a..85af2552894563f65e7549e90c6f96ab2f6708ea 100644 --- a/libcef/browser/browser_contents_delegate.h +++ b/libcef/browser/browser_contents_delegate.h @@ -124,6 +124,9 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate, void ShowRepostFormWarningDialog(content::WebContents* source) override; #endif +#if defined(OHOS_MULTI_WINDOW) +void OnActivateContent() override; +#endif // WebContentsObserver methods: void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; void RenderFrameHostChanged(content::RenderFrameHost* old_host,