Title: [223790] trunk/Source/WebKit
Revision
223790
Author
[email protected]
Date
2017-10-20 13:38:41 -0700 (Fri, 20 Oct 2017)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (223789 => 223790)


--- trunk/Source/WebKit/ChangeLog	2017-10-20 20:34:27 UTC (rev 223789)
+++ trunk/Source/WebKit/ChangeLog	2017-10-20 20:38:41 UTC (rev 223790)
@@ -1,3 +1,20 @@
+2017-10-20  Alex Christensen  <[email protected]>
+
+        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):
+
 2017-10-20  Youenn Fablet  <[email protected]>
 
         ResourceResponse should have a ServiceWorker source

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate.h (223789 => 223790)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate.h	2017-10-20 20:34:27 UTC (rev 223789)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate.h	2017-10-20 20:38:41 UTC (rev 223790)
@@ -41,6 +41,10 @@
 - (void)_downloadDidFinish:(_WKDownload *)download;
 - (void)_download:(_WKDownload *)download didFailWithError:(NSError *)error;
 - (void)_downloadDidCancel:(_WKDownload *)download;
+- (void)_download:(_WKDownload *)download didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential*))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_download:(_WKDownload *)download didCreateDestination:(NSString *)destination WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_downloadProcessDidCrash:(_WKDownload *)download WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (BOOL)_download:(_WKDownload *)download shouldDecodeSourceDataOfMIMEType:(NSString *)MIMEType WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 - (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));
 @end

Modified: trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h (223789 => 223790)


--- trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h	2017-10-20 20:34:27 UTC (rev 223789)
+++ trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.h	2017-10-20 20:38:41 UTC (rev 223790)
@@ -55,6 +55,12 @@
     void didFail(WebProcessPool&, DownloadProxy&, const WebCore::ResourceError&) final;
     void didCancel(WebProcessPool&, DownloadProxy&) final;
     void willSendRequest(WebProcessPool&, DownloadProxy&, WebCore::ResourceRequest&&, const WebCore::ResourceResponse&, Function<void(WebCore::ResourceRequest&&)>&&) final;
+    void didReceiveAuthenticationChallenge(WebProcessPool&, DownloadProxy&, AuthenticationChallengeProxy&) final;
+#if !USE(NETWORK_SESSION)
+    bool shouldDecodeSourceDataOfMIMEType(WebProcessPool&, DownloadProxy&, const String&) final;
+#endif
+    void didCreateDestination(WebProcessPool&, DownloadProxy&, const String&) final;
+    void processDidCrash(WebProcessPool&, DownloadProxy&) final;
 
     WeakObjCPtr<id <_WKDownloadDelegate>> m_delegate;
 
@@ -68,6 +74,10 @@
         bool downloadDidFail : 1;
         bool downloadDidCancel : 1;
         bool downloadDidReceiveServerRedirectToURL : 1;
+        bool downloadDidReceiveAuthenticationChallengeCompletionHandler : 1;
+        bool downloadShouldDecodeSourceDataOfMIMEType : 1;
+        bool downloadDidCreateDestination : 1;
+        bool downloadProcessDidCrash : 1;
     } m_delegateMethods;
 };
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm (223789 => 223790)


--- trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm	2017-10-20 20:34:27 UTC (rev 223789)
+++ trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm	2017-10-20 20:38:41 UTC (rev 223790)
@@ -28,9 +28,13 @@
 
 #if WK_API_ENABLED
 
+#import "AuthenticationChallengeProxy.h"
+#import "AuthenticationDecisionListener.h"
 #import "CompletionHandlerCallChecker.h"
 #import "DownloadProxy.h"
+#import "WKNSURLAuthenticationChallenge.h"
 #import "WKNSURLExtras.h"
+#import "WebCredential.h"
 #import "_WKDownloadDelegate.h"
 #import "_WKDownloadInternal.h"
 #import <WebCore/ResourceError.h>
