Title: [235266] tags/Safari-607.1.3/Source/WebKit
Revision
235266
Author
[email protected]
Date
2018-08-23 18:31:38 -0700 (Thu, 23 Aug 2018)

Log Message

Revert r234941. rdar://problem/43667266

Modified Paths

Diff

Modified: tags/Safari-607.1.3/Source/WebKit/ChangeLog (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/ChangeLog	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/ChangeLog	2018-08-24 01:31:38 UTC (rev 235266)
@@ -1,5 +1,9 @@
 2018-08-23  Kocsen Chung  <[email protected]>
 
+        Revert r234941. rdar://problem/43667266
+
+2018-08-23  Kocsen Chung  <[email protected]>
+
         Revert r234942. rdar://problem/43655048
 
 2018-08-22  Antti Koivisto  <[email protected]>

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -75,6 +75,13 @@
     send(Messages::DownloadProxy::DidCancel({ }));
 }
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+void PendingDownload::canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace& protectionSpace)
+{
+    m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(true);
+}
+#endif
+
 void PendingDownload::didFailLoading(const WebCore::ResourceError& error)
 {
     send(Messages::DownloadProxy::DidFail(error, { }));

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -51,6 +51,9 @@
 private:    
     // NetworkLoadClient.
     void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override { }
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) override;
+#endif
     bool isSynchronous() const override { return false; }
     bool isAllowedToAskUserForCredentials() const final { return m_isAllowedToAskUserForCredentials; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) override;

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -102,7 +102,15 @@
         return;
     }
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    NetworkProcess::singleton().canAuthenticateAgainstProtectionSpace(challenge.protectionSpace(), m_parameters.pageID, m_parameters.frameID, [this, weakThis = makeWeakPtr(this), completionHandler = WTFMove(completionHandler), challenge = WTFMove(challenge)] (bool canAuthenticate) mutable {
+        if (!canAuthenticate)
+            return completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, { });
+        NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.pageID, m_parameters.frameID, challenge, WTFMove(completionHandler));
+    });
+#else
     NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.pageID, m_parameters.frameID, challenge, WTFMove(completionHandler));
