Title: [291678] branches/safari-613-branch/Source
Revision
291678
Author
alanc...@apple.com
Date
2022-03-22 11:27:34 -0700 (Tue, 22 Mar 2022)

Log Message

Cherry-pick r289018. rdar://problem/89972004

This reverts r289843.

Modified Paths

Added Paths

Diff

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (291677 => 291678)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-22 18:27:34 UTC (rev 291678)
@@ -5078,10 +5078,6 @@
             * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
             (WebCore::MediaPlayerPrivateAVFoundationObjC::getStartDate const):
 
-2022-02-15  Russell Epstein  <repst...@apple.com>
-
-        Revert r289340. rdar://problem/88629773
-
 2022-02-14  Russell Epstein  <repst...@apple.com>
 
         Cherry-pick r289686. rdar://problem/88689388

Modified: branches/safari-613-branch/Source/WebCore/PAL/ChangeLog (291677 => 291678)


--- branches/safari-613-branch/Source/WebCore/PAL/ChangeLog	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebCore/PAL/ChangeLog	2022-03-22 18:27:34 UTC (rev 291678)
@@ -1,7 +1,3 @@
-2022-02-15  Russell Epstein  <repst...@apple.com>
-
-        Revert r289340. rdar://problem/88629773
-
 2022-02-07  Russell Epstein  <repst...@apple.com>
 
         Cherry-pick r289018. rdar://problem/87358372

Modified: branches/safari-613-branch/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -202,6 +202,9 @@
 - (BOOL)_schemeWasUpgradedDueToDynamicHSTS;
 - (BOOL)_preventHSTSStorage;
 - (BOOL)_ignoreHSTS;
+#if HAVE(NETWORK_CONNECTION_PRIVACY_STANCE)
+@property (setter=_setPrivacyProxyFailClosed:) BOOL _privacyProxyFailClosed;
+#endif
 @end
 
 @interface NSURLResponse ()

Modified: branches/safari-613-branch/Source/WebCore/loader/DocumentLoader.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebCore/loader/DocumentLoader.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebCore/loader/DocumentLoader.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -298,6 +298,9 @@
     void setDefersLoading(bool);
     void setMainResourceDataBufferingPolicy(DataBufferingPolicy);
 
+    void setMainResourceWasPrivateRelayed(bool privateRelayed) { m_mainResourceWasPrivateRelayed = privateRelayed; }
+    bool mainResourceWasPrivateRelayed() const { return m_mainResourceWasPrivateRelayed; }
+
     void startLoadingMainResource();
     WEBCORE_EXPORT void cancelMainResourceLoad(const ResourceError&);
     void willContinueMainResourceLoadAfterRedirect(const ResourceRequest&);
@@ -699,6 +702,7 @@
     bool m_allowsDataURLsForMainFrame { false };
 
     bool m_lastNavigationWasAppInitiated { true };
+    bool m_mainResourceWasPrivateRelayed { false };
 };
 
 inline void DocumentLoader::recordMemoryCacheLoadForFutureClientNotification(const ResourceRequest& request)

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-03-22 18:27:34 UTC (rev 291678)
@@ -1902,10 +1902,6 @@
 
 2022-02-15  Russell Epstein  <repst...@apple.com>
 
-        Revert r289340. rdar://problem/88629773
-
-2022-02-15  Russell Epstein  <repst...@apple.com>
-
         Revert r289343. rdar://problem/88629773
 
 2022-02-14  Russell Epstein  <repst...@apple.com>

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -104,7 +104,7 @@
     return m_parentProcessConnection.get();
 }
 
-void PendingDownload::didReceiveResponse(WebCore::ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
+void PendingDownload::didReceiveResponse(WebCore::ResourceResponse&& response, PrivateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     completionHandler(WebCore::PolicyAction::Download);
 }

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -67,7 +67,7 @@
     bool isSynchronous() const override { return false; }
     bool isAllowedToAskUserForCredentials() const final { return m_isAllowedToAskUserForCredentials; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) override;
-    void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) override;
+    void didReceiveResponse(WebCore::ResourceResponse&&, PrivateRelayed, ResponseCompletionHandler&&) override;
     void didReceiveBuffer(const WebCore::FragmentedSharedBuffer&, int reportedEncodedDataLength) override { };
     void didFinishLoading(const WebCore::NetworkLoadMetrics&) override { };
     void didFailLoading(const WebCore::ResourceError&) override;

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -109,7 +109,7 @@
     m_networkProcess->authenticationManager().didReceiveAuthenticationChallenge(m_parameters.sessionID, m_parameters.webPageProxyID, m_parameters.topOrigin ? &m_parameters.topOrigin->data() : nullptr, challenge, negotiatedLegacyTLS, WTFMove(completionHandler));
 }
 
-void NetworkCORSPreflightChecker::didReceiveResponse(WebCore::ResourceResponse&& response, NegotiatedLegacyTLS, ResponseCompletionHandler&& completionHandler)
+void NetworkCORSPreflightChecker::didReceiveResponse(WebCore::ResourceResponse&& response, NegotiatedLegacyTLS, PrivateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     CORS_CHECKER_RELEASE_LOG("didReceiveResponse");
 

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -71,7 +71,7 @@
 private:
     void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler&&) final;
     void didReceiveChallenge(WebCore::AuthenticationChallenge&&, NegotiatedLegacyTLS, ChallengeCompletionHandler&&) final;