@@ -57,6 +61,10 @@
     m_delegateMethods.downloadDidFail = [delegate respondsToSelector:@selector(_download:didFailWithError:)];
     m_delegateMethods.downloadDidCancel = [delegate respondsToSelector:@selector(_downloadDidCancel:)];
     m_delegateMethods.downloadDidReceiveServerRedirectToURL = [delegate respondsToSelector:@selector(_download:didReceiveServerRedirectToURL:)];
+    m_delegateMethods.downloadDidReceiveAuthenticationChallengeCompletionHandler = [delegate respondsToSelector:@selector(_download:didReceiveAuthenticationChallenge:completionHandler:)];
+    m_delegateMethods.downloadShouldDecodeSourceDataOfMIMEType = [delegate respondsToSelector:@selector(_download:shouldDecodeSourceDataOfMIMEType:)];
+    m_delegateMethods.downloadDidCreateDestination = [delegate respondsToSelector:@selector(_download:didCreateDestination:)];
+    m_delegateMethods.downloadProcessDidCrash = [delegate respondsToSelector:@selector(_downloadProcessDidCrash:)];
 }
 
 void DownloadClient::didStart(WebProcessPool&, DownloadProxy& downloadProxy)
@@ -77,6 +85,66 @@
         [m_delegate _download:wrapper(downloadProxy) didReceiveData:length];
 }
 
+void DownloadClient::didReceiveAuthenticationChallenge(WebProcessPool&, DownloadProxy& downloadProxy, AuthenticationChallengeProxy& authenticationChallenge)
+{
+    if (!m_delegateMethods.downloadDidReceiveAuthenticationChallengeCompletionHandler) {
+        authenticationChallenge.listener()->performDefaultHandling();
+        return;
+    }
+
+    [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) {
+        if (checker->completionHandlerHasBeenCalled())
+            return;
+        checker->didCallCompletionHandler();
+        switch (disposition) {
+        case NSURLSessionAuthChallengeUseCredential: {
+            RefPtr<WebCredential> webCredential;
+            if (credential)
+                webCredential = WebCredential::create(WebCore::Credential(credential));
+            
+            authenticationChallenge->listener()->useCredential(webCredential.get());
+            break;
+        }
+            
+        case NSURLSessionAuthChallengePerformDefaultHandling:
+            authenticationChallenge->listener()->performDefaultHandling();
+            break;
+            
+        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
+            authenticationChallenge->listener()->cancel();
+            break;
+            
+        case NSURLSessionAuthChallengeRejectProtectionSpace:
+            authenticationChallenge->listener()->rejectProtectionSpaceAndContinue();
+            break;
+            
+        default:
+            [NSException raise:NSInvalidArgumentException format:@"Invalid NSURLSessionAuthChallengeDisposition (%ld)", (long)disposition];
+        }
+    }).get()];
+}
+
+#if !USE(NETWORK_SESSION)
+bool DownloadClient::shouldDecodeSourceDataOfMIMEType(WebProcessPool&, DownloadProxy& downloadProxy, const String& mimeType)
+{
+    if (m_delegateMethods.downloadShouldDecodeSourceDataOfMIMEType)
+        return [m_delegate _download:wrapper(downloadProxy) shouldDecodeSourceDataOfMIMEType:mimeType];
+    return true;
+}
+#endif
+
+void DownloadClient::didCreateDestination(WebProcessPool&, DownloadProxy& downloadProxy, const String& destination)
+{
+    if (m_delegateMethods.downloadDidCreateDestination)
+        [m_delegate _download:wrapper(downloadProxy) didCreateDestination:destination];
+}
+
+void DownloadClient::processDidCrash(WebProcessPool&, DownloadProxy& downloadProxy)
+{
+    if (m_delegateMethods.downloadProcessDidCrash)
+        [m_delegate _downloadProcessDidCrash:wrapper(downloadProxy)];
+}
+
 void DownloadClient::decideDestinationWithSuggestedFilename(WebProcessPool&, DownloadProxy& downloadProxy, const String& filename, Function<void(AllowOverwrite, String)>&& completionHandler)
 {
     if (!m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameAllowOverwrite && !m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameCompletionHandler)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to