+#endif
 }
 
 void NetworkCORSPreflightChecker::didReceiveResponseNetworkSession(WebCore::ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -39,7 +39,7 @@
 
 namespace WebKit {
 
-class NetworkCORSPreflightChecker final : private NetworkDataTaskClient {
+class NetworkCORSPreflightChecker final : private NetworkDataTaskClient, public CanMakeWeakPtr<NetworkCORSPreflightChecker> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     struct Parameters {

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkLoad.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkLoad.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkLoad.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -42,7 +42,6 @@
 
 #if PLATFORM(COCOA)
 #include "NetworkDataTaskCocoa.h"
-#include "NetworkSessionCocoa.h"
 #endif
 
 #if ENABLE(NETWORK_CAPTURE)
@@ -122,6 +121,10 @@
         m_redirectCompletionHandler({ });
     if (m_responseCompletionHandler)
         m_responseCompletionHandler(PolicyAction::Ignore);
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    if (m_challengeCompletionHandler)
+        m_challengeCompletionHandler(AuthenticationChallengeDisposition::Cancel, { });
+#endif
     if (m_task)
         m_task->clearClient();
 }
@@ -253,7 +256,18 @@
 
 void NetworkLoad::didReceiveChallenge(AuthenticationChallenge&& challenge, ChallengeCompletionHandler&& completionHandler)
 {
-    auto scheme = challenge.protectionSpace().authenticationScheme();
+    m_challenge = challenge;
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    m_challengeCompletionHandler = WTFMove(completionHandler);
+    m_client.get().canAuthenticateAgainstProtectionSpaceAsync(challenge.protectionSpace());
+#else
+    completeAuthenticationChallenge(WTFMove(completionHandler));
+#endif
+}
+
+void NetworkLoad::completeAuthenticationChallenge(ChallengeCompletionHandler&& completionHandler)
+{
+    auto scheme = m_challenge->protectionSpace().authenticationScheme();
     bool isTLSHandshake = scheme == ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested
         || scheme == ProtectionSpaceAuthenticationSchemeClientCertificateRequested;
     if (!isAllowedToAskUserForCredentials() && !isTLSHandshake) {
@@ -261,13 +275,36 @@
         completionHandler(AuthenticationChallengeDisposition::UseCredential, { });
         return;
     }
-    
+
+    if (!m_task)
+        return;
     if (auto* pendingDownload = m_task->pendingDownload())
-        NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(*pendingDownload, challenge, WTFMove(completionHandler));
+        NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(*pendingDownload, *m_challenge, WTFMove(completionHandler));
     else
-        NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.webPageID, m_parameters.webFrameID, challenge, WTFMove(completionHandler));
+        NetworkProcess::singleton().authenticationManager().didReceiveAuthenticationChallenge(m_parameters.webPageID, m_parameters.webFrameID, *m_challenge, WTFMove(completionHandler));
 }
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+void NetworkLoad::continueCanAuthenticateAgainstProtectionSpace(bool result)
+{
+    if (!m_challengeCompletionHandler) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+
+    auto completionHandler = std::exchange(m_challengeCompletionHandler, nullptr);
+    if (!result) {
+        if (NetworkSession::allowsSpecificHTTPSCertificateForHost(*m_challenge))
+            completionHandler(AuthenticationChallengeDisposition::UseCredential, serverTrustCredential(*m_challenge));
+        else
+            completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, { });
+        return;
+    }
+
+    completeAuthenticationChallenge(WTFMove(completionHandler));
+}
+#endif
+
 void NetworkLoad::didReceiveResponseNetworkSession(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
 {
     ASSERT(RunLoop::isMain());

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkLoad.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkLoad.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkLoad.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -69,6 +69,10 @@
 
     bool shouldCaptureExtraNetworkLoadMetrics() const final;
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    void continueCanAuthenticateAgainstProtectionSpace(bool);
+#endif
+
     String description() const;
 
 private:
@@ -91,10 +95,16 @@
     void notifyDidReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&);
     void throttleDelayCompleted();
 
+    void completeAuthenticationChallenge(ChallengeCompletionHandler&&);
+
     std::reference_wrapper<NetworkLoadClient> m_client;
     const NetworkLoadParameters m_parameters;
     CompletionHandler<void(WebCore::ResourceRequest&&)> m_redirectCompletionHandler;
     RefPtr<NetworkDataTask> m_task;
+    std::optional<WebCore::AuthenticationChallenge> m_challenge;
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    ChallengeCompletionHandler m_challengeCompletionHandler;
+#endif
     ResponseCompletionHandler m_responseCompletionHandler;
     
     struct Throttle;

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkLoadClient.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkLoadClient.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkLoadClient.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -47,6 +47,9 @@
     virtual bool isAllowedToAskUserForCredentials() const = 0;
 
     virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) = 0;
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    virtual void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) = 0;
+#endif
     virtual void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) = 0;
     enum class ShouldContinueDidReceiveResponse { No, Yes };
     virtual ShouldContinueDidReceiveResponse didReceiveResponse(WebCore::ResourceResponse&&) = 0;

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkProcess.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -677,7 +677,27 @@
 {
     downloadManager().cancelDownload(downloadID);
 }
+    
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+void NetworkProcess::canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace& protectionSpace, uint64_t pageID, uint64_t frameID, CompletionHandler<void(bool)>&& completionHandler)
+{
+    static uint64_t lastCompletionHandlerID = 0;
+    uint64_t completionHandlerID = ++lastCompletionHandlerID;
+    m_canAuthenticateAgainstProtectionSpaceCompletionHandlers.add(completionHandlerID, WTFMove(completionHandler));
+    parentProcessConnection()->send(Messages::NetworkProcessProxy::CanAuthenticateAgainstProtectionSpace(completionHandlerID, pageID, frameID, protectionSpace), 0);
+}
 
