-
-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add download started and download completed callbacks #530
feat: Add download started and download completed callbacks #530
Conversation
Also adds the complete and failed callbacks.
bf039b2
to
799da8e
Compare
Now has handler for download start/deny and download completed callback
This avoids the indirection of the closure builder pattern whilst still solving the lifetime issues.
What is this PR status? |
7e82e16
to
b600926
Compare
macOS implementation works, but may rely on an incorrect assumption - clicking the download link seems to return a random blob URL, so we just grab the first saved blob URL
@amrbashir I believe I've addressed your comments, plus cleaned some things up. Would you be able to give it another look over? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than these two nit-picks, the Linux/Windows implementation looks good, as for macOS, I will leave it for @wusyong or @lucasfernog to approve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now for Windows and Linux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking so long to merge this PR, our macOS expert is currently on vacation
cls.add_ivar::<*mut c_void>("function"); | ||
cls.add_ivar::<*mut c_void>("HasDownloadHandler"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extract these two strings into some consts so it is easier to track/change in the future? Actually any ivar used more than one time should be in a const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many more ivar like this. I think we should do this in another PR.
Thanks for this amazing PR @atlanticaccent ! |
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___
)Other information
Windows works completely - the callbacks fire and the file downloads. The download location can even be changed through the crude API I've implemented (a
&mut String
passed to the download started callback). One note on changing download location paths is that Universal Naming Convention file paths do not work (they start with slashes and a question mark) - these are generated when callingcanonicalize
so an alternative solution is necessary.Linux seems to be working to some extent - both callbacks fire, however controlling where the file is saved seems to have no effect and causes the download to stall indefinitely. Not setting the download path causes bizarre behaviour where webkitgtk either claims that the download has succeeded (to where is unclear) or that the path (which is full of invalid characters) is occupied.
I attempted a macOS implementation however seem to have failed completely. I have aDownloadDelegate
being created and set, and a couple of what I think are necessary methods implemented on theWKWebview
, but nothing seems to get the actual delegate functions to fire.The macOS implementation is effectively on par with the linux implementation, in that all the callbacks now fire correctly, but setting the download location causes the entire download to fail, and not setting it does not seem to actually write out a download/file.