mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
browser(webkit): build fix, switch to the new download API (#4621)
This commit is contained in:
parent
d8520f0695
commit
4be41f2571
@ -1,2 +1,2 @@
|
|||||||
1398
|
1399
|
||||||
Changed: yurys@chromium.org Fri 04 Dec 2020 05:44:45 PM PST
|
Changed: yurys@chromium.org Mon Dec 7 10:04:55 PST 2020
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
@property (nonatomic, copy) void (^completionHandler)(BOOL accept, NSString* value);
|
@property (nonatomic, copy) void (^completionHandler)(BOOL accept, NSString* value);
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface BrowserAppDelegate : NSObject <NSApplicationDelegate, WKNavigationDelegate, WKUIDelegate, _WKBrowserInspectorDelegate, _WKDownloadDelegate> {
|
@interface BrowserAppDelegate : NSObject <NSApplicationDelegate, WKNavigationDelegate, WKUIDelegate, _WKBrowserInspectorDelegate, WKDownloadDelegate> {
|
||||||
NSMutableSet *_headlessWindows;
|
NSMutableSet *_headlessWindows;
|
||||||
NSMutableSet *_browserContexts;
|
NSMutableSet *_browserContexts;
|
||||||
bool _headless;
|
bool _headless;
|
||||||
|
@ -335,7 +335,6 @@ const NSActivityOptions ActivityOptions =
|
|||||||
[dataStoreConfiguration setProxyConfiguration:[self proxyConfiguration:proxyServer WithBypassList:proxyBypassList]];
|
[dataStoreConfiguration setProxyConfiguration:[self proxyConfiguration:proxyServer WithBypassList:proxyBypassList]];
|
||||||
browserContext.dataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration] autorelease];
|
browserContext.dataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration] autorelease];
|
||||||
browserContext.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration] autorelease];
|
browserContext.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration] autorelease];
|
||||||
[browserContext.processPool _setDownloadDelegate:self];
|
|
||||||
[_browserContexts addObject:browserContext];
|
[_browserContexts addObject:browserContext];
|
||||||
return browserContext;
|
return browserContext;
|
||||||
}
|
}
|
||||||
@ -434,8 +433,8 @@ const NSActivityOptions ActivityOptions =
|
|||||||
{
|
{
|
||||||
LOG(@"decidePolicyForNavigationAction");
|
LOG(@"decidePolicyForNavigationAction");
|
||||||
|
|
||||||
if (navigationAction._shouldPerformDownload) {
|
if (navigationAction.downloadAttribute) {
|
||||||
decisionHandler(_WKNavigationActionPolicyDownload);
|
decisionHandler(WKNavigationActionPolicyBecomeDownload);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (navigationAction._canHandleRequest) {
|
if (navigationAction._canHandleRequest) {
|
||||||
@ -455,17 +454,27 @@ const NSActivityOptions ActivityOptions =
|
|||||||
|
|
||||||
NSString *disposition = [[httpResponse allHeaderFields] objectForKey:@"Content-Disposition"];
|
NSString *disposition = [[httpResponse allHeaderFields] objectForKey:@"Content-Disposition"];
|
||||||
if (disposition && [disposition hasPrefix:@"attachment"]) {
|
if (disposition && [disposition hasPrefix:@"attachment"]) {
|
||||||
decisionHandler(_WKNavigationResponsePolicyBecomeDownload);
|
decisionHandler(WKNavigationResponsePolicyBecomeDownload);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
decisionHandler(WKNavigationResponsePolicyAllow);
|
decisionHandler(WKNavigationResponsePolicyAllow);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark _WKDownloadDelegate
|
- (void)webView:(WKWebView *)webView navigationAction:(WKNavigationAction *)navigationAction didBecomeDownload:(WKDownload *)download
|
||||||
|
|
||||||
- (void)_download:(_WKDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename completionHandler:(void (^)(BOOL allowOverwrite, NSString *destination))completionHandler
|
|
||||||
{
|
{
|
||||||
completionHandler(NO, @"");
|
download.delegate = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)webView:(WKWebView *)webView navigationResponse:(WKNavigationResponse *)navigationResponse didBecomeDownload:(WKDownload *)download
|
||||||
|
{
|
||||||
|
download.delegate = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark WKDownloadDelegate
|
||||||
|
|
||||||
|
- (void)download:(WKDownload *)download decideDestinationWithResponse:(NSURLResponse *)response suggestedFilename:(NSString *)suggestedFilename completionHandler:(void (^)(NSURL * _Nullable destination))completionHandler
|
||||||
|
{
|
||||||
|
completionHandler(nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -687,7 +687,7 @@ static NSSet *dataTypes()
|
|||||||
|
|
||||||
NSString *disposition = [[httpResponse allHeaderFields] objectForKey:@"Content-Disposition"];
|
NSString *disposition = [[httpResponse allHeaderFields] objectForKey:@"Content-Disposition"];
|
||||||
if (disposition && [disposition hasPrefix:@"attachment"]) {
|
if (disposition && [disposition hasPrefix:@"attachment"]) {
|
||||||
decisionHandler(_WKNavigationResponsePolicyBecomeDownload);
|
decisionHandler(WKNavigationResponsePolicyBecomeDownload);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
decisionHandler(WKNavigationResponsePolicyAllow);
|
decisionHandler(WKNavigationResponsePolicyAllow);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user