mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add permission callback for user-initated downloads (fixes issue #3183)
This change adds a CefDownloadHandler::CanDownload callback for optionally blocking user-initiated downloads (e.g. alt + link click or link click that returns a `Content-Disposition: attachment` response from the server). To test: - Run `ceftests --gtest_filter=DownloadTest.*`. - Run `cefclient --hide-controls`. User-initiated downloads will be blocked.
This commit is contained in:
@@ -515,6 +515,21 @@ bool ClientHandler::OnCursorChange(CefRefPtr<CefBrowser> browser,
|
||||
return mouse_cursor_change_disabled_;
|
||||
}
|
||||
|
||||
bool ClientHandler::CanDownload(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& url,
|
||||
const CefString& request_method) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
if (!with_controls_) {
|
||||
// Block the download.
|
||||
LOG(INFO) << "Blocking download";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allow the download.
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClientHandler::OnBeforeDownload(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefDownloadItem> download_item,
|
||||
|
Reference in New Issue
Block a user