-    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, ResponseCompletionHandler&&) final;
+    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, PrivateRelayed, ResponseCompletionHandler&&) final;
     void didReceiveData(const WebCore::SharedBuffer&) final;
     void didCompleteWithError(const WebCore::ResourceError&, const WebCore::NetworkLoadMetrics&) final;
     void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) final;

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkDataTask.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkDataTask.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkDataTask.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -122,7 +122,7 @@
     });
 }
 
-void NetworkDataTask::didReceiveResponse(ResourceResponse&& response, NegotiatedLegacyTLS negotiatedLegacyTLS, ResponseCompletionHandler&& completionHandler)
+void NetworkDataTask::didReceiveResponse(ResourceResponse&& response, NegotiatedLegacyTLS negotiatedLegacyTLS, PrivateRelayed privateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     if (response.isHTTP09()) {
         auto url = ""
@@ -141,7 +141,7 @@
         response.setUsedLegacyTLS(UsedLegacyTLS::Yes);
 
     if (m_client)
-        m_client->didReceiveResponse(WTFMove(response), negotiatedLegacyTLS, WTFMove(completionHandler));
+        m_client->didReceiveResponse(WTFMove(response), negotiatedLegacyTLS, privateRelayed, WTFMove(completionHandler));
     else
         completionHandler(PolicyAction::Ignore);
 }

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkDataTask.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkDataTask.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkDataTask.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -53,6 +53,7 @@
 class PendingDownload;
 enum class AuthenticationChallengeDisposition : uint8_t;
 enum class NegotiatedLegacyTLS : bool;
+enum class PrivateRelayed : bool;
 
 using RedirectCompletionHandler = CompletionHandler<void(WebCore::ResourceRequest&&)>;
 using ChallengeCompletionHandler = CompletionHandler<void(AuthenticationChallengeDisposition, const WebCore::Credential&)>;
@@ -62,7 +63,7 @@
 public:
     virtual void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler&&) = 0;
     virtual void didReceiveChallenge(WebCore::AuthenticationChallenge&&, NegotiatedLegacyTLS, ChallengeCompletionHandler&&) = 0;
-    virtual void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, ResponseCompletionHandler&&) = 0;
+    virtual void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, PrivateRelayed, ResponseCompletionHandler&&) = 0;
     virtual void didReceiveData(const WebCore::SharedBuffer&) = 0;
     virtual void didCompleteWithError(const WebCore::ResourceError&, const WebCore::NetworkLoadMetrics&) = 0;
     virtual void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) = 0;
@@ -94,7 +95,7 @@
     virtual void resume() = 0;
     virtual void invalidateAndCancel() = 0;
 
-    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, ResponseCompletionHandler&&);
+    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, PrivateRelayed, ResponseCompletionHandler&&);
     bool shouldCaptureExtraNetworkLoadMetrics() const;
 
     enum class State {

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkDataTaskBlob.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -38,6 +38,7 @@
 #include "Logging.h"
 #include "NetworkProcess.h"
 #include "NetworkSession.h"
+#include "PrivateRelayed.h"
 #include "WebErrors.h"
 #include <WebCore/AsyncFileStream.h>
 #include <WebCore/BlobRegistryImpl.h>
@@ -290,7 +291,7 @@
         break;
     }
 
-    didReceiveResponse(WTFMove(response), NegotiatedLegacyTLS::No, [this, protectedThis = WTFMove(protectedThis), errorCode](PolicyAction policyAction) {
+    didReceiveResponse(WTFMove(response), NegotiatedLegacyTLS::No, PrivateRelayed::No, [this, protectedThis = WTFMove(protectedThis), errorCode](PolicyAction policyAction) {
         LOG(NetworkSession, "%p - NetworkDataTaskBlob::didReceiveResponse completionHandler (%u)", this, static_cast<unsigned>(policyAction));
 
         if (m_state == State::Canceling || m_state == State::Completed) {

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoad.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoad.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoad.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -229,7 +229,7 @@
         m_networkProcess->authenticationManager().didReceiveAuthenticationChallenge(m_task->sessionID(), m_parameters.webPageProxyID, m_parameters.topOrigin ? &m_parameters.topOrigin->data() : nullptr, challenge, negotiatedLegacyTLS, WTFMove(completionHandler));
 }
 
-void NetworkLoad::didReceiveResponse(ResourceResponse&& response, NegotiatedLegacyTLS negotiatedLegacyTLS, ResponseCompletionHandler&& completionHandler)
+void NetworkLoad::didReceiveResponse(ResourceResponse&& response, NegotiatedLegacyTLS negotiatedLegacyTLS, PrivateRelayed privateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
@@ -241,10 +241,10 @@
     if (negotiatedLegacyTLS == NegotiatedLegacyTLS::Yes)
         m_networkProcess->authenticationManager().negotiatedLegacyTLS(m_parameters.webPageProxyID);
     
-    notifyDidReceiveResponse(WTFMove(response), negotiatedLegacyTLS, WTFMove(completionHandler));
+    notifyDidReceiveResponse(WTFMove(response), negotiatedLegacyTLS, privateRelayed, WTFMove(completionHandler));
 }
 
-void NetworkLoad::notifyDidReceiveResponse(ResourceResponse&& response, NegotiatedLegacyTLS negotiatedLegacyTLS, ResponseCompletionHandler&& completionHandler)
+void NetworkLoad::notifyDidReceiveResponse(ResourceResponse&& response, NegotiatedLegacyTLS, PrivateRelayed privateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
@@ -251,7 +251,7 @@
     if (m_parameters.needsCertificateInfo)
         response.includeCertificateInfo();
 
-    m_client.get().didReceiveResponse(WTFMove(response), WTFMove(completionHandler));
+    m_client.get().didReceiveResponse(WTFMove(response), privateRelayed, WTFMove(completionHandler));
 }
 
 void NetworkLoad::didReceiveData(const WebCore::SharedBuffer& buffer)

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoad.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoad.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoad.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -80,7 +80,7 @@
     // NetworkDataTaskClient
     void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler&&) final;
     void didReceiveChallenge(WebCore::AuthenticationChallenge&&, NegotiatedLegacyTLS, ChallengeCompletionHandler&&) final;
-    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, ResponseCompletionHandler&&) final;
+    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, PrivateRelayed, ResponseCompletionHandler&&) final;
     void didReceiveData(const WebCore::SharedBuffer&) final;
     void didCompleteWithError(const WebCore::ResourceError&, const WebCore::NetworkLoadMetrics&) final;
     void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) final;