+void NetworkProcess::continueCanAuthenticateAgainstProtectionSpace(uint64_t completionHandlerID, bool canAuthenticate)
+{
+    if (auto completionHandler = m_canAuthenticateAgainstProtectionSpaceCompletionHandlers.take(completionHandlerID)) {
+        completionHandler(canAuthenticate);
+        return;
+    }
+    ASSERT_NOT_REACHED();
+}
+
+#endif
+
 void NetworkProcess::continueWillSendRequest(DownloadID downloadID, WebCore::ResourceRequest&& request)
 {
     downloadManager().continueWillSendRequest(downloadID, WTFMove(request));

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkProcess.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkProcess.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkProcess.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -126,6 +126,10 @@
 
     void findPendingDownloadLocation(NetworkDataTask&, ResponseCompletionHandler&&, const WebCore::ResourceResponse&);
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    void canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace&, uint64_t pageID, uint64_t frameID, CompletionHandler<void(bool)>&&);
+#endif
+
     void prefetchDNS(const String&);
 
     void addWebsiteDataStore(WebsiteDataStoreParameters&&);
@@ -221,6 +225,9 @@
     void downloadRequest(PAL::SessionID, DownloadID, const WebCore::ResourceRequest&, const String& suggestedFilename);
     void resumeDownload(PAL::SessionID, DownloadID, const IPC::DataReference& resumeData, const String& path, SandboxExtension::Handle&&);
     void cancelDownload(DownloadID);
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    void continueCanAuthenticateAgainstProtectionSpace(uint64_t completionHandlerID, bool canAuthenticate);
+#endif
     void continueWillSendRequest(DownloadID, WebCore::ResourceRequest&&);
     void continueDecidePendingDownloadDestination(DownloadID, String destination, SandboxExtension::Handle&&, bool allowOverwrite);
 
@@ -279,6 +286,9 @@
     NetworkProcessSupplementMap m_supplements;
 
     HashMap<uint64_t, Function<void()>> m_sandboxExtensionForBlobsCompletionHandlers;
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    HashMap<uint64_t, CompletionHandler<void(bool)>> m_canAuthenticateAgainstProtectionSpaceCompletionHandlers;
+#endif
     HashSet<PAL::SessionID> m_sessionsControlledByAutomation;
 
     HashMap<PAL::SessionID, Vector<CacheStorageParametersCallback>> m_cacheStorageParametersCallbacks;

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2018-08-24 01:31:38 UTC (rev 235266)
@@ -46,6 +46,9 @@
     ResumeDownload(PAL::SessionID sessionID, WebKit::DownloadID downloadID, IPC::DataReference resumeData, String path, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
     CancelDownload(WebKit::DownloadID downloadID)
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    ContinueCanAuthenticateAgainstProtectionSpace(uint64_t loaderID, bool canAuthenticate)
+#endif
     ContinueWillSendRequest(WebKit::DownloadID downloadID, WebCore::ResourceRequest request)
     ContinueDecidePendingDownloadDestination(WebKit::DownloadID downloadID, String destination, WebKit::SandboxExtension::Handle sandboxExtensionHandle, bool allowOverwrite)
 

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -934,6 +934,16 @@
     m_fileReferences.clear();
 }
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+void NetworkResourceLoader::canAuthenticateAgainstProtectionSpaceAsync(const ProtectionSpace& protectionSpace)
+{
+    NetworkProcess::singleton().canAuthenticateAgainstProtectionSpace(protectionSpace, pageID(), frameID(), [this, protectedThis = makeRef(*this)] (bool result) {
+        if (m_networkLoad)
+            m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(result);
+    });
+}
+#endif
+
 bool NetworkResourceLoader::isAlwaysOnLoggingAllowed() const
 {
     if (NetworkProcess::singleton().sessionIsControlledByAutomation(sessionID()))

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkResourceLoader.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkResourceLoader.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/NetworkResourceLoader.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -94,6 +94,9 @@
 
     // NetworkLoadClient.
     void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) override;
