@@ -335,7 +335,6 @@ - (_WKBrowserContext *)createBrowserContext:(NSString *)proxyServer WithBypassLi
335
335
[dataStoreConfiguration setProxyConfiguration: [self proxyConfiguration: proxyServer WithBypassList: proxyBypassList]];
336
336
browserContext.dataStore = [[[WKWebsiteDataStore alloc ] _initWithConfiguration: dataStoreConfiguration] autorelease ];
337
337
browserContext.processPool = [[[WKProcessPool alloc ] _initWithConfiguration: processConfiguration] autorelease ];
338
- [browserContext.processPool _setDownloadDelegate: self ];
339
338
[_browserContexts addObject: browserContext];
340
339
return browserContext;
341
340
}
@@ -434,8 +433,8 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
434
433
{
435
434
LOG (@" decidePolicyForNavigationAction" );
436
435
437
- if (navigationAction._shouldPerformDownload ) {
438
- decisionHandler (_WKNavigationActionPolicyDownload );
436
+ if (navigationAction.downloadAttribute ) {
437
+ decisionHandler (WKNavigationActionPolicyBecomeDownload );
439
438
return ;
440
439
}
441
440
if (navigationAction._canHandleRequest ) {
@@ -455,17 +454,27 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNaviga
455
454
456
455
NSString *disposition = [[httpResponse allHeaderFields ] objectForKey: @" Content-Disposition" ];
457
456
if (disposition && [disposition hasPrefix: @" attachment" ]) {
458
- decisionHandler (_WKNavigationResponsePolicyBecomeDownload );
457
+ decisionHandler (WKNavigationResponsePolicyBecomeDownload );
459
458
return ;
460
459
}
461
460
decisionHandler (WKNavigationResponsePolicyAllow );
462
461
}
463
462
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
465
474
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
467
476
{
468
- completionHandler (NO , @" " );
477
+ completionHandler (nil );
469
478
}
470
479
471
480
@end
0 commit comments