Open lucamuscat opened 2 months ago
As background, the "Download" button in the PDF viewer should trigger a call to PdfViewWebPlugin::HandleSaveMessage (via onDownloadClick_ in the JS code). There is a different code path for original vs edited PDF files (SaveToFile vs SaveToBuffer). SaveToFile calls PDFDocumentHelper::SaveUrlAs and SaveToBuffer calls saveData_ (JS code). The SaveToFile case should call DownloadManagerImpl::DownloadUrl. However, the SaveToBuffer case would not trigger a download because it operates using local (in memory) PDF modifications.
Describe the bug Typically,
DownloadHandler::CanDownload
is called before any download, giving the developer the opportunity to decide whether a file should be downloaded.DownloadHandler::CanDownload
is not executed when a PDF file is downloaded through the PDF viewer plugin, circumventing the logic found inDownloadHandler::CanDownload
.Although one may argue that the PDF is technically already downloaded, thereby making this method call redundant, it subverts the exceptation that
DownloadHandler::CanDownload
method is called on all downloads.My current workaround is to move my
DownloadHandler::CanDownload
logic intoDownloadHandler::OnBeforeDownload
, and returning false inDownloadHandler::OnBeforeDownload
, allowing the alloy runtime to cancel the download by default. This is a hacky/dirty workaround which I wish to avoid.To Reproduce Steps to reproduce the behavior:
cef-project
containing the MVP of the bugminimal
executable.DownloadHandler::CanDownload
will log a message starting withCanDownload
when triggered, allowing you to grep for the log.CanDownload
logExpected behavior
DownloadHandler::CanDownload
is called when downloading a PDF file through the PDF viewer.Versions (please complete the following information):
Additional context So far, I have only tried reproducing the bug in the
minimal
project incef-project
, but I also observe this behaviour in another project.Let me know if I can provide more information. If you know where I can look to start fixing this bug, kindly let me know.
Regards, Luca