@@ -90,7 +90,7 @@
     void wasBlockedByDisabledFTP() final;
     void didNegotiateModernTLS(const URL&) final;
 
-    void notifyDidReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, ResponseCompletionHandler&&);
+    void notifyDidReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, PrivateRelayed, ResponseCompletionHandler&&);
 
     std::reference_wrapper<NetworkLoadClient> m_client;
     Ref<NetworkProcess> m_networkProcess;

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoadClient.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoadClient.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoadClient.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -38,6 +38,7 @@
 
 namespace WebKit {
 
+enum class PrivateRelayed : bool;
 using ResponseCompletionHandler = CompletionHandler<void(WebCore::PolicyAction)>;
 
 class NetworkLoadClient {
@@ -50,7 +51,7 @@
 
     virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) = 0;
     virtual void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) = 0;
-    virtual void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) = 0;
+    virtual void didReceiveResponse(WebCore::ResourceResponse&&, PrivateRelayed, ResponseCompletionHandler&&) = 0;
     virtual void didReceiveBuffer(const WebCore::FragmentedSharedBuffer&, int reportedEncodedDataLength) = 0;
     virtual void didFinishLoading(const WebCore::NetworkLoadMetrics&) = 0;
     virtual void didFailLoading(const WebCore::ResourceError&) = 0;

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoadParameters.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoadParameters.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkLoadParameters.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -67,6 +67,7 @@
     PreconnectOnly shouldPreconnectOnly { PreconnectOnly::No };
     std::optional<NetworkActivityTracker> networkActivityTracker;
     std::optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain { NavigatingToAppBoundDomain::No };
+    bool mainResourceWasPrivateRelayed { false };
 };
 
 } // namespace WebKit

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -137,6 +137,7 @@
 #endif
     
     encoder << isNavigatingToAppBoundDomain;
+    encoder << mainResourceWasPrivateRelayed;
 }
 
 std::optional<NetworkResourceLoadParameters> NetworkResourceLoadParameters::decode(IPC::Decoder& decoder)
@@ -388,6 +389,12 @@
         return std::nullopt;
     result.isNavigatingToAppBoundDomain = *isNavigatingToAppBoundDomain;
     
+    std::optional<bool> mainResourceWasPrivateRelayed;
+    decoder >> mainResourceWasPrivateRelayed;
+    if (!mainResourceWasPrivateRelayed)
+        return std::nullopt;
+    result.mainResourceWasPrivateRelayed = *mainResourceWasPrivateRelayed;
+
     return result;
 }
     

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -38,6 +38,7 @@
 #include "NetworkProcessConnectionMessages.h"
 #include "NetworkProcessProxyMessages.h"
 #include "NetworkSession.h"
+#include "PrivateRelayed.h"
 #include "ResourceLoadInfo.h"
 #include "ServiceWorkerFetchTask.h"
 #include "WebCoreArgumentCoders.h"
@@ -547,7 +548,7 @@
     ASSERT(m_responseCompletionHandler || m_cacheEntryWaitingForContinueDidReceiveResponse);
 #endif
     bool willWaitForContinueDidReceiveResponse = true;
-    send(Messages::WebResourceLoader::DidReceiveResponse { m_response, willWaitForContinueDidReceiveResponse });
+    send(Messages::WebResourceLoader::DidReceiveResponse { m_response, PrivateRelayed::No, willWaitForContinueDidReceiveResponse });
 }
 
 bool NetworkResourceLoader::shouldInterruptLoadForXFrameOptions(const String& xFrameOptions, const URL& url)
@@ -687,7 +688,7 @@
     return BrowsingContextGroupSwitchDecision::NewSharedGroup;
 }
 
-void NetworkResourceLoader::didReceiveResponse(ResourceResponse&& receivedResponse, ResponseCompletionHandler&& completionHandler)
+void NetworkResourceLoader::didReceiveResponse(ResourceResponse&& receivedResponse, PrivateRelayed privateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     LOADER_RELEASE_LOG("didReceiveResponse: (httpStatusCode=%d, MIMEType=%" PUBLIC_LOG_STRING ", expectedContentLength=%" PRId64 ", hasCachedEntryForValidation=%d, hasNetworkLoadChecker=%d)", receivedResponse.httpStatusCode(), receivedResponse.mimeType().utf8().data(), receivedResponse.expectedContentLength(), !!m_cacheEntryForValidation, !!m_networkLoadChecker);
 
@@ -805,7 +806,7 @@
     // a main resource because the embedding client must decide whether to allow the load.
     bool willWaitForContinueDidReceiveResponse = isMainResource();
     LOADER_RELEASE_LOG("didReceiveResponse: Sending WebResourceLoader::DidReceiveResponse IPC (willWaitForContinueDidReceiveResponse=%d)", willWaitForContinueDidReceiveResponse);
-    sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(response, willWaitForContinueDidReceiveResponse);
+    sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(response, privateRelayed, willWaitForContinueDidReceiveResponse);
 
     if (m_parameters.pageHasResourceLoadClient)
         m_connection->networkProcess().parentProcessConnection()->send(Messages::NetworkProcessProxy::ResourceLoadDidReceiveResponse(m_parameters.webPageProxyID, resourceLoadInfo, response), 0);
@@ -824,11 +825,11 @@
     completionHandler(PolicyAction::Use);
 }
 