+#endif
     bool isSynchronous() const override;
     bool isAllowedToAskUserForCredentials() const override { return m_isAllowedToAskUserForCredentials; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&&) override;

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/PreconnectTask.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/PreconnectTask.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/PreconnectTask.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -96,6 +96,19 @@
     ASSERT_NOT_REACHED();
 }
 
+void PreconnectTask::canAuthenticateAgainstProtectionSpaceAsync(const ProtectionSpace& protectionSpace)
+{
+    if (!pageID()) {
+        // The preconnect was started by the UIProcess.
+        m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(false);
+        return;
+    }
+    NetworkProcess::singleton().canAuthenticateAgainstProtectionSpace(protectionSpace, pageID(), frameID(), [weakThis = makeWeakPtr(this)] (bool result) {
+        if (weakThis)
+            weakThis->m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(result);
+    });
+}
+
 void PreconnectTask::didFinish(const ResourceError& error)
 {
     if (m_completionHandler)

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/PreconnectTask.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/PreconnectTask.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/PreconnectTask.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -37,7 +37,7 @@
 class NetworkLoad;
 class NetworkLoadParameters;
 
-class PreconnectTask final : public NetworkLoadClient {
+class PreconnectTask final : public NetworkLoadClient, public CanMakeWeakPtr<PreconnectTask> {
 public:
     explicit PreconnectTask(NetworkLoadParameters&&, WTF::CompletionHandler<void(const WebCore::ResourceError&)>&& completionHandler = { });
     ~PreconnectTask();
@@ -50,6 +50,7 @@
     bool isSynchronous() const final { return false; }
     bool isAllowedToAskUserForCredentials() const final { return false; }
     void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) final;
+    void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) final;
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) final;
     ShouldContinueDidReceiveResponse didReceiveResponse(WebCore::ResourceResponse&&) final;
     void didReceiveBuffer(Ref<WebCore::SharedBuffer>&&, int reportedEncodedDataLength) final;

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -122,6 +122,13 @@
     didComplete();
 }
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+void SpeculativeLoad::canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&)
+{
+    m_networkLoad->continueCanAuthenticateAgainstProtectionSpace(false);
+}
+#endif
+
 void SpeculativeLoad::didFailLoading(const ResourceError&)
 {
     if (m_didComplete)

Modified: tags/Safari-607.1.3/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -53,6 +53,9 @@
 private:
     // NetworkLoadClient.
     void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override { }
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    void canAuthenticateAgainstProtectionSpaceAsync(const WebCore::ProtectionSpace&) override;
+#endif
     bool isSynchronous() const override { return false; }
     bool isAllowedToAskUserForCredentials() const final { return false; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) override;

Modified: tags/Safari-607.1.3/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -111,8 +111,8 @@
 
 void AuthenticationManager::didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const AuthenticationChallenge& authenticationChallenge, ChallengeCompletionHandler&& completionHandler)
 {
-    if (!pageID || !frameID) // Initiated by SpeculativeLoadManager
-        return completionHandler(AuthenticationChallengeDisposition::RejectProtectionSpace, { });
+    ASSERT(pageID);
+    ASSERT(frameID);
 
     uint64_t challengeID = addChallengeToChallengeMap({ pageID, authenticationChallenge, WTFMove(completionHandler) });
 

Modified: tags/Safari-607.1.3/Source/WebKit/Shared/Authentication/AuthenticationManager.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/Shared/Authentication/AuthenticationManager.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/Shared/Authentication/AuthenticationManager.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -68,6 +68,9 @@
 
     void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
     void didReceiveAuthenticationChallenge(IPC::MessageSender& download, const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&&);
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    void continueCanAuthenticateAgainstProtectionSpace(DownloadID, bool canAuthenticate);
+#endif
 
     void useCredentialForChallenge(uint64_t challengeID, const WebCore::Credential&);
     void continueWithoutCredentialForChallenge(uint64_t challengeID);

Modified: tags/Safari-607.1.3/Source/WebKit/UIProcess/API/C/WKPage.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -2318,10 +2318,8 @@
         
         void didReceiveAuthenticationChallenge(WebPageProxy& page, AuthenticationChallengeProxy& authenticationChallenge) override
         {
-            if (m_client.canAuthenticateAgainstProtectionSpace && !m_client.canAuthenticateAgainstProtectionSpace(toAPI(&page), toAPI(authenticationChallenge.protectionSpace()), m_client.base.clientInfo))
-                return authenticationChallenge.rejectProtectionSpaceAndContinue();
             if (!m_client.didReceiveAuthenticationChallenge)
-                return authenticationChallenge.rejectProtectionSpaceAndContinue();
+                return;
             m_client.didReceiveAuthenticationChallenge(toAPI(&page), toAPI(&authenticationChallenge), m_client.base.clientInfo);
         }
 

Modified: tags/Safari-607.1.3/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -75,6 +75,8 @@
 
 - (void)_webView:(WKWebView *)webView renderingProgressDidChange:(_WKRenderingProgressEvents)progressEvents;
 
+- (void)_webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge WK_API_DEPRECATED_WITH_REPLACEMENT("webView:didReceiveAuthenticationChallenge:completionHandler:", macosx(10.10, 10.13.4), ios(8.0, 11.3));
+
 - (void)_webViewWebProcessDidCrash:(WKWebView *)webView;
 - (void)_webViewWebProcessDidBecomeResponsive:(WKWebView *)webView;
 - (void)_webViewWebProcessDidBecomeUnresponsive:(WKWebView *)webView;

Modified: tags/Safari-607.1.3/Source/WebKit/UIProcess/Cocoa/NavigationState.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -108,6 +108,7 @@
 
         void renderingProgressDidChange(WebPageProxy&, WebCore::LayoutMilestones) override;
 
+        bool canAuthenticateAgainstProtectionSpace(WebPageProxy&, WebProtectionSpace*) override;
         void didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy&) override;
         bool processDidTerminate(WebPageProxy&, ProcessTerminationReason) override;
         void processDidBecomeResponsive(WebPageProxy&) override;
