RESOLVED FIXED 217747
Introduce new download API
https://bugs.webkit.org/show_bug.cgi?id=217747
Summary Introduce new download API
Alex Christensen
Reported 2020-10-14 19:36:11 PDT
Introduce new download SPI
Attachments
Patch (116.32 KB, patch)
2020-10-14 19:52 PDT, Alex Christensen
no flags
Patch (161.97 KB, patch)
2020-10-20 16:56 PDT, Alex Christensen
no flags
Patch (170.38 KB, patch)
2020-11-09 20:31 PST, Alex Christensen
no flags
Patch (169.64 KB, patch)
2020-11-10 09:55 PST, Alex Christensen
no flags
Patch (197.99 KB, patch)
2020-11-11 23:14 PST, Alex Christensen
ews-feeder: commit-queue-
Patch (198.57 KB, patch)
2020-11-11 23:35 PST, Alex Christensen
no flags
Patch (199.49 KB, patch)
2020-11-12 15:48 PST, Alex Christensen
no flags
Patch (199.49 KB, patch)
2020-11-12 18:55 PST, Alex Christensen
no flags
Patch (278.16 KB, patch)
2020-11-17 22:57 PST, Alex Christensen
no flags
Patch (325.51 KB, patch)
2020-11-18 15:09 PST, Alex Christensen
no flags
Patch (321.02 KB, patch)
2020-11-18 15:25 PST, Alex Christensen
ews-feeder: commit-queue-
Patch (321.03 KB, patch)
2020-11-18 15:47 PST, Alex Christensen
no flags
Patch (322.10 KB, patch)
2020-11-18 20:00 PST, Alex Christensen
no flags
Patch (322.05 KB, patch)
2020-11-19 09:51 PST, Alex Christensen
no flags
Patch (322.77 KB, patch)
2020-11-19 14:08 PST, Alex Christensen
no flags
Patch (323.26 KB, patch)
2020-11-20 13:01 PST, Alex Christensen
no flags
Patch (323.19 KB, patch)
2020-12-03 16:37 PST, Alex Christensen
no flags
Patch (309.81 KB, patch)
2020-12-09 19:38 PST, Alex Christensen
no flags
Patch (309.77 KB, patch)
2020-12-09 19:43 PST, Alex Christensen
no flags
Alex Christensen
Comment 1 2020-10-14 19:52:33 PDT
Alex Christensen
Comment 2 2020-10-14 19:53:07 PDT
Still needs a bunch of polish, but feel free to give feedback on the general direction.
EWS Watchlist
Comment 3 2020-10-14 19:53:27 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Geoffrey Garen
Comment 4 2020-10-15 16:48:36 PDT
Comment on attachment 411398 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=411398&action=review > Source/WebKit/UIProcess/API/Cocoa/_WKDownload2.h:40 > +- (void)cancelByProducingResumeData:(void (^)(NSData * _Nullable resumeData))completionHandler; I would just call this cancel. The parameter name already describes what is passed to the completion handler. > Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate2.h:47 > +// FIXME: Blobs don't have a response, but can still have a suggested filename. > +// Separate callback, or nullable response and separate string? > +- (void)download:(_WKDownload2 *)download decideDestinationWithResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURL *destination))completionHandler; Seems like the suggested filename should be its own parameter, and response should be nullable. (Seems OK, since most people will only look at the suggested filename.) > Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate2.h:55 > +- (void)downloadProcessDidTerminate:(_WKDownload2 *)download; Does this have to be separate from the didFail case? A termination seems like a failure to me. And I'm not sure what we're expecting people to do with the termination. Side note: Navigation delegate calls it "...WebContentProcessDidTerminate".
Alex Christensen
Comment 5 2020-10-20 16:56:39 PDT
Radar WebKit Bug Importer
Comment 6 2020-10-21 19:37:14 PDT
Alex Christensen
Comment 7 2020-11-09 20:31:33 PST
Alex Christensen
Comment 8 2020-11-10 09:55:01 PST
Alex Christensen
Comment 9 2020-11-11 23:14:13 PST
Alex Christensen
Comment 10 2020-11-11 23:35:41 PST
Alex Christensen
Comment 11 2020-11-12 14:30:37 PST
WKNavigationResponsePolicyBecomeDownload needs @constant header doc. Will add before landing.
Alex Christensen
Comment 12 2020-11-12 14:31:23 PST
Comment on attachment 413916 [details] Patch Same with WKDownloadRedirectPolicy. More header doc.
Brady Eidson
Comment 13 2020-11-12 14:37:27 PST
Comment on attachment 413916 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=413916&action=review I'm still looking at implementation stuff, but have some header comments > Source/WebKit/UIProcess/API/Cocoa/WKDownload.h:48 > + @discussion The completionHandler is passed data to be used to resume the download if possible. I'd make it more clear that the data is used to *attempt* to resume the download, and maybe even call out that due to server side considerations, some downloads may not be resumable. I would also say something like "to attempt to resume the download, call WKWebView resumeDownloadWithData:" > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:2 > + * Copyright (C) 2014 Apple Inc. All rights reserved. While I know 2014 was a happier time, sadly, I am quite aware that it's 2020. > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:42 > + @param download The web view that received the redirect. /s/web view/download/. (Same comment applies to all of these) > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:72 > + suggested download filename. If the destination file URL is non-null, it must be a file > + that does not exist yet in a directory that does exist. "yet" is unnecessary. The directory must exist and be writeable to the application. > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:95 > + @param resumeData The data to be used to resume this download if possible. Call out the API where the resume data can be used (just like the cancel completion handler) > Source/WebKit/UIProcess/API/Cocoa/WKWebView.h:458 > +/* @abstract Begins a download. > + @param request The request specifying the URL to download. > + @param completionHandler A block called when the download has started. > + */ > +- (void)downloadRequest:(NSURLRequest *)request completionHandler:(void(^)(WKDownload *))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); The purpose of this method is to begin downloading a resource *in the context of the currently displayed webpage as if the policy delegate made a load into a download instead" I would explicitly call this out.
Alex Christensen
Comment 14 2020-11-12 15:48:50 PST
Alex Christensen
Comment 15 2020-11-12 18:55:31 PST
Alex Christensen
Comment 16 2020-11-13 08:27:55 PST
Alex Christensen
Comment 17 2020-11-13 08:29:31 PST
*** Bug 158801 has been marked as a duplicate of this bug. ***
Alex Christensen
Comment 18 2020-11-17 22:57:38 PST
Brady Eidson
Comment 19 2020-11-18 09:32:41 PST
Comment on attachment 414415 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=414415&action=review Besides fixing EWSs, etc... seems fine. Except for calling downloads "web views" > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:57 > + @param download The web view that received the authentication challenge. Download > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:82 > + @param download The web view that has written data. Download > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:93 > + @param download The web view that finished. Download > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:98 > + @param download The web view that has failed. Download
Alex Christensen
Comment 20 2020-11-18 15:09:03 PST
Alex Christensen
Comment 21 2020-11-18 15:25:44 PST
Alex Christensen
Comment 22 2020-11-18 15:47:15 PST
Alex Christensen
Comment 23 2020-11-18 20:00:11 PST
Alex Christensen
Comment 24 2020-11-19 09:51:48 PST
Alex Christensen
Comment 25 2020-11-19 12:29:46 PST
Comment on attachment 414596 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=414596&action=review > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:70 > + @param response The server response, if this download was the result of an HTTP request. I need to add "or a synthesized response for blob downloads" Also, response should not be nullable. I thought it would be with blobs but it's not.
Brady Eidson
Comment 26 2020-11-19 13:42:16 PST
Comment on attachment 414596 [details] Patch (Relatively) Minor changes from last time, still r+
Alex Christensen
Comment 27 2020-11-19 14:08:29 PST
Alex Christensen
Comment 28 2020-11-19 15:40:21 PST
Comment on attachment 414617 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=414617&action=review > Source/WebKit/UIProcess/API/Cocoa/WKNavigation.mm:48 > +- (BOOL)_wasUserInitiated This is not actually needed. Will remove.
Alex Christensen
Comment 29 2020-11-20 13:01:55 PST
Alex Christensen
Comment 30 2020-12-03 16:37:02 PST
EWS
Comment 31 2020-12-03 19:31:02 PST
Committed r270422: <https://trac.webkit.org/changeset/270422> All reviewed patches have been landed. Closing bug and clearing flags on attachment 415365 [details].
WebKit Commit Bot
Comment 32 2020-12-04 13:56:17 PST
Re-opened since this is blocked by bug 219554
Alexey Proskuryakov
Comment 33 2020-12-04 14:01:00 PST
Reverted in r270454, please see radar for details.
Alex Christensen
Comment 34 2020-12-08 11:18:43 PST
Comment on attachment 415365 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=415365&action=review > Source/WebKit/UIProcess/API/Cocoa/WKDownloadDelegate.h:68 > +/* @abstract Invoked when the download needs to respond to an authentication challenge. This isn't correct. Also, I'm going to make decideDestinationWithResponse mandatory because downloads will always fail if it is not implemented.
Alex Christensen
Comment 35 2020-12-09 19:38:18 PST
Alex Christensen
Comment 36 2020-12-09 19:43:26 PST
EWS
Comment 37 2020-12-10 11:28:16 PST
Committed r270638: <https://trac.webkit.org/changeset/270638> All reviewed patches have been landed. Closing bug and clearing flags on attachment 415824 [details].
Note You need to log in before you can comment on or make changes to this bug.