4747#import " WebPrivacyHelpers.h"
4848#import " WebSocketTask.h"
4949#import < Foundation/NSURLSession.h>
50+ #import < Network/NSURLSession+Network.h>
5051#import < WebCore/AdvancedPrivacyProtections.h>
5152#import < WebCore/Credential.h>
5253#import < WebCore/FormDataStreamCocoa.h>
104105void WebKit::NetworkSessionCocoa::removeNetworkWebsiteData (std::optional<WallTime>, std::optional<HashSet<WebCore::RegistrableDomain>>&&, CompletionHandler<void ()>&& completionHandler) { completionHandler (); }
105106#endif
106107
107- #if HAVE(NW_PROXY_CONFIG) && __has_include(<Network/NSURLSession+Network.h>)
108- #include < Network/NSURLSession+Network.h>
109- #endif
110-
111108#import " DeviceManagementSoftLink.h"
112109
113110using WebKit::IsolatedSession;
@@ -315,7 +312,6 @@ - (void)sessionInvalidated
315312
316313- (void )URLSession : (NSURLSession *)session didBecomeInvalidWithError : (NSError *)error
317314{
318- #if HAVE(NW_PROXY_CONFIG)
319315 // Other sessions lose their wrappers before they become invalid, but a session that a proxy
320316 // change replaced keeps its wrapper until it finishes its tasks. The wrapper owns the session
321317 // and this delegate, and can let go of both here.
@@ -324,10 +320,7 @@ - (void)URLSession:(NSURLSession *)session didBecomeInvalidWithError:(NSError *)
324320 RetainPtr protectedSession = session;
325321 if (CheckedPtr networkSession = _session)
326322 networkSession->replacedSessionDidBecomeInvalid (protectedSession.get ());
327- return ;
328323 }
329- #endif
330- ASSERT (!_sessionWrapper);
331324}
332325
333326- (void )URLSession : (NSURLSession *)session task : (NSURLSessionTask *)task didSendBodyData : (int64_t )bytesSent totalBytesSent : (int64_t )totalBytesSent totalBytesExpectedToSend : (int64_t )totalBytesExpectedToSend
@@ -599,9 +592,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didRece
599592 // Proxy authentication is handled by CFNetwork internally. We can get here if the user cancels
600593 // CFNetwork authentication dialog, and we shouldn't ask the client to display another one in that case.
601594 if (challenge.protectionSpace .isProxy
602- #if HAVE(NW_PROXY_CONFIG)
603595 && sessionCocoa->proxyConfigs ().isEmpty ()
604- #endif
605596 && !sessionCocoa->preventsSystemHTTPProxyAuthentication ())
606597 return completionHandler (NSURLSessionAuthChallengeUseCredential , nil );
607598
@@ -1122,9 +1113,7 @@ - (void)URLSession:(NSURLSession *)session webSocketTask:(NSURLSessionWebSocketT
11221113 if (!configuration._sourceApplicationSecondaryIdentifier && isFullBrowser)
11231114 configuration._sourceApplicationSecondaryIdentifier = @" com.apple.WebKit.InAppBrowser" ;
11241115
1125- #if HAVE(NW_PROXY_CONFIG)
11261116 networkSession.applyProxyConfigurationToSessionConfiguration (configuration);
1127- #endif
11281117
11291118 delegate = adoptNS ([[WKNetworkSessionDelegate alloc ] initWithNetworkSession: networkSession wrapper: *this withCredentials: storedCredentialsPolicy == WebCore: :StoredCredentialsPolicy: :Use]);
11301119 session = [NSURLSession sessionWithConfiguration: configuration delegate: delegate.get () delegateQueue: [NSOperationQueue mainQueue ]];
@@ -1252,11 +1241,9 @@ - (void)URLSession:(NSURLSession *)session webSocketTask:(NSURLSessionWebSocketT
12521241 configuration.get ().TLSMinimumSupportedProtocolVersion = tls_protocol_version_TLSv12;
12531242#endif
12541243
1255- #if HAVE(NW_PROXY_CONFIG)
12561244 // Before the sessions exist, so that they get created with the proxies, rather than replaced.
12571245 if (parameters.proxyConfigData )
12581246 setProxyConfigData (*parameters.proxyConfigData );
1259- #endif
12601247
12611248 initializeNSURLSessionsInSet (m_defaultSessionSet.get (), configuration.get ());
12621249
@@ -1517,13 +1504,11 @@ - (void)URLSession:(NSURLSession *)session webSocketTask:(NSURLSessionWebSocketT
15171504 for (auto & sessionSet : m_perPageSessionSets.values ())
15181505 invalidateAndCancelSessionSet (sessionSet.get ());
15191506
1520- #if HAVE(NW_PROXY_CONFIG)
15211507 for (auto & sessionWrapper : m_replacedSessionWrappers) {
15221508 [sessionWrapper->session invalidateAndCancel ];
15231509 [sessionWrapper->delegate sessionInvalidated ];
15241510 }
15251511 m_replacedSessionWrappers.clear ();
1526- #endif
15271512}
15281513
15291514HashSet<WebCore::SecurityOriginData> NetworkSessionCocoa::originsWithCredentials ()
@@ -1741,10 +1726,8 @@ - (void)URLSession:(NSURLSession *)session webSocketTask:(NSURLSessionWebSocketT
17411726 RELEASE_LOG (NetworkSession, " NetworkSessionCocoa::removeWebSocketTask, web socket count is %u" , webSocketDataTaskMap.size ());
17421727 }
17431728
1744- #if HAVE(NW_PROXY_CONFIG)
17451729 // The wrapper of a session that a proxy change replaced may have been waiting for this task.
17461730 removeFinishedReplacedSessionWrappers ();
1747- #endif
17481731}
17491732
17501733void NetworkSessionCocoa::addWebPageNetworkParameters (WebPageProxyIdentifier pageID, WebPageNetworkParameters&& parameters)
@@ -2005,7 +1988,6 @@ void didCompleteWithError(const WebCore::ResourceError& error, const WebCore::Ne
20051988 }
20061989}
20071990
2008- #if HAVE(NW_PROXY_CONFIG)
20091991void NetworkSessionCocoa::clearProxyConfigData ()
20101992{
20111993 setProxyConfigData ({ });
@@ -2092,7 +2074,6 @@ void didCompleteWithError(const WebCore::ResourceError& error, const WebCore::Ne
20922074 } else
20932075 configuration.proxyConfigurations = @[ ];
20942076}
2095- #endif // HAVE(NW_PROXY_CONFIG)
20962077
20972078#if USE(APPLE_INTERNAL_SDK)
20982079
0 commit comments