@@ -206,6 +207,7 @@
         bool webViewDidReceiveAuthenticationChallengeCompletionHandler : 1;
         bool webViewWebContentProcessDidTerminate : 1;
         bool webViewWebContentProcessDidTerminateWithReason : 1;
+        bool webViewDidReceiveAuthenticationChallenge : 1;
         bool webViewWebProcessDidCrash : 1;
         bool webViewWebProcessDidBecomeResponsive : 1;
         bool webViewWebProcessDidBecomeUnresponsive : 1;

Modified: tags/Safari-607.1.3/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2018-08-24 01:31:38 UTC (rev 235266)
@@ -164,6 +164,7 @@
     m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler = [delegate respondsToSelector:@selector(webView:didReceiveAuthenticationChallenge:completionHandler:)];
     m_navigationDelegateMethods.webViewWebContentProcessDidTerminate = [delegate respondsToSelector:@selector(webViewWebContentProcessDidTerminate:)];
     m_navigationDelegateMethods.webViewWebContentProcessDidTerminateWithReason = [delegate respondsToSelector:@selector(_webView:webContentProcessDidTerminateWithReason:)];
+    m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallenge = [delegate respondsToSelector:@selector(_webView:didReceiveAuthenticationChallenge:)];
     m_navigationDelegateMethods.webViewWebProcessDidCrash = [delegate respondsToSelector:@selector(_webViewWebProcessDidCrash:)];
     m_navigationDelegateMethods.webViewWebProcessDidBecomeResponsive = [delegate respondsToSelector:@selector(_webViewWebProcessDidBecomeResponsive:)];
     m_navigationDelegateMethods.webViewWebProcessDidBecomeUnresponsive = [delegate respondsToSelector:@selector(_webViewWebProcessDidBecomeUnresponsive:)];
@@ -845,47 +846,66 @@
     [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView renderingProgressDidChange:renderingProgressEvents(layoutMilestones)];
 }
 
