diff --git a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc index ae1c40555e6f510982173ad9261e97ca92020435..05886b61c0fcfa38ea7d4ed5b95c2ce8d75153f4 100644 --- a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc @@ -2143,22 +2143,32 @@ void NWebHandlerDelegate::OnReceivedIcon(const void* data, } } + #ifdef OHOS_BFCACHE void NWebHandlerDelegate::UpdateFavicon(CefRefPtr browser) { CEF_REQUIRE_UI_THREAD(); - + + if (!browser || !browser->GetHost() || + !browser->GetHost()->GetVisibleNavigationEntry()) { + return; + } + LOG(INFO) << "[Favicon] nweb_handler delegate start to update favicon."; + void* data = nullptr; int color_type; int alpha_type; int width; int height; - if (browser != nullptr && browser->GetHost() != nullptr - && browser->GetHost()->GetVisibleNavigationEntry() != nullptr) { - LOG(INFO) << "[Favicon] nweb_handler delegate start to update favicon."; - browser->GetHost()->GetVisibleNavigationEntry()->GetFavicon(&data, color_type, alpha_type, width, height); - SetFavicon(data, width, height, ImageColorType(color_type), ImageAlphaType(alpha_type)); + browser->GetHost()->GetVisibleNavigationEntry()->GetFavicon( + &data, color_type, alpha_type, width, height); + SetFavicon(data, width, height, ImageColorType(color_type), + ImageAlphaType(alpha_type)); + + if (data && nweb_handler_) { + nweb_handler_->OnPageIcon(data, width, height, ImageColorType(color_type), + ImageAlphaType(alpha_type)); + return; } - return; } #endif // OHOS_BFCACHE