Skip to content

Commit 4be41f2

Browse files
authored
browser(webkit): build fix, switch to the new download API (#4621)
1 parent d8520f0 commit 4be41f2

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1398
2-
Changed: [email protected] Fri 04 Dec 2020 05:44:45 PM PST
1+
1399
2+
Changed: [email protected] Mon Dec 7 10:04:55 PST 2020

browser_patches/webkit/embedder/Playwright/mac/AppDelegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@property (nonatomic, copy) void (^completionHandler)(BOOL accept, NSString* value);
3232
@end
3333

34-
@interface BrowserAppDelegate : NSObject <NSApplicationDelegate, WKNavigationDelegate, WKUIDelegate, _WKBrowserInspectorDelegate, _WKDownloadDelegate> {
34+
@interface BrowserAppDelegate : NSObject <NSApplicationDelegate, WKNavigationDelegate, WKUIDelegate, _WKBrowserInspectorDelegate, WKDownloadDelegate> {
3535
NSMutableSet *_headlessWindows;
3636
NSMutableSet *_browserContexts;
3737
bool _headless;

browser_patches/webkit/embedder/Playwright/mac/AppDelegate.m

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ - (_WKBrowserContext *)createBrowserContext:(NSString *)proxyServer WithBypassLi
335335
[dataStoreConfiguration setProxyConfiguration:[self proxyConfiguration:proxyServer WithBypassList:proxyBypassList]];
336336
browserContext.dataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration] autorelease];
337337
browserContext.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration] autorelease];
338-
[browserContext.processPool _setDownloadDelegate:self];
339338
[_browserContexts addObject:browserContext];
340339
return browserContext;
341340
}
@@ -434,8 +433,8 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
434433
{
435434
LOG(@"decidePolicyForNavigationAction");
436435

437-
if (navigationAction._shouldPerformDownload) {
438-
decisionHandler(_WKNavigationActionPolicyDownload);
436+
if (navigationAction.downloadAttribute) {
437+
decisionHandler(WKNavigationActionPolicyBecomeDownload);
439438
return;
440439
}
441440
if (navigationAction._canHandleRequest) {
@@ -455,17 +454,27 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNaviga
455454

456455
NSString *disposition = [[httpResponse allHeaderFields] objectForKey:@"Content-Disposition"];
457456
if (disposition && [disposition hasPrefix:@"attachment"]) {
458-
decisionHandler(_WKNavigationResponsePolicyBecomeDownload);
457+
decisionHandler(WKNavigationResponsePolicyBecomeDownload);
459458
return;
460459
}
461460
decisionHandler(WKNavigationResponsePolicyAllow);
462461
}
463462

464-
#pragma mark _WKDownloadDelegate
463+
- (void)webView:(WKWebView *)webView navigationAction:(WKNavigationAction *)navigationAction didBecomeDownload:(WKDownload *)download
464+
{
465+
download.delegate = self;
466+
}
467+
468+
- (void)webView:(WKWebView *)webView navigationResponse:(WKNavigationResponse *)navigationResponse didBecomeDownload:(WKDownload *)download
469+
{
470+
download.delegate = self;
471+
}
472+
473+
#pragma mark WKDownloadDelegate
465474

466-
- (void)_download:(_WKDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename completionHandler:(void (^)(BOOL allowOverwrite, NSString *destination))completionHandler
475+
- (void)download:(WKDownload *)download decideDestinationWithResponse:(NSURLResponse *)response suggestedFilename:(NSString *)suggestedFilename completionHandler:(void (^)(NSURL * _Nullable destination))completionHandler
467476
{
468-
completionHandler(NO, @"");
477+
completionHandler(nil);
469478
}
470479

471480
@end

browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNaviga
687687

688688
NSString *disposition = [[httpResponse allHeaderFields] objectForKey:@"Content-Disposition"];
689689
if (disposition && [disposition hasPrefix:@"attachment"]) {
690-
decisionHandler(_WKNavigationResponsePolicyBecomeDownload);
690+
decisionHandler(WKNavigationResponsePolicyBecomeDownload);
691691
return;
692692
}
693693
decisionHandler(WKNavigationResponsePolicyAllow);

0 commit comments

Comments
 (0)