Changeset 223790 in webkit


Ignore:
Timestamp:
Oct 20, 2017 1:38:41 PM (7 years ago)
Author:
achristensen@apple.com
Message:

Add ObjC SPI to _WKDownloadDelegate missing from WKContextDownloadClient
https://bugs.webkit.org/show_bug.cgi?id=178566
<rdar://problem/23041906>

Reviewed by Brady Eidson.

  • UIProcess/API/Cocoa/_WKDownloadDelegate.h:
  • UIProcess/Cocoa/DownloadClient.h:
  • UIProcess/Cocoa/DownloadClient.mm:

(WebKit::DownloadClient::DownloadClient):
(WebKit::DownloadClient::didReceiveAuthenticationChallenge):
(WebKit::DownloadClient::shouldDecodeSourceDataOfMIMEType):
(WebKit::DownloadClient::didCreateDestination):
(WebKit::DownloadClient::processDidCrash):

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r223785 r223790  
     12017-10-20  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add ObjC SPI to _WKDownloadDelegate missing from WKContextDownloadClient
     4        https://bugs.webkit.org/show_bug.cgi?id=178566
     5        <rdar://problem/23041906>
     6
     7        Reviewed by Brady Eidson.
     8
     9        * UIProcess/API/Cocoa/_WKDownloadDelegate.h:
     10        * UIProcess/Cocoa/DownloadClient.h:
     11        * UIProcess/Cocoa/DownloadClient.mm:
     12        (WebKit::DownloadClient::DownloadClient):
     13        (WebKit::DownloadClient::didReceiveAuthenticationChallenge):
     14        (WebKit::DownloadClient::shouldDecodeSourceDataOfMIMEType):
     15        (WebKit::DownloadClient::didCreateDestination):
     16        (WebKit::DownloadClient::processDidCrash):
     17
    1182017-10-20  Youenn Fablet  <youenn@apple.com>
    219
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate.h

    r223740 r223790  
    4242- (void)_download:(_WKDownload *)download didFailWithError:(NSError *)error;
    4343- (void)_downloadDidCancel:(_WKDownload *)download;
     44- (void)_download:(_WKDownload *)download didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential*))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     45- (void)_download:(_WKDownload *)download didCreateDestination:(NSString *)destination WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     46- (void)_downloadProcessDidCrash:(_WKDownload *)download WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     47- (BOOL)_download:(_WKDownload *)download shouldDecodeSourceDataOfMIMEType:(NSString *)MIMEType WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    4448
    4549- (NSString *)_download:(_WKDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename allowOverwrite:(BOOL *)allowOverwrite WK_API_DEPRECATED_WITH_REPLACEMENT("_download:decideDestinationWithSuggestedFilename:completionHandler:", macosx(10.10, WK_MAC_TBA), ios(8.0, WK_IOS_TBA));
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h

    r223740 r223790  
    5656    void didCancel(WebProcessPool&, DownloadProxy&) final;
    5757    void willSendRequest(WebProcessPool&, DownloadProxy&, WebCore::ResourceRequest&&, const WebCore::ResourceResponse&, Function<void(WebCore::ResourceRequest&&)>&&) final;
     58    void didReceiveAuthenticationChallenge(WebProcessPool&, DownloadProxy&, AuthenticationChallengeProxy&) final;
     59#if !USE(NETWORK_SESSION)
     60    bool shouldDecodeSourceDataOfMIMEType(WebProcessPool&, DownloadProxy&, const String&) final;
     61#endif
     62    void didCreateDestination(WebProcessPool&, DownloadProxy&, const String&) final;
     63    void processDidCrash(WebProcessPool&, DownloadProxy&) final;
    5864
    5965    WeakObjCPtr<id <_WKDownloadDelegate>> m_delegate;
     
    6975        bool downloadDidCancel : 1;
    7076        bool downloadDidReceiveServerRedirectToURL : 1;
     77        bool downloadDidReceiveAuthenticationChallengeCompletionHandler : 1;
     78        bool downloadShouldDecodeSourceDataOfMIMEType : 1;
     79        bool downloadDidCreateDestination : 1;
     80        bool downloadProcessDidCrash : 1;
    7181    } m_delegateMethods;
    7282};
  • trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm

    r223740 r223790  
    2929#if WK_API_ENABLED
    3030
     31#import "AuthenticationChallengeProxy.h"
     32#import "AuthenticationDecisionListener.h"
    3133#import "CompletionHandlerCallChecker.h"
    3234#import "DownloadProxy.h"
     35#import "WKNSURLAuthenticationChallenge.h"
    3336#import "WKNSURLExtras.h"
     37#import "WebCredential.h"
    3438#import "_WKDownloadDelegate.h"
    3539#import "_WKDownloadInternal.h"
     
    5862    m_delegateMethods.downloadDidCancel = [delegate respondsToSelector:@selector(_downloadDidCancel:)];
    5963    m_delegateMethods.downloadDidReceiveServerRedirectToURL = [delegate respondsToSelector:@selector(_download:didReceiveServerRedirectToURL:)];
     64    m_delegateMethods.downloadDidReceiveAuthenticationChallengeCompletionHandler = [delegate respondsToSelector:@selector(_download:didReceiveAuthenticationChallenge:completionHandler:)];
     65    m_delegateMethods.downloadShouldDecodeSourceDataOfMIMEType = [delegate respondsToSelector:@selector(_download:shouldDecodeSourceDataOfMIMEType:)];
     66    m_delegateMethods.downloadDidCreateDestination = [delegate respondsToSelector:@selector(_download:didCreateDestination:)];
     67    m_delegateMethods.downloadProcessDidCrash = [delegate respondsToSelector:@selector(_downloadProcessDidCrash:)];
    6068}
    6169
     
    7684    if (m_delegateMethods.downloadDidReceiveData)
    7785        [m_delegate _download:wrapper(downloadProxy) didReceiveData:length];
     86}
     87
     88void DownloadClient::didReceiveAuthenticationChallenge(WebProcessPool&, DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallenge)
     89{
     90    if (!m_delegateMethods.downloadDidReceiveAuthenticationChallengeCompletionHandler) {
     91        authenticationChallenge.listener()->performDefaultHandling();
     92        return;
     93    }
     94
     95    [m_delegate _download:wrapper(downloadProxy) didReceiveAuthenticationChallenge:wrapper(authenticationChallenge) completionHandler:BlockPtr<void(NSURLSessionAuthChallengeDisposition, NSURLCredential *)>::fromCallable([authenticationChallenge = makeRef(authenticationChallenge), checker = CompletionHandlerCallChecker::create(m_delegate.get().get(), @selector(_download:didReceiveAuthenticationChallenge:completionHandler:))] (NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential) {
     96        if (checker->completionHandlerHasBeenCalled())
     97            return;
     98        checker->didCallCompletionHandler();
     99        switch (disposition) {
     100        case NSURLSessionAuthChallengeUseCredential: {
     101            RefPtr<WebCredential> webCredential;
     102            if (credential)
     103                webCredential = WebCredential::create(WebCore::Credential(credential));
     104           
     105            authenticationChallenge->listener()->useCredential(webCredential.get());
     106            break;
     107        }
     108           
     109        case NSURLSessionAuthChallengePerformDefaultHandling:
     110            authenticationChallenge->listener()->performDefaultHandling();
     111            break;
     112           
     113        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
     114            authenticationChallenge->listener()->cancel();
     115            break;
     116           
     117        case NSURLSessionAuthChallengeRejectProtectionSpace:
     118            authenticationChallenge->listener()->rejectProtectionSpaceAndContinue();
     119            break;
     120           
     121        default:
     122            [NSException raise:NSInvalidArgumentException format:@"Invalid NSURLSessionAuthChallengeDisposition (%ld)", (long)disposition];
     123        }
     124    }).get()];
     125}
     126
     127#if !USE(NETWORK_SESSION)
     128bool DownloadClient::shouldDecodeSourceDataOfMIMEType(WebProcessPool&, DownloadProxy& downloadProxy, const String& mimeType)
     129{
     130    if (m_delegateMethods.downloadShouldDecodeSourceDataOfMIMEType)
     131        return [m_delegate _download:wrapper(downloadProxy) shouldDecodeSourceDataOfMIMEType:mimeType];
     132    return true;
     133}
     134#endif
     135
     136void DownloadClient::didCreateDestination(WebProcessPool&, DownloadProxy& downloadProxy, const String& destination)
     137{
     138    if (m_delegateMethods.downloadDidCreateDestination)
     139        [m_delegate _download:wrapper(downloadProxy) didCreateDestination:destination];
     140}
     141
     142void DownloadClient::processDidCrash(WebProcessPool&, DownloadProxy& downloadProxy)
     143{
     144    if (m_delegateMethods.downloadProcessDidCrash)
     145        [m_delegate _downloadProcessDidCrash:wrapper(downloadProxy)];
    78146}
    79147
Note: See TracChangeset for help on using the changeset viewer.