+bool NavigationState::NavigationClient::canAuthenticateAgainstProtectionSpace(WebPageProxy&, WebProtectionSpace* protectionSpace)
+{
+    return !!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler;
+}
+
 void NavigationState::NavigationClient::didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy& authenticationChallenge)
 {
-    if (!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler)
-        return authenticationChallenge.rejectProtectionSpaceAndContinue();
+    if (m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler) {
+        auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+        if (!navigationDelegate) {
+            authenticationChallenge.listener()->performDefaultHandling();
+            return;
+        }
 
-    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
-    if (!navigationDelegate)
-        return authenticationChallenge.performDefaultHandling();
+        auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:didReceiveAuthenticationChallenge:completionHandler:));
+        [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) webView:m_navigationState.m_webView didReceiveAuthenticationChallenge:wrapper(authenticationChallenge) completionHandler:BlockPtr<void(NSURLSessionAuthChallengeDisposition, NSURLCredential *)>::fromCallable([challenge = makeRef(authenticationChallenge), checker = WTFMove(checker)](NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential) {
+            if (checker->completionHandlerHasBeenCalled())
+                return;
+            checker->didCallCompletionHandler();
 
-    auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:didReceiveAuthenticationChallenge:completionHandler:));
-    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) webView:m_navigationState.m_webView didReceiveAuthenticationChallenge:wrapper(authenticationChallenge) completionHandler:BlockPtr<void(NSURLSessionAuthChallengeDisposition, NSURLCredential *)>::fromCallable([challenge = makeRef(authenticationChallenge), checker = WTFMove(checker)](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));
 
-        switch (disposition) {
-        case NSURLSessionAuthChallengeUseCredential: {
-            RefPtr<WebCredential> webCredential;
-            if (credential)
-                webCredential = WebCredential::create(WebCore::Credential(credential));
+                challenge->listener()->useCredential(webCredential.get());
+                break;
+            }
 
-            challenge->useCredential(webCredential.get());
-            break;
-        }
+            case NSURLSessionAuthChallengePerformDefaultHandling:
+                challenge->listener()->performDefaultHandling();
+                break;
 
-        case NSURLSessionAuthChallengePerformDefaultHandling:
-            challenge->performDefaultHandling();
-            break;
+            case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
+                challenge->listener()->cancel();
+                break;
 
-        case NSURLSessionAuthChallengeCancelAuthenticationChallenge:
-            challenge->cancel();
-            break;
+            case NSURLSessionAuthChallengeRejectProtectionSpace:
+                challenge->listener()->rejectProtectionSpaceAndContinue();
+                break;
 
-        case NSURLSessionAuthChallengeRejectProtectionSpace:
-            challenge->rejectProtectionSpaceAndContinue();
-            break;
+            default:
+                [NSException raise:NSInvalidArgumentException format:@"Invalid NSURLSessionAuthChallengeDisposition (%ld)", (long)disposition];
+            }
+        }).get()];
+        return;
+    }
 
-        default:
-            [NSException raise:NSInvalidArgumentException format:@"Invalid NSURLSessionAuthChallengeDisposition (%ld)", (long)disposition];
-        }
-    }).get()];
+    if (!m_navigationState.m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallenge)
+        return;
+
+    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return;
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didReceiveAuthenticationChallenge:wrapper(authenticationChallenge)];
+#pragma clang diagnostic pop
 }
 
 static _WKProcessTerminationReason wkProcessTerminationReason(ProcessTerminationReason reason)