-void NetworkResourceLoader::sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(const WebCore::ResourceResponse& response, bool needsContinueDidReceiveResponseMessage)
+void NetworkResourceLoader::sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(const WebCore::ResourceResponse& response, PrivateRelayed privateRelayed, bool needsContinueDidReceiveResponseMessage)
 {
     auto browsingContextGroupSwitchDecision = toBrowsingContextGroupSwitchDecision(m_currentCoopEnforcementResult);
     if (browsingContextGroupSwitchDecision == BrowsingContextGroupSwitchDecision::StayInGroup) {
-        send(Messages::WebResourceLoader::DidReceiveResponse { response, needsContinueDidReceiveResponseMessage });
+        send(Messages::WebResourceLoader::DidReceiveResponse { response, privateRelayed, needsContinueDidReceiveResponseMessage });
         return;
     }
 
@@ -1089,7 +1090,7 @@
     LOADER_RELEASE_LOG("didFinishWithRedirectResponse:");
     redirectResponse.setType(ResourceResponse::Type::Opaqueredirect);
     if (!isCrossOriginPrefetch())
-        didReceiveResponse(WTFMove(redirectResponse), [] (auto) { });
+        didReceiveResponse(WTFMove(redirectResponse), PrivateRelayed::No, [] (auto) { });
     else if (auto* session = m_connection->networkProcess().networkSession(sessionID()))
         session->prefetchCache().storeRedirect(request.url(), WTFMove(redirectResponse), WTFMove(redirectRequest));
 
@@ -1339,7 +1340,7 @@
 
     bool needsContinueDidReceiveResponseMessage = isMainResource();
     LOADER_RELEASE_LOG("didRetrieveCacheEntry: Sending WebResourceLoader::DidReceiveResponse IPC (needsContinueDidReceiveResponseMessage=%d)", needsContinueDidReceiveResponseMessage);
-    sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(response, needsContinueDidReceiveResponseMessage);
+    sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(response, PrivateRelayed::No, needsContinueDidReceiveResponseMessage);
 
     if (needsContinueDidReceiveResponseMessage) {
         m_response = WTFMove(response);

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkResourceLoader.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkResourceLoader.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/NetworkResourceLoader.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -114,7 +114,7 @@
     bool isSynchronous() const final;
     bool isAllowedToAskUserForCredentials() const final { return m_isAllowedToAskUserForCredentials; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&&) final;
-    void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) final;
+    void didReceiveResponse(WebCore::ResourceResponse&&, PrivateRelayed, ResponseCompletionHandler&&) final;
     void didReceiveBuffer(const WebCore::FragmentedSharedBuffer&, int reportedEncodedDataLength) final;
     void didFinishLoading(const WebCore::NetworkLoadMetrics&) final;
     void didFailLoading(const WebCore::ResourceError&) final;
@@ -148,7 +148,7 @@
 #endif
 
     std::optional<WebCore::ResourceError> doCrossOriginOpenerHandlingOfResponse(const WebCore::ResourceResponse&);
-    void sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(const WebCore::ResourceResponse&, bool needsContinueDidReceiveResponseMessage);
+    void sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(const WebCore::ResourceResponse&, PrivateRelayed, bool needsContinueDidReceiveResponseMessage);
 
     bool isAppInitiated();
 

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/PingLoad.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/PingLoad.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/PingLoad.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -162,7 +162,7 @@
     didFinish(ResourceError { String(), 0, currentURL(), "Failed HTTP authentication"_s, ResourceError::Type::AccessControl });
 }
 
-void PingLoad::didReceiveResponse(ResourceResponse&& response, NegotiatedLegacyTLS, ResponseCompletionHandler&& completionHandler)
+void PingLoad::didReceiveResponse(ResourceResponse&& response, NegotiatedLegacyTLS, PrivateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     PING_RELEASE_LOG("didReceiveResponse - httpStatusCode=%d", response.httpStatusCode());
     WeakPtr weakThis { *this };

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/PingLoad.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/PingLoad.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/PingLoad.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -53,7 +53,7 @@
 
     void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler&&) final;
     void didReceiveChallenge(WebCore::AuthenticationChallenge&&, NegotiatedLegacyTLS, ChallengeCompletionHandler&&) final;
-    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, ResponseCompletionHandler&&) final;
+    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, PrivateRelayed, ResponseCompletionHandler&&) final;
     void didReceiveData(const WebCore::SharedBuffer&) final;
     void didCompleteWithError(const WebCore::ResourceError&, const WebCore::NetworkLoadMetrics&) final;
     void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend) final;

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/PreconnectTask.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/PreconnectTask.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/PreconnectTask.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -73,7 +73,7 @@
     // HSTS redirection may happen here.
 }
 
