Skip to content

Commit

Permalink
fix: return true to process downloading by CefViewCore
Browse files Browse the repository at this point in the history
  • Loading branch information
tishion committed Dec 1, 2024
1 parent 0aa55c8 commit c454c2b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/CefView/CefBrowserApp/CefViewBrowserClient_DownloadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ CefViewBrowserClient::OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CEF_REQUIRE_UI_THREAD();

auto delegate = client_delegate_.lock();
if (delegate)
if (delegate) {
delegate->onBeforeDownload(browser, download_item, suggested_name, callback);
} else {
// no delegate, just allow this download and then cancel it in OnDownloadUpdated
if (callback) {
callback->Continue("", false);
}
}

return false;
/// Return true and execute |callback| either asynchronously or in this method to continue or cancel the download.
/// Return false to proceed with default handling (cancel with Alloy style, download shelf with Chrome style)
return true;
}
#endif

Expand All @@ -52,6 +60,12 @@ CefViewBrowserClient::OnDownloadUpdated(CefRefPtr<CefBrowser> browser,
CEF_REQUIRE_UI_THREAD();

auto delegate = client_delegate_.lock();
if (delegate)
if (delegate) {
delegate->onDownloadUpdated(browser, download_item, callback);
} else {
// no delegate, just cancel this downloading
if (callback) {
callback->Cancel();
}
}
}

0 comments on commit c454c2b

Please sign in to comment.