Modified: tags/Safari-607.1.3/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -399,6 +399,30 @@
     page->logDiagnosticMessageWithValue(message, description, value, significantFigures, shouldSample);
 }
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+void NetworkProcessProxy::canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t pageID, uint64_t frameID, const WebCore::ProtectionSpace& protectionSpace)
+{
+    // NetworkProcess state cannot asynchronously be kept in sync with these objects
+    // like we expect WebProcess <-> UIProcess state to be kept in sync.
+    // So there's no guarantee the messaged WebPageProxy or WebFrameProxy exist here in the UIProcess.
+    // We need to validate both the page and the frame up front.
+    if (auto* page = WebProcessProxy::webPage(pageID)) {
+        if (page->process().webFrame(frameID)) {
+            page->canAuthenticateAgainstProtectionSpace(loaderID, frameID, protectionSpace);
+            return;
+        }
+#if ENABLE(SERVICE_WORKER)
+    } else if (m_processPool.serviceWorkerProcessProxyFromPageID(pageID)) {
+        send(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpace(loaderID, true), 0);
+        return;
+#endif
+    }
+    // In the case where we will not be able to reply to this message with a client reply,
+    // we should message back a default to the Networking process.
+    send(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpace(loaderID, false), 0);
+}
+#endif
+
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
 void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
 {

Modified: tags/Safari-607.1.3/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -143,6 +143,9 @@
     void logDiagnosticMessage(uint64_t pageID, const String& message, const String& description, WebCore::ShouldSample);
     void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample);
     void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample);
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    void canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t pageID, uint64_t frameID, const WebCore::ProtectionSpace&);
+#endif
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     void didUpdateBlockCookies(uint64_t contextId);
     void storageAccessRequestResult(bool wasGranted, uint64_t contextId);

Modified: tags/Safari-607.1.3/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2018-08-24 01:31:38 UTC (rev 235266)
@@ -43,6 +43,9 @@
     LogDiagnosticMessageWithResult(uint64_t pageID, String message, String description, uint32_t result, enum WebCore::ShouldSample shouldSample)
     LogDiagnosticMessageWithValue(uint64_t pageID, String message, String description, double value, unsigned significantFigures, enum WebCore::ShouldSample shouldSample)
 
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    CanAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t pageID, uint64_t frameID, WebCore::ProtectionSpace protectionSpace)
+#endif
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
     DidUpdateBlockCookies(uint64_t callbackId)
     StorageAccessRequestResult(bool wasGranted, uint64_t contextId)

Modified: tags/Safari-607.1.3/Source/WebKit/UIProcess/WebPageProxy.cpp (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-08-24 01:31:38 UTC (rev 235266)
@@ -6335,6 +6335,24 @@
 
 #endif
 
+void WebPageProxy::canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t frameID, const ProtectionSpace& coreProtectionSpace)
+{
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+    WebFrameProxy* frame = m_process->webFrame(frameID);
+    MESSAGE_CHECK(frame);
+
+    RefPtr<WebProtectionSpace> protectionSpace = WebProtectionSpace::create(coreProtectionSpace);
+
+    bool canAuthenticate;
+    if (m_navigationClient)
+        canAuthenticate = m_navigationClient->canAuthenticateAgainstProtectionSpace(*this, protectionSpace.get());
+    else
+        canAuthenticate = m_loaderClient->canAuthenticateAgainstProtectionSpaceInFrame(*this, *frame, protectionSpace.get());
+
+    m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpace(loaderID, canAuthenticate));
+#endif
+}
+
 void WebPageProxy::didReceiveAuthenticationChallengeProxy(uint64_t frameID, Ref<AuthenticationChallengeProxy>&& authenticationChallenge)
 {
     WebFrameProxy* frame = m_process->webFrame(frameID);

Modified: tags/Safari-607.1.3/Source/WebKit/UIProcess/WebPageProxy.h (235265 => 235266)


--- tags/Safari-607.1.3/Source/WebKit/UIProcess/WebPageProxy.h	2018-08-24 00:59:11 UTC (rev 235265)
+++ tags/Safari-607.1.3/Source/WebKit/UIProcess/WebPageProxy.h	2018-08-24 01:31:38 UTC (rev 235266)
@@ -1284,6 +1284,8 @@
 
     bool isAlwaysOnLoggingAllowed() const;
 
+    void canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t frameID, const WebCore::ProtectionSpace&);
+
 #if ENABLE(GAMEPAD)
     void gamepadActivity(const Vector<GamepadData>&, bool shouldMakeGamepadsVisible);
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to