-void PreconnectTask::didReceiveResponse(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
+void PreconnectTask::didReceiveResponse(ResourceResponse&& response, PrivateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     ASSERT_NOT_REACHED();
     completionHandler(PolicyAction::Ignore);

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/PreconnectTask.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/PreconnectTask.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/PreconnectTask.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -54,7 +54,7 @@
     bool isAllowedToAskUserForCredentials() const final { return false; }
     void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) final;
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) final;
-    void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) final;
+    void didReceiveResponse(WebCore::ResourceResponse&&, PrivateRelayed, ResponseCompletionHandler&&) final;
     void didReceiveBuffer(const WebCore::FragmentedSharedBuffer&, int reportedEncodedDataLength) final;
     void didFinishLoading(const WebCore::NetworkLoadMetrics&) final;
     void didFailLoading(const WebCore::ResourceError&) final;

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -35,6 +35,7 @@
 #include "NetworkProcess.h"
 #include "NetworkResourceLoader.h"
 #include "NetworkSession.h"
+#include "PrivateRelayed.h"
 #include "ServiceWorkerNavigationPreloader.h"
 #include "SharedBufferCopy.h"
 #include "WebCoreArgumentCoders.h"
@@ -220,7 +221,7 @@
 
     if (shouldSetSource == ShouldSetSource::Yes)
         response.setSource(ResourceResponse::Source::ServiceWorker);
-    m_loader.sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(response, needsContinueDidReceiveResponseMessage);
+    m_loader.sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(response, PrivateRelayed::No, needsContinueDidReceiveResponseMessage);
     if (needsContinueDidReceiveResponseMessage)
         m_loader.setResponse(WTFMove(response));
 }

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerNavigationPreloader.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerNavigationPreloader.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerNavigationPreloader.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -33,6 +33,7 @@
 #include "NetworkCache.h"
 #include "NetworkLoad.h"
 #include "NetworkSession.h"
+#include "PrivateRelayed.h"
 #include <WebCore/NavigationPreloadState.h>
 
 namespace WebKit {
@@ -111,7 +112,7 @@
 
 void ServiceWorkerNavigationPreloader::loadWithCacheEntry(NetworkCache::Entry& entry)
 {
-    didReceiveResponse(ResourceResponse { entry.response() }, [body = RefPtr { entry.buffer() }, weakThis = WeakPtr { *this }](auto) mutable {
+    didReceiveResponse(ResourceResponse { entry.response() }, PrivateRelayed::No, [body = RefPtr { entry.buffer() }, weakThis = WeakPtr { *this }](auto) mutable {
         if (!weakThis || weakThis->m_isCancelled)
             return;
 
@@ -153,11 +154,11 @@
 
 void ServiceWorkerNavigationPreloader::willSendRedirectedRequest(ResourceRequest&&, ResourceRequest&&, ResourceResponse&& response)
 {
-    didReceiveResponse(WTFMove(response), [](auto) { });
+    didReceiveResponse(WTFMove(response), PrivateRelayed::No, [](auto) { });
     didComplete();
 }
 
-void ServiceWorkerNavigationPreloader::didReceiveResponse(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
+void ServiceWorkerNavigationPreloader::didReceiveResponse(ResourceResponse&& response, PrivateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     RELEASE_LOG(ServiceWorker, "ServiceWorkerNavigationPreloader::didReceiveResponse %p", this);
 

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerNavigationPreloader.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerNavigationPreloader.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerNavigationPreloader.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -71,7 +71,7 @@
     bool isSynchronous() const final { return false; }
     bool isAllowedToAskUserForCredentials() const final { return false; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) final;
-    void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) final;
+    void didReceiveResponse(WebCore::ResourceResponse&&, PrivateRelayed, ResponseCompletionHandler&&) final;
     void didReceiveBuffer(const WebCore::FragmentedSharedBuffer&, int reportedEncodedDataLength) final;
     void didFinishLoading(const WebCore::NetworkLoadMetrics&) final;
     void didFailLoading(const WebCore::ResourceError&) final;

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -140,7 +140,7 @@
     fail(ResourceError { ResourceError::Type::Cancellation });
 }
 
-void ServiceWorkerSoftUpdateLoader::didReceiveResponse(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
+void ServiceWorkerSoftUpdateLoader::didReceiveResponse(ResourceResponse&& response, PrivateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     m_certificateInfo = *response.certificateInfo();
     if (response.httpStatusCode() == 304 && m_cacheEntry) {

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -63,7 +63,7 @@
     bool isSynchronous() const final { return false; }
     bool isAllowedToAskUserForCredentials() const final { return false; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) final;
-    void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) final;
+    void didReceiveResponse(WebCore::ResourceResponse&&, PrivateRelayed, ResponseCompletionHandler&&) final;
     void didReceiveBuffer(const WebCore::FragmentedSharedBuffer&, int reportedEncodedDataLength) final;
     void didFinishLoading(const WebCore::NetworkLoadMetrics&) final;
     void didFailLoading(const WebCore::ResourceError&) final;

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -104,7 +104,7 @@
     didComplete();
 }
 
-void SpeculativeLoad::didReceiveResponse(ResourceResponse&& receivedResponse, ResponseCompletionHandler&& completionHandler)
+void SpeculativeLoad::didReceiveResponse(ResourceResponse&& receivedResponse, PrivateRelayed, ResponseCompletionHandler&& completionHandler)
 {
     m_response = receivedResponse;
 

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -60,7 +60,7 @@
     bool isSynchronous() const override { return false; }
     bool isAllowedToAskUserForCredentials() const final { return false; }
     void willSendRedirectedRequest(WebCore::ResourceRequest&&, WebCore::ResourceRequest&& redirectRequest, WebCore::ResourceResponse&& redirectResponse) override;
-    void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&) override;
+    void didReceiveResponse(WebCore::ResourceResponse&&, PrivateRelayed, ResponseCompletionHandler&&) override;
     void didReceiveBuffer(const WebCore::FragmentedSharedBuffer&, int reportedEncodedDataLength) override;
     void didFinishLoading(const WebCore::NetworkLoadMetrics&) override;
     void didFailLoading(const WebCore::ResourceError&) override;

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -62,7 +62,7 @@
     void didReceiveChallenge(WebCore::AuthenticationChallenge&&, NegotiatedLegacyTLS, ChallengeCompletionHandler&&);
     void didNegotiateModernTLS(const URL&);
     void didCompleteWithError(const WebCore::ResourceError&, const WebCore::NetworkLoadMetrics&);
-    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, ResponseCompletionHandler&&);
+    void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, PrivateRelayed, ResponseCompletionHandler&&);
     void didReceiveData(const WebCore::SharedBuffer&);
 
     void willPerformHTTPRedirection(WebCore::ResourceResponse&&, WebCore::ResourceRequest&&, RedirectCompletionHandler&&);

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2022-03-22 18:27:34 UTC (rev 291678)
@@ -344,6 +344,11 @@
     mutableRequest.get().attribution = request.isAppInitiated() ? NSURLRequestAttributionDeveloper : NSURLRequestAttributionUser;
 #endif
 
+#if HAVE(NETWORK_CONNECTION_PRIVACY_STANCE)
+    if (parameters.mainResourceWasPrivateRelayed)
+        [mutableRequest _setPrivacyProxyFailClosed:YES];
+#endif
+    
     nsRequest = mutableRequest;
 
 #if ENABLE(APP_PRIVACY_REPORT)
@@ -451,7 +456,7 @@
         m_client->didReceiveData(data);
 }
 
-void NetworkDataTaskCocoa::didReceiveResponse(WebCore::ResourceResponse&& response, NegotiatedLegacyTLS negotiatedLegacyTLS, WebKit::ResponseCompletionHandler&& completionHandler)
+void NetworkDataTaskCocoa::didReceiveResponse(WebCore::ResourceResponse&& response, NegotiatedLegacyTLS negotiatedLegacyTLS, PrivateRelayed privateRelayed, WebKit::ResponseCompletionHandler&& completionHandler)
 {
     WTFEmitSignpost(m_task.get(), "DataTask", "received response headers");
 #if HAVE(CFNETWORK_CNAME_AND_COOKIE_TRANSFORM_SPI)
@@ -458,7 +463,7 @@
     if (isTopLevelNavigation())
         updateFirstPartyInfoForSession(response.url());
 #endif
-    NetworkDataTask::didReceiveResponse(WTFMove(response), negotiatedLegacyTLS, WTFMove(completionHandler));
+    NetworkDataTask::didReceiveResponse(WTFMove(response), negotiatedLegacyTLS, privateRelayed, WTFMove(completionHandler));
 }
 
 void NetworkDataTaskCocoa::willPerformHTTPRedirection(WebCore::ResourceResponse&& redirectResponse, WebCore::ResourceRequest&& request, RedirectCompletionHandler&& completionHandler)

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2022-03-22 18:27:34 UTC (rev 291678)
@@ -36,6 +36,7 @@
 #import "NetworkLoad.h"
 #import "NetworkProcess.h"
 #import "NetworkSessionCreationParameters.h"
+#import "PrivateRelayed.h"
 #import "WebPageNetworkParameters.h"
 #import "WebSocketTask.h"
 #import <Foundation/NSURLSession.h>
@@ -928,6 +929,12 @@
         NSURLSessionTaskMetrics *taskMetrics = dataTask._incompleteTaskMetrics;
 
         NSURLSessionTaskTransactionMetrics *metrics = taskMetrics.transactionMetrics.lastObject;
+#if HAVE(NETWORK_CONNECTION_PRIVACY_STANCE)
+        auto privateRelayed = metrics._privacyStance == nw_connection_privacy_stance_proxied ? PrivateRelayed::Yes : PrivateRelayed::No;
+#else
+        auto privateRelayed = PrivateRelayed::No;
+#endif
+        WTFLogAlways("RESPONSE WAS PRIVATE RELAYED %d", privateRelayed);
         auto tlsVersion = (tls_protocol_version_t)metrics.negotiatedTLSProtocolVersion.unsignedShortValue;
 ALLOW_DEPRECATED_DECLARATIONS_BEGIN
         if (tlsVersion == tls_protocol_version_TLSv10 || tlsVersion == tls_protocol_version_TLSv11)
@@ -950,7 +957,7 @@
 
         resourceResponse.setDeprecatedNetworkLoadMetrics(WebCore::copyTimingData(taskMetrics, networkDataTask->networkLoadMetrics()));
 
-        networkDataTask->didReceiveResponse(WTFMove(resourceResponse), negotiatedLegacyTLS, [completionHandler = makeBlockPtr(completionHandler), taskIdentifier](WebCore::PolicyAction policyAction) {
+        networkDataTask->didReceiveResponse(WTFMove(resourceResponse), negotiatedLegacyTLS, privateRelayed, [completionHandler = makeBlockPtr(completionHandler), taskIdentifier](WebCore::PolicyAction policyAction) {
 #if !LOG_DISABLED
             LOG(NetworkSession, "%llu didReceiveResponse completionHandler (%d)", taskIdentifier, policyAction);
 #else

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -29,6 +29,7 @@
 #include "AuthenticationChallengeDisposition.h"
 #include "AuthenticationManager.h"
 #include "NetworkSessionCurl.h"
+#include "PrivateRelayed.h"
 #include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/CookieJar.h>
 #include <WebCore/CurlRequest.h>
@@ -225,7 +226,7 @@
 
 void NetworkDataTaskCurl::invokeDidReceiveResponse()
 {
-    didReceiveResponse(ResourceResponse(m_response), NegotiatedLegacyTLS::No, [this, protectedThis = Ref { *this }](PolicyAction policyAction) {
+    didReceiveResponse(ResourceResponse(m_response), NegotiatedLegacyTLS::No, PrivateRelayed::No, [this, protectedThis = Ref { *this }](PolicyAction policyAction) {
         if (m_state == State::Canceling || m_state == State::Completed)
             return;
 

Modified: branches/safari-613-branch/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -33,6 +33,7 @@
 #include "NetworkLoad.h"
 #include "NetworkProcess.h"
 #include "NetworkSessionSoup.h"
+#include "PrivateRelayed.h"
 #include "WebErrors.h"
 #include "WebKitDirectoryInputStream.h"
 #include <WebCore/AuthenticationChallenge.h>
@@ -503,7 +504,7 @@
     // FIXME: This cannot be eliminated until other code no longer relies on ResourceResponse's NetworkLoadMetrics.
     m_response.setDeprecatedNetworkLoadMetrics(Box<NetworkLoadMetrics>::create(m_networkLoadMetrics));
 
-    didReceiveResponse(ResourceResponse(m_response), NegotiatedLegacyTLS::No, [this, protectedThis = Ref { *this }](PolicyAction policyAction) {
+    didReceiveResponse(ResourceResponse(m_response), NegotiatedLegacyTLS::No, PrivateRelayed::No, [this, protectedThis = Ref { *this }](PolicyAction policyAction) {
         if (m_state == State::Canceling || m_state == State::Completed) {
             clearRequest();
             return;

Added: branches/safari-613-branch/Source/WebKit/Shared/PrivateRelayed.h (0 => 291678)


--- branches/safari-613-branch/Source/WebKit/Shared/PrivateRelayed.h	                        (rev 0)
+++ branches/safari-613-branch/Source/WebKit/Shared/PrivateRelayed.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebKit {
+
+enum class PrivateRelayed : bool { No, Yes };
+
+}

Modified: branches/safari-613-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-03-22 18:27:34 UTC (rev 291678)
@@ -4681,6 +4681,7 @@
 		57FE688A260ABB3D00BF45E4 /* PrivateClickMeasurementNetworkLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementNetworkLoader.h; sourceTree = "<group>"; };
 		57FE688B260ABB3D00BF45E4 /* PrivateClickMeasurementNetworkLoader.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementNetworkLoader.cpp; sourceTree = "<group>"; };
 		5C00993B2417FB7E00D53C25 /* ResourceLoadStatisticsParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatisticsParameters.h; sourceTree = "<group>"; };
+		5C05FDF227AB4FA5003A2487 /* PrivateRelayed.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PrivateRelayed.h; sourceTree = "<group>"; };
 		5C0A10C1235241A30053E2CA /* NetworkSchemeRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkSchemeRegistry.cpp; sourceTree = "<group>"; };
 		5C0B17741E7C879C00E9123C /* NetworkSocketStreamMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkSocketStreamMessageReceiver.cpp; path = DerivedSources/WebKit/NetworkSocketStreamMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
 		5C0B17751E7C879C00E9123C /* NetworkSocketStreamMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkSocketStreamMessages.h; path = DerivedSources/WebKit/NetworkSocketStreamMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -7077,6 +7078,7 @@
 				49ECA41B23FCA4860023358D /* PolicyDecision.h */,
 				E18C92F312DB9E7100CF2AEB /* PrintInfo.cpp */,
 				E1CC1B8E12D7EADF00625838 /* PrintInfo.h */,
+				5C05FDF227AB4FA5003A2487 /* PrivateRelayed.h */,
 				463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */,
 				517B5F94275EBA62002DC22D /* PushMessageForTesting.h */,
 				9B1229D023FF2A5E008CA751 /* RemoteAudioDestinationIdentifier.h */,

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -277,6 +277,11 @@
     if (!frame)
         return;
 
+    if (auto* mainFrameDocument = frame->mainFrame().document()) {
+        if (auto* mainDocumentLoader = mainFrameDocument->loader())
+            parameters.mainResourceWasPrivateRelayed = mainDocumentLoader->mainResourceWasPrivateRelayed();
+    }
+    
     if (auto* document = frame->document())
         parameters.crossOriginEmbedderPolicy = document->crossOriginEmbedderPolicy();
 

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebResourceLoader.cpp (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebResourceLoader.cpp	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebResourceLoader.cpp	2022-03-22 18:27:34 UTC (rev 291678)
@@ -30,6 +30,7 @@
 #include "Logging.h"
 #include "NetworkProcessConnection.h"
 #include "NetworkResourceLoaderMessages.h"
+#include "PrivateRelayed.h"
 #include "SharedBufferCopy.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebErrors.h"
@@ -93,6 +94,22 @@
     m_coreLoader = nullptr;
 }
 
+MainFrameMainResource WebResourceLoader::mainFrameMainResource() const
+{
+    auto* frame = m_coreLoader->frame();
+    if (!frame || !frame->isMainFrame())
+        return MainFrameMainResource::No;
+
+    auto* frameLoader = m_coreLoader->frameLoader();
+    if (!frameLoader)
+        return MainFrameMainResource::No;
+
+    if (!frameLoader->notifier().isInitialRequestIdentifier(m_coreLoader->identifier()))
+        return MainFrameMainResource::No;
+
+    return MainFrameMainResource::Yes;
+}
+
 void WebResourceLoader::willSendRequest(ResourceRequest&& proposedRequest, IPC::FormDataReference&& proposedRequestBody, ResourceResponse&& redirectResponse)
 {
     Ref<WebResourceLoader> protectedThis(*this);
@@ -110,11 +127,7 @@
     
     if (auto* frame = m_coreLoader->frame()) {
         if (auto* page = frame->page()) {
-            auto mainFrameMainResource = frame->isMainFrame()
-                && m_coreLoader->frameLoader()
-                && m_coreLoader->frameLoader()->notifier().isInitialRequestIdentifier(m_coreLoader->identifier())
-                ? MainFrameMainResource::Yes : MainFrameMainResource::No;
-            if (!page->allowsLoadFromURL(proposedRequest.url(), mainFrameMainResource))
+            if (!page->allowsLoadFromURL(proposedRequest.url(), mainFrameMainResource()))
                 proposedRequest = { };
         }
     }
@@ -135,7 +148,7 @@
     m_coreLoader->didSendData(bytesSent, totalBytesToBeSent);
 }
 
-void WebResourceLoader::didReceiveResponse(const ResourceResponse& response, bool needsContinueDidReceiveResponseMessage)
+void WebResourceLoader::didReceiveResponse(const ResourceResponse& response, PrivateRelayed privateRelayed, bool needsContinueDidReceiveResponseMessage)
 {
     LOG(Network, "(WebProcess) WebResourceLoader::didReceiveResponse for '%s'. Status %d.", m_coreLoader->url().string().latin1().data(), response.httpStatusCode());
     WEBRESOURCELOADER_RELEASE_LOG("didReceiveResponse: (httpStatusCode=%d)", response.httpStatusCode());
@@ -142,6 +155,9 @@
 
     Ref<WebResourceLoader> protectedThis(*this);
 
+    if (privateRelayed == PrivateRelayed::Yes && mainFrameMainResource() == MainFrameMainResource::Yes)
+        m_coreLoader->documentLoader()->setMainResourceWasPrivateRelayed(privateRelayed == PrivateRelayed::Yes);
+
     if (m_coreLoader->documentLoader()->applicationCacheHost().maybeLoadFallbackForResponse(m_coreLoader.get(), response)) {
         WEBRESOURCELOADER_RELEASE_LOG("didReceiveResponse: not continuing load because the content is already cached");
         return;

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebResourceLoader.h (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebResourceLoader.h	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebResourceLoader.h	2022-03-22 18:27:34 UTC (rev 291678)
@@ -48,10 +48,13 @@
 class ResourceLoader;
 class ResourceRequest;
 class ResourceResponse;
+enum class MainFrameMainResource : bool;
 }
 
 namespace WebKit {
 
+enum class PrivateRelayed : bool;
+
 class WebResourceLoader : public RefCounted<WebResourceLoader>, public IPC::MessageSender {
 public:
     struct TrackingParameters {
@@ -80,7 +83,7 @@
 
     void willSendRequest(WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody, WebCore::ResourceResponse&&);
     void didSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent);
-    void didReceiveResponse(const WebCore::ResourceResponse&, bool needsContinueDidReceiveResponseMessage);
+    void didReceiveResponse(const WebCore::ResourceResponse&, PrivateRelayed, bool needsContinueDidReceiveResponseMessage);
     void didReceiveData(const IPC::SharedBufferCopy& data, int64_t encodedDataLength);
     void didFinishResourceLoad(const WebCore::NetworkLoadMetrics&);
     void didFailResourceLoad(const WebCore::ResourceError&);
@@ -90,6 +93,8 @@
 
     void stopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied(const WebCore::ResourceResponse&);
 
+    WebCore::MainFrameMainResource mainFrameMainResource() const;
+    
 #if ENABLE(SHAREABLE_RESOURCE)
     void didReceiveResource(const ShareableResource::Handle&);
 #endif

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebResourceLoader.messages.in (291677 => 291678)


--- branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebResourceLoader.messages.in	2022-03-22 18:17:48 UTC (rev 291677)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/Network/WebResourceLoader.messages.in	2022-03-22 18:27:34 UTC (rev 291678)
@@ -23,7 +23,7 @@
 messages -> WebResourceLoader LegacyReceiver {
     WillSendRequest(WebCore::ResourceRequest request, IPC::FormDataReference requestBody, WebCore::ResourceResponse redirectResponse)
     DidSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent)
-    DidReceiveResponse(WebCore::ResourceResponse response, bool needsContinueDidReceiveResponseMessage)
+    DidReceiveResponse(WebCore::ResourceResponse response, enum:bool WebKit::PrivateRelayed privateRelayed, bool needsContinueDidReceiveResponseMessage)
     DidReceiveData(IPC::SharedBufferCopy data, int64_t encodedDataLength)
     DidFinishResourceLoad(WebCore::NetworkLoadMetrics networkLoadMetrics)
     DidFailResourceLoad(WebCore::ResourceError error)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to