WebKit Bugzilla
Attachment 346030 Details for
Bug 188137
: Merge PlatformCookieJar functions into NetworkStorageSession
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188137-20180729173242.patch (text/plain), 144.97 KB, created by
Rob Buis
on 2018-07-29 08:32:45 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2018-07-29 08:32:45 PDT
Size:
144.97 KB
patch
obsolete
>Subversion Revision: 234344 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 102c257fa1d4be9ba2b1d1ad9ec61e0ee758dc72..226bbe1741ac91c7f430cb95692ef10924005fa4 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,110 @@ >+2018-07-29 Rob Buis <rbuis@igalia.com> >+ >+ Merge PlatformCookieJar functions into NetworkStorageSession >+ https://bugs.webkit.org/show_bug.cgi?id=188137 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests -- no change in WebKit functionality. >+ >+ * PlatformMac.cmake: Remove CookieJarMac.mm reference >+ * SourcesCocoa.txt: Remove CookieJarMac.mm reference >+ * WebCore.xcodeproj/project.pbxproj: >+ * loader/CookieJar.cpp: Remove PlatformCookieJar.h reference. >+ * platform/Curl.cmake: Remove CookieJarCurl.cpp reference. >+ * platform/SourcesSoup.txt: Remove CookieJarSoup.cpp reference. >+ * platform/network/CacheValidation.cpp: Adapt callsites to use >+ NetworkStorageSession instead of CookieJar functions. >+ >+ (WebCore::headerValueForVary): >+ * platform/network/NetworkStorageSession.h: Add PlatformCookieJar >+ functions. >+ >+ * platform/network/PlatformCookieJar.h: Removed. >+ * platform/network/SocketStreamHandleImpl.cpp: Adapt callsites to >+ use NetworkStorageSession instead of CookieJar functions. >+ (WebCore::cookieDataForHandshake): >+ * platform/network/cf/CookieJarCFNet.cpp: Removed. >+ * platform/network/cf/NetworkStorageSessionCFNet.cpp: Move functions >+ from CookieJarCFNet.cpp. >+ (WebCore::cookieDomain): >+ (WebCore::canonicalCookieTime): >+ (WebCore::cookieCreatedTime): >+ (WebCore::cookieExpirationTime): >+ (WebCore::cookieName): >+ (WebCore::cookiePath): >+ (WebCore::cookieValue): >+ (WebCore::filterCookies): >+ (WebCore::copyCookiesForURLWithFirstPartyURL): >+ (WebCore::createCookies): >+ (WebCore::NetworkStorageSession::setCookiesFromDOM const): >+ (WebCore::containsSecureCookies): >+ (WebCore::NetworkStorageSession::cookiesForDOM const): >+ (WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const): >+ (WebCore::NetworkStorageSession::cookiesEnabled const): >+ (WebCore::NetworkStorageSession::getRawCookies const): >+ (WebCore::NetworkStorageSession::deleteCookie const): >+ (WebCore::NetworkStorageSession::getHostnamesWithCookies): >+ (WebCore::NetworkStorageSession::deleteAllCookies): >+ (WebCore::NetworkStorageSession::deleteCookiesForHostnames): >+ (WebCore::NetworkStorageSession::deleteAllCookiesModifiedSince): >+ * platform/network/cocoa/NetworkStorageSessionCocoa.mm: Move functions >+ from CookieJarMac.mm. >+ (WebCore::httpCookies): >+ (WebCore::deleteHTTPCookie): >+ (WebCore::policyProperties): >+ (WebCore::cookiesForURL): >+ (WebCore::setHTTPCookiesForURL): >+ (WebCore::httpCookiesForURL): >+ (WebCore::filterCookies): >+ (WebCore::applyPartitionToCookies): >+ (WebCore::cookiesAreBlockedForURL): >+ (WebCore::cookiesInPartitionForURL): >+ (WebCore::cookiesForSession): >+ (WebCore::deleteAllHTTPCookies): >+ (WebCore::NetworkStorageSession::cookiesForDOM const): >+ (WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const): >+ (WebCore::NetworkStorageSession::setCookiesFromDOM const): >+ (WebCore::httpCookieAcceptPolicy): >+ (WebCore::NetworkStorageSession::cookiesEnabled const): >+ (WebCore::NetworkStorageSession::getRawCookies const): >+ (WebCore::NetworkStorageSession::deleteCookie const): >+ (WebCore::NetworkStorageSession::getHostnamesWithCookies): >+ (WebCore::NetworkStorageSession::deleteAllCookies): >+ (WebCore::NetworkStorageSession::deleteCookiesForHostnames): >+ (WebCore::NetworkStorageSession::deleteAllCookiesModifiedSince): >+ * platform/network/curl/CookieJarCurl.cpp: Removed. >+ * platform/network/curl/CookieJarCurl.h: >+ * platform/network/curl/NetworkStorageSessionCurl.cpp: Merge functions >+ from CookieJarCurl.cpp. >+ (WebCore::NetworkStorageSession::setCookiesFromDOM const): >+ (WebCore::NetworkStorageSession::cookiesEnabled const): >+ (WebCore::NetworkStorageSession::cookiesForDOM const): >+ (WebCore::NetworkStorageSession::deleteCookie const): >+ (WebCore::NetworkStorageSession::deleteAllCookies): >+ (WebCore::NetworkStorageSession::deleteAllCookiesModifiedSince): >+ (WebCore::NetworkStorageSession::deleteCookiesForHostnames): >+ (WebCore::NetworkStorageSession::getHostnamesWithCookies): >+ (WebCore::NetworkStorageSession::getRawCookies const): >+ (WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const): >+ * platform/network/mac/CookieJarMac.mm: Removed. >+ * platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm: >+ * platform/network/soup/CookieJarSoup.cpp: Removed. >+ * platform/network/soup/NetworkStorageSessionSoup.cpp: Merge functions >+ from CookieJarSoup.cpp. >+ (WebCore::NetworkStorageSession::cookiesEnabled const): >+ (WebCore::httpOnlyCookieExists): >+ (WebCore::NetworkStorageSession::setCookiesFromDOM const): >+ (WebCore::NetworkStorageSession::deleteCookie const): >+ (WebCore::NetworkStorageSession::deleteAllCookies): >+ (WebCore::NetworkStorageSession::deleteAllCookiesModifiedSince): >+ (WebCore::NetworkStorageSession::deleteCookiesForHostnames): >+ (WebCore::NetworkStorageSession::getHostnamesWithCookies): >+ (WebCore::NetworkStorageSession::getRawCookies const): >+ (WebCore::cookiesForSession): >+ (WebCore::NetworkStorageSession::cookiesForDOM const): >+ (WebCore::NetworkStorageSession::cookieRequestHeaderFieldValue const): >+ > 2018-07-24 Simon Fraser <simon.fraser@apple.com> > > Animation stops with object-fit:contain on an animated 2d canvas >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index fcb37d14655b344beb93b7f690e5ea8695d051ff..580bd9f1858d1e09c60ea9695fbb8e138eb9be94 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,33 @@ >+2018-07-29 Rob Buis <rbuis@igalia.com> >+ >+ https://bugs.webkit.org/show_bug.cgi?id=188137 >+ Merge PlatformCookieJar functions into NetworkStorageSession >+ >+ Adapt callsites to use NetworkStorageSession instead of CookieJar functions. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * NetworkProcess/Cookies/WebCookieManager.cpp: >+ (WebKit::WebCookieManager::getHostnamesWithCookies): >+ (WebKit::WebCookieManager::deleteCookiesForHostname): >+ (WebKit::WebCookieManager::deleteAllCookies): >+ (WebKit::WebCookieManager::deleteAllCookiesModifiedSince): >+ * NetworkProcess/NetworkConnectionToWebProcess.cpp: >+ (WebKit::NetworkConnectionToWebProcess::cookiesForDOM): >+ (WebKit::NetworkConnectionToWebProcess::setCookiesFromDOM): >+ (WebKit::NetworkConnectionToWebProcess::cookiesEnabled): >+ (WebKit::NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue): >+ (WebKit::NetworkConnectionToWebProcess::getRawCookies): >+ (WebKit::NetworkConnectionToWebProcess::deleteCookie): >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::fetchWebsiteData): >+ (WebKit::NetworkProcess::deleteWebsiteData): >+ (WebKit::NetworkProcess::deleteWebsiteDataForOrigins): >+ * NetworkProcess/NetworkResourceLoader.cpp: >+ (WebKit::logCookieInformationInternal): >+ * NetworkProcess/cache/NetworkCache.cpp: >+ * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: >+ > 2018-07-27 Chris Dumez <cdumez@apple.com> > > Fix thread-safety issues related to RealtimeMediaSource::audioSamplesAvailable() >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 0e3375663b93d5b86e3cb5018566cab48fae5d06..396bae894dfcb82b8d219f710d8fd4f2cfa2e73b 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,22 @@ >+2018-07-29 Rob Buis <rbuis@igalia.com> >+ >+ Merge PlatformCookieJar functions into NetworkStorageSession >+ https://bugs.webkit.org/show_bug.cgi?id=188137 >+ >+ Adapt callsites to use NetworkStorageSession instead of CookieJar functions. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebCoreSupport/WebPlatformStrategies.mm: >+ (WebPlatformStrategies::cookiesForDOM): >+ (WebPlatformStrategies::setCookiesFromDOM): >+ (WebPlatformStrategies::cookiesEnabled): >+ (WebPlatformStrategies::cookieRequestHeaderFieldValue): >+ (WebPlatformStrategies::getRawCookies): >+ (WebPlatformStrategies::deleteCookie): >+ * WebView/WebPreferences.mm: >+ (+[WebPreferences _clearNetworkLoaderSession]): >+ > 2018-07-26 Andy VanWagoner <andy@vanwagoner.family> > > [INTL] Remove INTL sub-feature compile flags >diff --git a/Source/WebKitLegacy/win/ChangeLog b/Source/WebKitLegacy/win/ChangeLog >index a73dfefbef0cfc866cccab64812655d449c748f6..51271126334d98dfca909051a67dfe1e76ad5cbf 100644 >--- a/Source/WebKitLegacy/win/ChangeLog >+++ b/Source/WebKitLegacy/win/ChangeLog >@@ -1,3 +1,22 @@ >+2018-07-29 Rob Buis <rbuis@igalia.com> >+ >+ https://bugs.webkit.org/show_bug.cgi?id=188137 >+ Merge PlatformCookieJar functions into NetworkStorageSession >+ >+ Adapt callsites to use NetworkStorageSession instead of CookieJar functions. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebCoreSupport/WebPlatformStrategies.cpp: >+ (WebPlatformStrategies::cookiesForDOM): >+ (WebPlatformStrategies::setCookiesFromDOM): >+ (WebPlatformStrategies::cookiesEnabled): >+ (WebPlatformStrategies::cookieRequestHeaderFieldValue): >+ (WebPlatformStrategies::getRawCookies): >+ (WebPlatformStrategies::deleteCookie): >+ * WebPreferences.cpp: >+ (WebPreferences::clearNetworkLoaderSession): >+ > 2018-07-26 Ross Kirsling <ross.kirsling@sony.com> > > String(View) should have a splitAllowingEmptyEntries function instead of a flag parameter >diff --git a/Source/WebCore/PlatformAppleWin.cmake b/Source/WebCore/PlatformAppleWin.cmake >index 2c07f3a2d72d7a71399deefdc925796acd8e10fb..b86029b88be71b79df3840686aef553a89212294 100644 >--- a/Source/WebCore/PlatformAppleWin.cmake >+++ b/Source/WebCore/PlatformAppleWin.cmake >@@ -47,7 +47,6 @@ list(APPEND WebCore_SOURCES > platform/graphics/win/FontCustomPlatformData.cpp > > platform/network/cf/AuthenticationCF.cpp >- platform/network/cf/CookieJarCFNet.cpp > platform/network/cf/CookieStorageCFNet.cpp > platform/network/cf/CredentialStorageCFNet.cpp > platform/network/cf/DNSResolveQueueCFNet.cpp >diff --git a/Source/WebCore/PlatformMac.cmake b/Source/WebCore/PlatformMac.cmake >index f3d8d028cfd1e061f9f2c6f302bdf9b95d1d4949..5dfe74c79b523100d4ec7b8b4bdf5d835f86f291 100644 >--- a/Source/WebCore/PlatformMac.cmake >+++ b/Source/WebCore/PlatformMac.cmake >@@ -434,7 +434,6 @@ list(APPEND WebCore_SOURCES > platform/network/mac/AuthenticationMac.mm > platform/network/mac/BlobDataFileReferenceMac.mm > platform/network/mac/CertificateInfoMac.mm >- platform/network/mac/CookieJarMac.mm > platform/network/mac/CookieStorageMac.mm > platform/network/mac/CredentialStorageMac.mm > platform/network/mac/FormDataStreamMac.mm >diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt >index e352e53b8d61fcb80a2f2a0ca6cefe5c1a91b93d..ee9e8b0a1f3175352f25520704533895b3b19b4c 100644 >--- a/Source/WebCore/SourcesCocoa.txt >+++ b/Source/WebCore/SourcesCocoa.txt >@@ -507,7 +507,6 @@ platform/network/ios/WebCoreURLResponseIOS.mm > platform/network/mac/AuthenticationMac.mm > platform/network/mac/BlobDataFileReferenceMac.mm > platform/network/mac/CertificateInfoMac.mm >-platform/network/mac/CookieJarMac.mm > platform/network/mac/CookieStorageMac.mm > platform/network/mac/CredentialStorageMac.mm > platform/network/mac/FormDataStreamMac.mm >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index fc1fa1d2ecf8e035d25482fefb759fcfa1eb5561..787dcfab57d1c2d5d2c9e6c2154c020813b0bdde 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -4603,7 +4603,6 @@ > E134F5AB12EE343F004EC58D /* IntRectHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E134F5AA12EE343F004EC58D /* IntRectHash.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E139866415478474001E3F65 /* StyleResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E139866215478474001E3F65 /* StyleResolver.h */; }; > E13EF3441684ECF40034C83F /* NetworkStorageSession.h in Headers */ = {isa = PBXBuildFile; fileRef = E13EF3421684ECF40034C83F /* NetworkStorageSession.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- E1424C8A164B3B4E00F32D40 /* PlatformCookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E1424C94164B52C800F32D40 /* CookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = E1424C92164B52C800F32D40 /* CookieJar.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E14F1C4514B5DAC600EA9009 /* HTMLFormControlElementWithState.h in Headers */ = {isa = PBXBuildFile; fileRef = E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E152551516FD2350003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = E152551316FD234F003D7ADB /* WebCoreResourceHandleAsOperationQueueDelegate.h */; }; >@@ -14130,8 +14129,6 @@ > E13EF34716850C470034C83F /* NetworkStorageSessionCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkStorageSessionCFNet.cpp; sourceTree = "<group>"; }; > E13F01EA1270E10D00DFBA71 /* CookieStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieStorage.h; sourceTree = "<group>"; }; > E13F01F01270E19000DFBA71 /* CookieStorageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieStorageMac.mm; sourceTree = "<group>"; }; >- E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCookieJar.h; sourceTree = "<group>"; }; >- E1424C8F164B460B00F32D40 /* CookieJarMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieJarMac.mm; sourceTree = "<group>"; }; > E1424C91164B52C800F32D40 /* CookieJar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieJar.cpp; sourceTree = "<group>"; }; > E1424C92164B52C800F32D40 /* CookieJar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieJar.h; sourceTree = "<group>"; }; > E14A94D616DFDF950068DE82 /* BlobRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlobRegistry.cpp; sourceTree = "<group>"; }; >@@ -19073,7 +19070,6 @@ > CDCD41E61C3DDB0900965D99 /* ParsedContentRange.h */, > 447958021643B47B001E0A7F /* ParsedContentType.cpp */, > 447958031643B47B001E0A7F /* ParsedContentType.h */, >- E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */, > 37BAAE571980D1DD005DFE71 /* ProtectionSpace.h */, > 514C765F0CE923A1007EF3CD /* ProtectionSpaceBase.cpp */, > 514C76600CE923A1007EF3CD /* ProtectionSpaceBase.h */, >@@ -19113,7 +19109,6 @@ > 514C76430CE9234E007EF3CD /* AuthenticationMac.mm */, > E164A2EB191AE6350010737D /* BlobDataFileReferenceMac.mm */, > 5F2DBBE7178E332D00141486 /* CertificateInfoMac.mm */, >- E1424C8F164B460B00F32D40 /* CookieJarMac.mm */, > E13F01F01270E19000DFBA71 /* CookieStorageMac.mm */, > E1B4CD2410B322E200BFFD7E /* CredentialStorageMac.mm */, > 514C76440CE9234E007EF3CD /* FormDataStreamMac.h */, >@@ -29715,7 +29710,6 @@ > 493E5E0912D6420500020081 /* PlatformCALayerClient.h in Headers */, > 2D70BA1318074DDF0001908A /* PlatformCALayerCocoa.h in Headers */, > A14978711ABAF3A500CEF7E4 /* PlatformContentFilter.h in Headers */, >- E1424C8A164B3B4E00F32D40 /* PlatformCookieJar.h in Headers */, > BC5C762B1497FE1400BC4775 /* PlatformEvent.h in Headers */, > 26601EBF14B3B9AD0012C0FE /* PlatformEventFactoryIOS.h in Headers */, > BCAA487014A052530088FAC4 /* PlatformEventFactoryMac.h in Headers */, >@@ -29894,8 +29888,6 @@ > 3C244FEAA375AC633F88BE6F /* RenderLayerModelObject.h in Headers */, > 0BE030A20F3112FB003C1A46 /* RenderLineBoxList.h in Headers */, > BCEA4864097D93020094C9E4 /* RenderLineBreak.h in Headers */, >- 94CFD60A1FE9867E002488AD /* RenderLinesClampFlow.h in Headers */, >- 94CFD60D1FEACEFE002488AD /* RenderLinesClampSet.h in Headers */, > ABB5419F0ACDDFE4002820EB /* RenderListBox.h in Headers */, > A8EA7A520A191A5200A8EF5F /* RenderListItem.h in Headers */, > A8EA7A500A191A5200A8EF5F /* RenderListMarker.h in Headers */, >diff --git a/Source/WebCore/loader/CookieJar.cpp b/Source/WebCore/loader/CookieJar.cpp >index 49b798d7d2ceabd9a8dafedd85348a24aba82c3e..068306744af814bd2760a5e1865a5a9ab4352b13 100644 >--- a/Source/WebCore/loader/CookieJar.cpp >+++ b/Source/WebCore/loader/CookieJar.cpp >@@ -35,7 +35,6 @@ > #include "FrameLoaderClient.h" > #include "NetworkStorageSession.h" > #include "NetworkingContext.h" >-#include "PlatformCookieJar.h" > #include "PlatformStrategies.h" > #include "SameSiteInfo.h" > #include <wtf/SystemTracing.h> >diff --git a/Source/WebCore/platform/Curl.cmake b/Source/WebCore/platform/Curl.cmake >index 10511306964d870ab9dffa15dbde9113d5d093d0..1603ef8616286eab26f73a834b2702f2f0cec725 100644 >--- a/Source/WebCore/platform/Curl.cmake >+++ b/Source/WebCore/platform/Curl.cmake >@@ -5,7 +5,6 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES > list(APPEND WebCore_SOURCES > platform/network/curl/AuthenticationChallengeCurl.cpp > platform/network/curl/CertificateInfo.cpp >- platform/network/curl/CookieJarCurl.cpp > platform/network/curl/CookieJarCurlDatabase.cpp > platform/network/curl/CookieJarDB.cpp > platform/network/curl/CookieStorageCurl.cpp >diff --git a/Source/WebCore/platform/SourcesSoup.txt b/Source/WebCore/platform/SourcesSoup.txt >index d64fcfbea28147dadf430b2ffb4c0fea60b95d8a..c02e49e4e51ef74931f70dd8655d34de2d63e48b 100644 >--- a/Source/WebCore/platform/SourcesSoup.txt >+++ b/Source/WebCore/platform/SourcesSoup.txt >@@ -23,7 +23,6 @@ > > platform/network/soup/AuthenticationChallengeSoup.cpp > platform/network/soup/CertificateInfo.cpp >-platform/network/soup/CookieJarSoup.cpp > platform/network/soup/CookieSoup.cpp > platform/network/soup/CookieStorageSoup.cpp > platform/network/soup/CredentialStorageSoup.cpp >diff --git a/Source/WebCore/platform/network/CacheValidation.cpp b/Source/WebCore/platform/network/CacheValidation.cpp >index 302a8d6789b0c98a960e233ba4282cd2e782673e..910fbf956821fb70c6e63251f0ab4815223f1e02 100644 >--- a/Source/WebCore/platform/network/CacheValidation.cpp >+++ b/Source/WebCore/platform/network/CacheValidation.cpp >@@ -29,7 +29,6 @@ > #include "CookiesStrategy.h" > #include "HTTPHeaderMap.h" > #include "NetworkStorageSession.h" >-#include "PlatformCookieJar.h" > #include "PlatformStrategies.h" > #include "ResourceRequest.h" > #include "ResourceResponse.h" >@@ -338,7 +337,7 @@ static String headerValueForVary(const ResourceRequest& request, const String& h > auto* cookieStrategy = platformStrategies() ? platformStrategies()->cookiesStrategy() : nullptr; > if (!cookieStrategy) { > ASSERT(sessionID == PAL::SessionID::defaultSessionID()); >- return cookieRequestHeaderFieldValue(NetworkStorageSession::defaultStorageSession(), request.firstPartyForCookies(), SameSiteInfo::create(request), request.url(), std::nullopt, std::nullopt, includeSecureCookies).first; >+ return NetworkStorageSession::defaultStorageSession().cookieRequestHeaderFieldValue(request.firstPartyForCookies(), SameSiteInfo::create(request), request.url(), std::nullopt, std::nullopt, includeSecureCookies).first; > } > return cookieStrategy->cookieRequestHeaderFieldValue(sessionID, request.firstPartyForCookies(), SameSiteInfo::create(request), request.url(), std::nullopt, std::nullopt, includeSecureCookies).first; > } >diff --git a/Source/WebCore/platform/network/NetworkStorageSession.h b/Source/WebCore/platform/network/NetworkStorageSession.h >index 6e99393df2b89d6c0ffdadd9f241ab8fc092fb93..08a82dd5a3d089b3ba4f8b0dd5416354287e2517 100644 >--- a/Source/WebCore/platform/network/NetworkStorageSession.h >+++ b/Source/WebCore/platform/network/NetworkStorageSession.h >@@ -30,6 +30,7 @@ > #include <wtf/Function.h> > #include <wtf/HashMap.h> > #include <wtf/HashSet.h> >+#include <wtf/WallTime.h> > #include <wtf/text/WTFString.h> > > #if PLATFORM(COCOA) || USE(CFURLCONNECTION) >@@ -64,6 +65,10 @@ class ResourceRequest; > class SoupNetworkSession; > > struct Cookie; >+struct CookieRequestHeaderFieldProxy; >+struct SameSiteInfo; >+ >+enum class IncludeSecureCookies; > > class NetworkStorageSession { > WTF_MAKE_NONCOPYABLE(NetworkStorageSession); WTF_MAKE_FAST_ALLOCATED; >@@ -137,12 +142,24 @@ public: > NetworkingContext* context() const; > #endif > >+ WEBCORE_EXPORT bool cookiesEnabled() const; > WEBCORE_EXPORT void setCookie(const Cookie&); > WEBCORE_EXPORT void setCookies(const Vector<Cookie>&, const URL&, const URL& mainDocumentURL); >+ WEBCORE_EXPORT void setCookiesFromDOM(const URL& firstParty, const SameSiteInfo&, const URL&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String&) const; > WEBCORE_EXPORT void deleteCookie(const Cookie&); >+ WEBCORE_EXPORT void deleteCookie(const URL&, const String&) const; >+ WEBCORE_EXPORT void deleteAllCookies(); >+ WEBCORE_EXPORT void deleteAllCookiesModifiedSince(WallTime); >+ WEBCORE_EXPORT void deleteCookiesForHostnames(const Vector<String>& cookieHostNames); > WEBCORE_EXPORT Vector<Cookie> getAllCookies(); > WEBCORE_EXPORT Vector<Cookie> getCookies(const URL&); >+ WEBCORE_EXPORT bool getRawCookies(const URL& firstParty, const SameSiteInfo&, const URL&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>&) const; > WEBCORE_EXPORT void flushCookieStore(); >+ WEBCORE_EXPORT void getHostnamesWithCookies(HashSet<String>& hostnames); >+ WEBCORE_EXPORT std::pair<String, bool> cookiesForDOM(const URL& firstParty, const SameSiteInfo&, const URL&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies) const; >+ WEBCORE_EXPORT std::pair<String, bool> cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo&, const URL&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies) const; >+ WEBCORE_EXPORT std::pair<String, bool> cookieRequestHeaderFieldValue(const CookieRequestHeaderFieldProxy&) const; >+ > > private: > static HashMap<PAL::SessionID, std::unique_ptr<NetworkStorageSession>>& globalSessionMap(); >diff --git a/Source/WebCore/platform/network/PlatformCookieJar.h b/Source/WebCore/platform/network/PlatformCookieJar.h >deleted file mode 100644 >index 78943d9cf8181f6380463ee87bf1931744765c3c..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/network/PlatformCookieJar.h >+++ /dev/null >@@ -1,58 +0,0 @@ >-/* >- * Copyright (C) 2003-2017 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. ``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 >- * 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 >- >-#include <wtf/Forward.h> >-#include <wtf/HashSet.h> >-#include <wtf/WallTime.h> >-#include <wtf/text/WTFString.h> >- >-namespace WebCore { >- >-class URL; >-class NetworkStorageSession; >- >-struct Cookie; >-struct CookieRequestHeaderFieldProxy; >-struct SameSiteInfo; >- >-enum class IncludeSecureCookies; >- >-// FIXME: These should probably be NetworkStorageSession member functions. >- >-WEBCORE_EXPORT std::pair<String, bool> cookiesForDOM(const NetworkStorageSession&, const URL& firstParty, const SameSiteInfo&, const URL&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies); >-WEBCORE_EXPORT void setCookiesFromDOM(const NetworkStorageSession&, const URL& firstParty, const SameSiteInfo&, const URL&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String&); >-WEBCORE_EXPORT bool cookiesEnabled(const NetworkStorageSession&); >-WEBCORE_EXPORT std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession&, const URL& firstParty, const SameSiteInfo&, const URL&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies); >-WEBCORE_EXPORT std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession&, const CookieRequestHeaderFieldProxy&); >-WEBCORE_EXPORT bool getRawCookies(const NetworkStorageSession&, const URL& firstParty, const SameSiteInfo&, const URL&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>&); >-WEBCORE_EXPORT void deleteCookie(const NetworkStorageSession&, const URL&, const String&); >-WEBCORE_EXPORT void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames); >-WEBCORE_EXPORT void deleteCookiesForHostnames(const NetworkStorageSession&, const Vector<String>& cookieHostNames); >-WEBCORE_EXPORT void deleteAllCookies(const NetworkStorageSession&); >-WEBCORE_EXPORT void deleteAllCookiesModifiedSince(const NetworkStorageSession&, WallTime); >- >-} >diff --git a/Source/WebCore/platform/network/SocketStreamHandleImpl.cpp b/Source/WebCore/platform/network/SocketStreamHandleImpl.cpp >index 759d63a4685bfdafa727005bb744c8a567ad1ac3..389b6ea0366a69afc65ca30f18571ddf440ae4d3 100644 >--- a/Source/WebCore/platform/network/SocketStreamHandleImpl.cpp >+++ b/Source/WebCore/platform/network/SocketStreamHandleImpl.cpp >@@ -28,7 +28,6 @@ > > #include "CookieRequestHeaderFieldProxy.h" > #include "NetworkStorageSession.h" >-#include "PlatformCookieJar.h" > #include "SocketStreamHandleClient.h" > #include <wtf/Function.h> > >@@ -85,7 +84,7 @@ static std::optional<std::pair<Vector<uint8_t>, bool>> cookieDataForHandshake(co > > String cookieDataString; > bool secureCookiesAccessed = false; >- std::tie(cookieDataString, secureCookiesAccessed) = WebCore::cookieRequestHeaderFieldValue(*networkStorageSession, headerFieldProxy); >+ std::tie(cookieDataString, secureCookiesAccessed) = networkStorageSession->cookieRequestHeaderFieldValue(headerFieldProxy); > if (cookieDataString.isEmpty()) > return std::pair<Vector<uint8_t>, bool> { { }, secureCookiesAccessed }; > >diff --git a/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp b/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp >deleted file mode 100644 >index 1e0c74a27ac068f75a9f3310ff74f967090354c3..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp >+++ /dev/null >@@ -1,325 +0,0 @@ >-/* >- * Copyright (C) 2006-2017 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. ``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 >- * 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. >- */ >- >-#include "config.h" >-#include "PlatformCookieJar.h" >- >-#if USE(CFURLCONNECTION) >- >-#include "Cookie.h" >-#include "CookieRequestHeaderFieldProxy.h" >-#include "CookiesStrategy.h" >-#include "NetworkStorageSession.h" >-#include "NotImplemented.h" >-#include "URL.h" >-#include <CFNetwork/CFHTTPCookiesPriv.h> >-#include <CoreFoundation/CoreFoundation.h> >-#include <WebKitSystemInterface/WebKitSystemInterface.h> >-#include <pal/spi/cf/CFNetworkSPI.h> >-#include <windows.h> >-#include <wtf/SoftLinking.h> >-#include <wtf/cf/TypeCastsCF.h> >-#include <wtf/text/WTFString.h> >- >-enum { >- CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain = 3 >-}; >- >-namespace WTF { >- >-#define DECLARE_CF_TYPE_TRAIT(ClassName) \ >-template <> \ >-struct CFTypeTrait<ClassName##Ref> { \ >-static inline CFTypeID typeID() { return ClassName##GetTypeID(); } \ >-}; >- >-#if COMPILER(CLANG) >-#pragma clang diagnostic push >-#pragma clang diagnostic ignored "-Wdeprecated-declarations" >-#endif >-DECLARE_CF_TYPE_TRAIT(CFHTTPCookie); >-#if COMPILER(CLANG) >-#pragma clang diagnostic pop >-#endif >- >-#undef DECLARE_CF_TYPE_TRAIT >-} // namespace WTF >- >-namespace WebCore { >- >-static const CFStringRef s_setCookieKeyCF = CFSTR("Set-Cookie"); >-static const CFStringRef s_cookieCF = CFSTR("Cookie"); >-static const CFStringRef s_createdCF = CFSTR("Created"); >- >-static inline RetainPtr<CFStringRef> cookieDomain(CFHTTPCookieRef cookie) >-{ >- return adoptCF(CFHTTPCookieCopyDomain(cookie)); >-} >- >-static double canonicalCookieTime(double time) >-{ >- if (!time) >- return time; >- >- return (time + kCFAbsoluteTimeIntervalSince1970) * 1000; >-} >- >-static double cookieCreatedTime(CFHTTPCookieRef cookie) >-{ >- RetainPtr<CFDictionaryRef> props = adoptCF(CFHTTPCookieCopyProperties(cookie)); >- auto value = CFDictionaryGetValue(props.get(), s_createdCF); >- >- auto asNumber = dynamic_cf_cast<CFNumberRef>(value); >- if (asNumber) { >- double asDouble; >- if (CFNumberGetValue(asNumber, kCFNumberFloat64Type, &asDouble)) >- return canonicalCookieTime(asDouble); >- return 0.0; >- } >- >- auto asString = dynamic_cf_cast<CFStringRef>(value); >- if (asString) >- return canonicalCookieTime(CFStringGetDoubleValue(asString)); >- >- return 0.0; >-} >- >-static inline CFAbsoluteTime cookieExpirationTime(CFHTTPCookieRef cookie) >-{ >- return canonicalCookieTime(CFHTTPCookieGetExpirationTime(cookie)); >-} >- >-static inline RetainPtr<CFStringRef> cookieName(CFHTTPCookieRef cookie) >-{ >- return adoptCF(CFHTTPCookieCopyName(cookie)); >-} >- >-static inline RetainPtr<CFStringRef> cookiePath(CFHTTPCookieRef cookie) >-{ >- return adoptCF(CFHTTPCookieCopyPath(cookie)); >-} >- >-static inline RetainPtr<CFStringRef> cookieValue(CFHTTPCookieRef cookie) >-{ >- return adoptCF(CFHTTPCookieCopyValue(cookie)); >-} >- >-static RetainPtr<CFArrayRef> filterCookies(CFArrayRef unfilteredCookies) >-{ >- ASSERT(unfilteredCookies); >- CFIndex count = CFArrayGetCount(unfilteredCookies); >- RetainPtr<CFMutableArrayRef> filteredCookies = adoptCF(CFArrayCreateMutable(0, count, &kCFTypeArrayCallBacks)); >- for (CFIndex i = 0; i < count; ++i) { >- CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(unfilteredCookies, i); >- >- // <rdar://problem/5632883> CFHTTPCookieStorage would store an empty cookie, >- // which would be sent as "Cookie: =". We have a workaround in setCookies() to prevent >- // that, but we also need to avoid sending cookies that were previously stored, and >- // there's no harm to doing this check because such a cookie is never valid. >- if (!CFStringGetLength(cookieName(cookie).get())) >- continue; >- >- if (CFHTTPCookieIsHTTPOnly(cookie)) >- continue; >- >- CFArrayAppendValue(filteredCookies.get(), cookie); >- } >- return filteredCookies; >-} >- >-static RetainPtr<CFArrayRef> copyCookiesForURLWithFirstPartyURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url, IncludeSecureCookies includeSecureCookies) >-{ >- bool secure = includeSecureCookies == IncludeSecureCookies::Yes; >- >- ASSERT(!secure || (secure && url.protocolIs("https"))); >- >- UNUSED_PARAM(firstParty); >- return adoptCF(CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), url.createCFURL().get(), secure)); >-} >- >-static CFArrayRef createCookies(CFDictionaryRef headerFields, CFURLRef url) >-{ >- CFArrayRef parsedCookies = CFHTTPCookieCreateWithResponseHeaderFields(kCFAllocatorDefault, headerFields, url); >- if (!parsedCookies) >- parsedCookies = CFArrayCreate(kCFAllocatorDefault, 0, 0, &kCFTypeArrayCallBacks); >- >- return parsedCookies; >-} >- >-void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& value) >-{ >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >- // <rdar://problem/5632883> CFHTTPCookieStorage stores an empty cookie, which would be sent as "Cookie: =". >- if (value.isEmpty()) >- return; >- >- RetainPtr<CFURLRef> urlCF = url.createCFURL(); >- RetainPtr<CFURLRef> firstPartyForCookiesCF = firstParty.createCFURL(); >- >- // <http://bugs.webkit.org/show_bug.cgi?id=6531>, <rdar://4409034> >- // cookiesWithResponseHeaderFields doesn't parse cookies without a value >- String cookieString = value.contains('=') ? value : value + "="; >- >- RetainPtr<CFStringRef> cookieStringCF = cookieString.createCFString(); >- auto cookieStringCFPtr = cookieStringCF.get(); >- RetainPtr<CFDictionaryRef> headerFieldsCF = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, >- (const void**)&s_setCookieKeyCF, (const void**)&cookieStringCFPtr, 1, >- &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); >- >- RetainPtr<CFArrayRef> unfilteredCookies = adoptCF(createCookies(headerFieldsCF.get(), urlCF.get())); >- CFHTTPCookieStorageSetCookies(session.cookieStorage().get(), filterCookies(unfilteredCookies.get()).get(), urlCF.get(), firstPartyForCookiesCF.get()); >-} >- >-static bool containsSecureCookies(CFArrayRef cookies) >-{ >- CFIndex cookieCount = CFArrayGetCount(cookies); >- while (cookieCount--) { >- if (CFHTTPCookieIsSecure(checked_cf_cast<CFHTTPCookieRef>(CFArrayGetValueAtIndex(cookies, cookieCount)))) >- return true; >- } >- >- return false; >-} >- >-std::pair<String, bool> cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) >-{ >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >- RetainPtr<CFArrayRef> cookiesCF = copyCookiesForURLWithFirstPartyURL(session, firstParty, url, includeSecureCookies); >- >- auto filteredCookies = filterCookies(cookiesCF.get()); >- >- bool didAccessSecureCookies = containsSecureCookies(filteredCookies.get()); >- >- RetainPtr<CFDictionaryRef> headerCF = adoptCF(CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, filteredCookies.get())); >- String cookieString = checked_cf_cast<CFStringRef>(CFDictionaryGetValue(headerCF.get(), s_cookieCF)); >- return { cookieString, didAccessSecureCookies }; >-} >- >-std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) >-{ >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >- RetainPtr<CFArrayRef> cookiesCF = copyCookiesForURLWithFirstPartyURL(session, firstParty, url, includeSecureCookies); >- >- bool didAccessSecureCookies = containsSecureCookies(cookiesCF.get()); >- >- RetainPtr<CFDictionaryRef> headerCF = adoptCF(CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesCF.get())); >- String cookieString = checked_cf_cast<CFStringRef>(CFDictionaryGetValue(headerCF.get(), s_cookieCF)); >- return { cookieString, didAccessSecureCookies }; >-} >- >-std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const CookieRequestHeaderFieldProxy& headerFieldProxy) >-{ >- return cookieRequestHeaderFieldValue(session, headerFieldProxy.firstParty, headerFieldProxy.sameSiteInfo, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, headerFieldProxy.includeSecureCookies); >-} >- >-bool cookiesEnabled(const NetworkStorageSession& session) >-{ >- CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageGetCookieAcceptPolicy(session.cookieStorage().get()); >- return policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyAlways; >-} >- >-bool getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) >-{ >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >- rawCookies.clear(); >- >- auto includeSecureCookies = url.protocolIs("https") ? IncludeSecureCookies::Yes : IncludeSecureCookies::No; >- >- RetainPtr<CFArrayRef> cookiesCF = copyCookiesForURLWithFirstPartyURL(session, firstParty, url, includeSecureCookies); >- >- CFIndex count = CFArrayGetCount(cookiesCF.get()); >- rawCookies.reserveCapacity(count); >- >- for (CFIndex i = 0; i < count; i++) { >- CFHTTPCookieRef cfCookie = checked_cf_cast<CFHTTPCookieRef>(CFArrayGetValueAtIndex(cookiesCF.get(), i)); >- Cookie cookie; >- cookie.name = cookieName(cfCookie).get(); >- cookie.value = cookieValue(cfCookie).get(); >- cookie.domain = cookieDomain(cfCookie).get(); >- cookie.path = cookiePath(cfCookie).get(); >- cookie.created = cookieCreatedTime(cfCookie); >- cookie.expires = cookieExpirationTime(cfCookie); >- cookie.httpOnly = CFHTTPCookieIsHTTPOnly(cfCookie); >- cookie.secure = CFHTTPCookieIsSecure(cfCookie); >- cookie.session = false; // FIXME: Need API for if a cookie is a session cookie. >- rawCookies.uncheckedAppend(WTFMove(cookie)); >- } >- >- return true; >-} >- >-void deleteCookie(const NetworkStorageSession& session, const URL& url, const String& name) >-{ >- RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage(); >- >- RetainPtr<CFURLRef> urlCF = url.createCFURL(); >- >- bool sendSecureCookies = url.protocolIs("https"); >- RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookiesForURL(cookieStorage.get(), urlCF.get(), sendSecureCookies)); >- >- CFIndex count = CFArrayGetCount(cookiesCF.get()); >- for (CFIndex i = 0; i < count; i++) { >- CFHTTPCookieRef cookie = checked_cf_cast<CFHTTPCookieRef>(CFArrayGetValueAtIndex(cookiesCF.get(), i)); >- if (String(cookieName(cookie).get()) == name) { >- CFHTTPCookieStorageDeleteCookie(cookieStorage.get(), cookie); >- break; >- } >- } >-} >- >-void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames) >-{ >- RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookies(session.cookieStorage().get())); >- if (!cookiesCF) >- return; >- >- CFIndex count = CFArrayGetCount(cookiesCF.get()); >- for (CFIndex i = 0; i < count; ++i) { >- CFHTTPCookieRef cookie = checked_cf_cast<CFHTTPCookieRef>(CFArrayGetValueAtIndex(cookiesCF.get(), i)); >- RetainPtr<CFStringRef> domain = cookieDomain(cookie); >- hostnames.add(domain.get()); >- } >-} >- >-void deleteAllCookies(const NetworkStorageSession& session) >-{ >- CFHTTPCookieStorageDeleteAllCookies(session.cookieStorage().get()); >-} >- >-void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& hostnames) >-{ >-} >- >-void deleteAllCookiesModifiedSince(const NetworkStorageSession&, WallTime) >-{ >-} >- >-} // namespace WebCore >- >-#endif // USE(CFURLCONNECTION) >diff --git a/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp b/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp >index 4e3105610c99b9e86f3dab14dd5fcc3c5d31d307..f942ec943e8fb18bf113bcf0d3d61defcaf78604 100644 >--- a/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp >+++ b/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp >@@ -36,6 +36,45 @@ > #include "ResourceRequest.h" > #else > #include <WebKitSystemInterface/WebKitSystemInterface.h> >+#endif >+#if USE(CFURLCONNECTION) >+#include "Cookie.h" >+#include "CookieRequestHeaderFieldProxy.h" >+#include "CookiesStrategy.h" >+#include "NotImplemented.h" >+#include "URL.h" >+#include <CFNetwork/CFHTTPCookiesPriv.h> >+#include <CoreFoundation/CoreFoundation.h> >+#include <pal/spi/cf/CFNetworkSPI.h> >+#include <windows.h> >+#include <wtf/SoftLinking.h> >+#include <wtf/cf/TypeCastsCF.h> >+#include <wtf/text/WTFString.h> >+ >+enum { >+ CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain = 3 >+}; >+ >+namespace WTF { >+ >+#define DECLARE_CF_TYPE_TRAIT(ClassName) \ >+template <> \ >+struct CFTypeTrait<ClassName##Ref> { \ >+static inline CFTypeID typeID() { return ClassName##GetTypeID(); } \ >+}; >+ >+#if COMPILER(CLANG) >+#pragma clang diagnostic push >+#pragma clang diagnostic ignored "-Wdeprecated-declarations" >+#endif >+DECLARE_CF_TYPE_TRAIT(CFHTTPCookie); >+#if COMPILER(CLANG) >+#pragma clang diagnostic pop >+#endif >+ >+#undef DECLARE_CF_TYPE_TRAIT >+} // namespace WTF >+ > #endif > > namespace WebCore { >@@ -402,4 +441,263 @@ void NetworkStorageSession::setCookies(const Vector<Cookie>&, const URL&, const > } > #endif > >+} // namespace WebCore >+ >+#if USE(CFURLCONNECTION) >+ >+namespace WebCore { >+ >+static const CFStringRef s_setCookieKeyCF = CFSTR("Set-Cookie"); >+static const CFStringRef s_cookieCF = CFSTR("Cookie"); >+static const CFStringRef s_createdCF = CFSTR("Created"); >+ >+static inline RetainPtr<CFStringRef> cookieDomain(CFHTTPCookieRef cookie) >+{ >+ return adoptCF(CFHTTPCookieCopyDomain(cookie)); >+} >+ >+static double canonicalCookieTime(double time) >+{ >+ if (!time) >+ return time; >+ >+ return (time + kCFAbsoluteTimeIntervalSince1970) * 1000; >+} >+ >+static double cookieCreatedTime(CFHTTPCookieRef cookie) >+{ >+ RetainPtr<CFDictionaryRef> props = adoptCF(CFHTTPCookieCopyProperties(cookie)); >+ auto value = CFDictionaryGetValue(props.get(), s_createdCF); >+ >+ auto asNumber = dynamic_cf_cast<CFNumberRef>(value); >+ if (asNumber) { >+ double asDouble; >+ if (CFNumberGetValue(asNumber, kCFNumberFloat64Type, &asDouble)) >+ return canonicalCookieTime(asDouble); >+ return 0.0; >+ } >+ >+ auto asString = dynamic_cf_cast<CFStringRef>(value); >+ if (asString) >+ return canonicalCookieTime(CFStringGetDoubleValue(asString)); >+ >+ return 0.0; > } >+ >+static inline CFAbsoluteTime cookieExpirationTime(CFHTTPCookieRef cookie) >+{ >+ return canonicalCookieTime(CFHTTPCookieGetExpirationTime(cookie)); >+} >+ >+static inline RetainPtr<CFStringRef> cookieName(CFHTTPCookieRef cookie) >+{ >+ return adoptCF(CFHTTPCookieCopyName(cookie)); >+} >+ >+static inline RetainPtr<CFStringRef> cookiePath(CFHTTPCookieRef cookie) >+{ >+ return adoptCF(CFHTTPCookieCopyPath(cookie)); >+} >+ >+static inline RetainPtr<CFStringRef> cookieValue(CFHTTPCookieRef cookie) >+{ >+ return adoptCF(CFHTTPCookieCopyValue(cookie)); >+} >+ >+static RetainPtr<CFArrayRef> filterCookies(CFArrayRef unfilteredCookies) >+{ >+ ASSERT(unfilteredCookies); >+ CFIndex count = CFArrayGetCount(unfilteredCookies); >+ RetainPtr<CFMutableArrayRef> filteredCookies = adoptCF(CFArrayCreateMutable(0, count, &kCFTypeArrayCallBacks)); >+ for (CFIndex i = 0; i < count; ++i) { >+ CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(unfilteredCookies, i); >+ >+ // <rdar://problem/5632883> CFHTTPCookieStorage would store an empty cookie, >+ // which would be sent as "Cookie: =". We have a workaround in setCookies() to prevent >+ // that, but we also need to avoid sending cookies that were previously stored, and >+ // there's no harm to doing this check because such a cookie is never valid. >+ if (!CFStringGetLength(cookieName(cookie).get())) >+ continue; >+ >+ if (CFHTTPCookieIsHTTPOnly(cookie)) >+ continue; >+ >+ CFArrayAppendValue(filteredCookies.get(), cookie); >+ } >+ return filteredCookies; >+} >+ >+static RetainPtr<CFArrayRef> copyCookiesForURLWithFirstPartyURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url, IncludeSecureCookies includeSecureCookies) >+{ >+ bool secure = includeSecureCookies == IncludeSecureCookies::Yes; >+ >+ ASSERT(!secure || (secure && url.protocolIs("https"))); >+ >+ UNUSED_PARAM(firstParty); >+ return adoptCF(CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), url.createCFURL().get(), secure)); >+} >+ >+static CFArrayRef createCookies(CFDictionaryRef headerFields, CFURLRef url) >+{ >+ CFArrayRef parsedCookies = CFHTTPCookieCreateWithResponseHeaderFields(kCFAllocatorDefault, headerFields, url); >+ if (!parsedCookies) >+ parsedCookies = CFArrayCreate(kCFAllocatorDefault, 0, 0, &kCFTypeArrayCallBacks); >+ >+ return parsedCookies; >+} >+ >+void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& value) const >+{ >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+ // <rdar://problem/5632883> CFHTTPCookieStorage stores an empty cookie, which would be sent as "Cookie: =". >+ if (value.isEmpty()) >+ return; >+ >+ RetainPtr<CFURLRef> urlCF = url.createCFURL(); >+ RetainPtr<CFURLRef> firstPartyForCookiesCF = firstParty.createCFURL(); >+ >+ // <http://bugs.webkit.org/show_bug.cgi?id=6531>, <rdar://4409034> >+ // cookiesWithResponseHeaderFields doesn't parse cookies without a value >+ String cookieString = value.contains('=') ? value : value + "="; >+ >+ RetainPtr<CFStringRef> cookieStringCF = cookieString.createCFString(); >+ auto cookieStringCFPtr = cookieStringCF.get(); >+ RetainPtr<CFDictionaryRef> headerFieldsCF = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, >+ (const void**)&s_setCookieKeyCF, (const void**)&cookieStringCFPtr, 1, >+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); >+ >+ RetainPtr<CFArrayRef> unfilteredCookies = adoptCF(createCookies(headerFieldsCF.get(), urlCF.get())); >+ CFHTTPCookieStorageSetCookies(cookieStorage().get(), filterCookies(unfilteredCookies.get()).get(), urlCF.get(), firstPartyForCookiesCF.get()); >+} >+ >+static bool containsSecureCookies(CFArrayRef cookies) >+{ >+ CFIndex cookieCount = CFArrayGetCount(cookies); >+ while (cookieCount--) { >+ if (CFHTTPCookieIsSecure(checked_cf_cast<CFHTTPCookieRef>(CFArrayGetValueAtIndex(cookies, cookieCount)))) >+ return true; >+ } >+ >+ return false; >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookiesForDOM(const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const >+{ >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+ RetainPtr<CFArrayRef> cookiesCF = copyCookiesForURLWithFirstPartyURL(*this, firstParty, url, includeSecureCookies); >+ >+ auto filteredCookies = filterCookies(cookiesCF.get()); >+ >+ bool didAccessSecureCookies = containsSecureCookies(filteredCookies.get()); >+ >+ RetainPtr<CFDictionaryRef> headerCF = adoptCF(CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, filteredCookies.get())); >+ String cookieString = checked_cf_cast<CFStringRef>(CFDictionaryGetValue(headerCF.get(), s_cookieCF)); >+ return { cookieString, didAccessSecureCookies }; >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const >+{ >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+ RetainPtr<CFArrayRef> cookiesCF = copyCookiesForURLWithFirstPartyURL(*this, firstParty, url, includeSecureCookies); >+ >+ bool didAccessSecureCookies = containsSecureCookies(cookiesCF.get()); >+ >+ RetainPtr<CFDictionaryRef> headerCF = adoptCF(CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesCF.get())); >+ String cookieString = checked_cf_cast<CFStringRef>(CFDictionaryGetValue(headerCF.get(), s_cookieCF)); >+ return { cookieString, didAccessSecureCookies }; >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const CookieRequestHeaderFieldProxy& headerFieldProxy) const >+{ >+ return cookieRequestHeaderFieldValue(headerFieldProxy.firstParty, headerFieldProxy.sameSiteInfo, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, headerFieldProxy.includeSecureCookies); >+} >+ >+bool NetworkStorageSession::cookiesEnabled() const >+{ >+ CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage().get()); >+ return policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyExclusivelyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyAlways; >+} >+ >+bool NetworkStorageSession::getRawCookies(const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) const >+{ >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+ rawCookies.clear(); >+ >+ auto includeSecureCookies = url.protocolIs("https") ? IncludeSecureCookies::Yes : IncludeSecureCookies::No; >+ >+ RetainPtr<CFArrayRef> cookiesCF = copyCookiesForURLWithFirstPartyURL(*this, firstParty, url, includeSecureCookies); >+ >+ CFIndex count = CFArrayGetCount(cookiesCF.get()); >+ rawCookies.reserveCapacity(count); >+ >+ for (CFIndex i = 0; i < count; i++) { >+ CFHTTPCookieRef cfCookie = checked_cf_cast<CFHTTPCookieRef>(CFArrayGetValueAtIndex(cookiesCF.get(), i)); >+ Cookie cookie; >+ cookie.name = cookieName(cfCookie).get(); >+ cookie.value = cookieValue(cfCookie).get(); >+ cookie.domain = cookieDomain(cfCookie).get(); >+ cookie.path = cookiePath(cfCookie).get(); >+ cookie.created = cookieCreatedTime(cfCookie); >+ cookie.expires = cookieExpirationTime(cfCookie); >+ cookie.httpOnly = CFHTTPCookieIsHTTPOnly(cfCookie); >+ cookie.secure = CFHTTPCookieIsSecure(cfCookie); >+ cookie.session = false; // FIXME: Need API for if a cookie is a session cookie. >+ rawCookies.uncheckedAppend(WTFMove(cookie)); >+ } >+ >+ return true; >+} >+ >+void NetworkStorageSession::deleteCookie(const URL& url, const String& name) const >+{ >+ RetainPtr<CFHTTPCookieStorageRef> cookieStorage = this->cookieStorage(); >+ >+ RetainPtr<CFURLRef> urlCF = url.createCFURL(); >+ >+ bool sendSecureCookies = url.protocolIs("https"); >+ RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookiesForURL(cookieStorage.get(), urlCF.get(), sendSecureCookies)); >+ >+ CFIndex count = CFArrayGetCount(cookiesCF.get()); >+ for (CFIndex i = 0; i < count; i++) { >+ CFHTTPCookieRef cookie = checked_cf_cast<CFHTTPCookieRef>(CFArrayGetValueAtIndex(cookiesCF.get(), i)); >+ if (String(cookieName(cookie).get()) == name) { >+ CFHTTPCookieStorageDeleteCookie(cookieStorage.get(), cookie); >+ break; >+ } >+ } >+} >+ >+void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& hostnames) >+{ >+ RetainPtr<CFArrayRef> cookiesCF = adoptCF(CFHTTPCookieStorageCopyCookies(cookieStorage().get())); >+ if (!cookiesCF) >+ return; >+ >+ CFIndex count = CFArrayGetCount(cookiesCF.get()); >+ for (CFIndex i = 0; i < count; ++i) { >+ CFHTTPCookieRef cookie = checked_cf_cast<CFHTTPCookieRef>(CFArrayGetValueAtIndex(cookiesCF.get(), i)); >+ RetainPtr<CFStringRef> domain = cookieDomain(cookie); >+ hostnames.add(domain.get()); >+ } >+} >+ >+void NetworkStorageSession::deleteAllCookies() >+{ >+ CFHTTPCookieStorageDeleteAllCookies(cookieStorage().get()); >+} >+ >+void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& hostnames) >+{ >+} >+ >+void NetworkStorageSession::deleteAllCookiesModifiedSince(WallTime) >+{ >+} >+ >+} // namespace WebCore >+ >+#endif // USE(CFURLCONNECTION) >diff --git a/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm b/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm >index 3a3df0fa5036ca1599ba323b051ab303291bfb94..385c44b99ff5cb633142e3381fa2ade12111c14b 100644 >--- a/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm >+++ b/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm >@@ -27,11 +27,27 @@ > #import "NetworkStorageSession.h" > > #import "Cookie.h" >+#import "CookieRequestHeaderFieldProxy.h" > #import "CookieStorageObserver.h" >+#import "CookiesStrategy.h" >+#import "SameSiteInfo.h" > #import "URL.h" > #import <pal/spi/cf/CFNetworkSPI.h> > #import <wtf/BlockObjCExceptions.h> >+#import <wtf/Optional.h> > #import <wtf/ProcessPrivilege.h> >+#import <wtf/text/StringBuilder.h> >+ >+@interface NSURL () >+- (CFURLRef)_cfurl; >+@end >+ >+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >+@interface NSHTTPCookieStorage (Staging) >+- (void)_getCookiesForURL:(NSURL *)url mainDocumentURL:(NSURL *)mainDocumentURL partition:(NSString *)partition policyProperties:(NSDictionary*)props completionHandler:(void (^)(NSArray *))completionHandler; >+- (void)_setCookies:(NSArray *)cookies forURL:(NSURL *)URL mainDocumentURL:(NSURL *)mainDocumentURL policyProperties:(NSDictionary*) props; >+@end >+#endif > > namespace WebCore { > >@@ -150,4 +166,420 @@ CFURLStorageSessionRef createPrivateStorageSession(CFStringRef identifier) > return storageSession.leakRef(); > } > >+static NSArray *httpCookies(CFHTTPCookieStorageRef cookieStorage) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ if (!cookieStorage) >+ return [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]; >+ >+ auto cookies = adoptCF(CFHTTPCookieStorageCopyCookies(cookieStorage)); >+ return [NSHTTPCookie _cf2nsCookies:cookies.get()]; >+} >+ >+static void deleteHTTPCookie(CFHTTPCookieStorageRef cookieStorage, NSHTTPCookie *cookie) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ if (!cookieStorage) { >+ [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie]; >+ return; >+ } >+ >+ CFHTTPCookieStorageDeleteCookie(cookieStorage, [cookie _GetInternalCFHTTPCookie]); >+} >+ >+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >+static RetainPtr<NSDictionary> policyProperties(const SameSiteInfo& sameSiteInfo, NSURL *url) >+{ >+ static NSURL *emptyURL = [[NSURL alloc] initWithString:@""]; >+ NSDictionary *policyProperties = @{ >+ @"_kCFHTTPCookiePolicyPropertySiteForCookies": sameSiteInfo.isSameSite ? url : emptyURL, >+ @"_kCFHTTPCookiePolicyPropertyIsTopLevelNavigation": [NSNumber numberWithBool:sameSiteInfo.isTopSite], >+ }; >+ return policyProperties; >+} >+#endif >+ >+static NSArray *cookiesForURL(NSHTTPCookieStorage *storage, NSURL *url, NSURL *mainDocumentURL, const std::optional<SameSiteInfo>& sameSiteInfo, NSString *partition = nullptr) >+{ >+ // The _getCookiesForURL: method calls the completionHandler synchronously. We use std::optional<> to ensure this invariant. >+ std::optional<RetainPtr<NSArray *>> cookiesPtr; >+ auto completionHandler = [&cookiesPtr] (NSArray *cookies) { >+ cookiesPtr = retainPtr(cookies); >+ }; >+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >+ if ([storage respondsToSelector:@selector(_getCookiesForURL:mainDocumentURL:partition:policyProperties:completionHandler:)]) >+ [storage _getCookiesForURL:url mainDocumentURL:mainDocumentURL partition:partition policyProperties:sameSiteInfo ? policyProperties(sameSiteInfo.value(), url).get() : nullptr completionHandler:completionHandler]; >+ else >+ [storage _getCookiesForURL:url mainDocumentURL:mainDocumentURL partition:partition completionHandler:completionHandler]; >+#else >+ [storage _getCookiesForURL:url mainDocumentURL:mainDocumentURL partition:partition completionHandler:completionHandler]; >+ UNUSED_PARAM(sameSiteInfo); >+#endif >+ ASSERT(!!cookiesPtr); >+ return cookiesPtr->autorelease(); >+} >+ >+static void setHTTPCookiesForURL(CFHTTPCookieStorageRef cookieStorage, NSArray *cookies, NSURL *url, NSURL *mainDocumentURL, const SameSiteInfo& sameSiteInfo) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ if (!cookieStorage) { >+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >+ if ([NSHTTPCookieStorage instancesRespondToSelector:@selector(_setCookies:forURL:mainDocumentURL:policyProperties:)]) >+ [[NSHTTPCookieStorage sharedHTTPCookieStorage] _setCookies:cookies forURL:url mainDocumentURL:mainDocumentURL policyProperties:policyProperties(sameSiteInfo, url).get()]; >+ else >+#endif >+ [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:cookies forURL:url mainDocumentURL:mainDocumentURL]; >+ return; >+ } >+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >+ if ([NSHTTPCookieStorage instancesRespondToSelector:@selector(_setCookies:forURL:mainDocumentURL:policyProperties:)]) { >+ // FIXME: Stop creating a new NSHTTPCookieStorage object each time we want to query the cookie jar. >+ // NetworkStorageSession could instead keep a NSHTTPCookieStorage object for us. >+ RetainPtr<NSHTTPCookieStorage> nsCookieStorage = adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:cookieStorage]); >+ [nsCookieStorage _setCookies:cookies forURL:url mainDocumentURL:mainDocumentURL policyProperties:policyProperties(sameSiteInfo, url).get()]; >+ } else { >+#endif >+ auto cfCookies = adoptCF([NSHTTPCookie _ns2cfCookies:cookies]); >+ CFHTTPCookieStorageSetCookies(cookieStorage, cfCookies.get(), [url _cfurl], [mainDocumentURL _cfurl]); >+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >+ } >+#else >+ UNUSED_PARAM(sameSiteInfo); >+#endif >+} >+ >+static NSArray *httpCookiesForURL(CFHTTPCookieStorageRef cookieStorage, NSURL *firstParty, const std::optional<SameSiteInfo>& sameSiteInfo, NSURL *url) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ if (!cookieStorage) >+ cookieStorage = _CFHTTPCookieStorageGetDefault(kCFAllocatorDefault); >+ >+ // FIXME: Stop creating a new NSHTTPCookieStorage object each time we want to query the cookie jar. >+ // NetworkStorageSession could instead keep a NSHTTPCookieStorage object for us. >+ RetainPtr<NSHTTPCookieStorage> nsCookieStorage = adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:cookieStorage]); >+ return cookiesForURL(nsCookieStorage.get(), url, firstParty, sameSiteInfo); >+} >+ >+static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ NSUInteger count = [unfilteredCookies count]; >+ RetainPtr<NSMutableArray> filteredCookies = adoptNS([[NSMutableArray alloc] initWithCapacity:count]); >+ >+ for (NSUInteger i = 0; i < count; ++i) { >+ NSHTTPCookie *cookie = (NSHTTPCookie *)[unfilteredCookies objectAtIndex:i]; >+ >+ // <rdar://problem/5632883> On 10.5, NSHTTPCookieStorage would store an empty cookie, >+ // which would be sent as "Cookie: =". We have a workaround in setCookies() to prevent >+ // that, but we also need to avoid sending cookies that were previously stored, and >+ // there's no harm to doing this check because such a cookie is never valid. >+ if (![[cookie name] length]) >+ continue; >+ >+ if ([cookie isHTTPOnly]) >+ continue; >+ >+ [filteredCookies.get() addObject:cookie]; >+ } >+ >+ return filteredCookies; >+} >+ >+#if HAVE(CFNETWORK_STORAGE_PARTITIONING) >+ >+static NSArray *applyPartitionToCookies(NSString *partition, NSArray *cookies) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ >+ // FIXME 24747739: CFNetwork should expose this key as SPI >+ static NSString * const partitionKey = @"StoragePartition"; >+ >+ NSMutableArray *partitionedCookies = [NSMutableArray arrayWithCapacity:cookies.count]; >+ for (NSHTTPCookie *cookie in cookies) { >+ RetainPtr<NSMutableDictionary> properties = adoptNS([cookie.properties mutableCopy]); >+ [properties setObject:partition forKey:partitionKey]; >+ [partitionedCookies addObject:[NSHTTPCookie cookieWithProperties:properties.get()]]; >+ } >+ >+ return partitionedCookies; >+} >+ >+static bool cookiesAreBlockedForURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url) >+{ >+ return session.shouldBlockCookies(firstParty, url); >+} >+ >+static NSArray *cookiesInPartitionForURL(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ String partition = session.cookieStoragePartition(firstParty, url, frameID, pageID); >+ if (partition.isEmpty()) >+ return nil; >+ >+ // FIXME: Stop creating a new NSHTTPCookieStorage object each time we want to query the cookie jar. >+ // NetworkStorageSession could instead keep a NSHTTPCookieStorage object for us. >+ RetainPtr<NSHTTPCookieStorage> cookieStorage; >+ if (auto storage = session.cookieStorage()) >+ cookieStorage = adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:storage.get()]); >+ else >+ cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; >+ return cookiesForURL(cookieStorage.get(), url, firstParty, sameSiteInfo, partition); >+} >+ >+#endif // HAVE(CFNETWORK_STORAGE_PARTITIONING) >+ >+static NSArray *cookiesForURL(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) >+{ >+#if HAVE(CFNETWORK_STORAGE_PARTITIONING) >+ if (cookiesAreBlockedForURL(session, firstParty, url)) >+ return nil; >+ >+ if (NSArray *cookies = cookiesInPartitionForURL(session, firstParty, sameSiteInfo, url, frameID, pageID)) >+ return cookies; >+#else >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+#endif >+ return httpCookiesForURL(session.cookieStorage().get(), firstParty, sameSiteInfo, url); >+} >+ >+enum IncludeHTTPOnlyOrNot { DoNotIncludeHTTPOnly, IncludeHTTPOnly }; >+static std::pair<String, bool> cookiesForSession(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeHTTPOnlyOrNot includeHTTPOnly, IncludeSecureCookies includeSecureCookies) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ NSArray *cookies = cookiesForURL(session, firstParty, sameSiteInfo, url, frameID, pageID); >+ if (![cookies count]) >+ return { String(), false }; // Return a null string, not an empty one that StringBuilder would create below. >+ >+ StringBuilder cookiesBuilder; >+ bool didAccessSecureCookies = false; >+ for (NSHTTPCookie *cookie in cookies) { >+ if (![[cookie name] length]) >+ continue; >+ >+ if (!includeHTTPOnly && [cookie isHTTPOnly]) >+ continue; >+ >+ if ([cookie isSecure]) { >+ didAccessSecureCookies = true; >+ if (includeSecureCookies == IncludeSecureCookies::No) >+ continue; >+ } >+ >+ if (!cookiesBuilder.isEmpty()) >+ cookiesBuilder.appendLiteral("; "); >+ >+ cookiesBuilder.append([cookie name]); >+ cookiesBuilder.append('='); >+ cookiesBuilder.append([cookie value]); >+ } >+ return { cookiesBuilder.toString(), didAccessSecureCookies }; >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+ return { String(), false }; >+} >+ >+static void deleteAllHTTPCookies(CFHTTPCookieStorageRef cookieStorage) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ >+ if (!cookieStorage) { >+ NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; >+ NSArray *cookies = [cookieStorage cookies]; >+ if (!cookies) >+ return; >+ >+ for (NSHTTPCookie *cookie in cookies) >+ [cookieStorage deleteCookie:cookie]; >+ return; >+ } >+ >+ CFHTTPCookieStorageDeleteAllCookies(cookieStorage); >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookiesForDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const >+{ >+ return cookiesForSession(*this, firstParty, sameSiteInfo, url, frameID, pageID, DoNotIncludeHTTPOnly, includeSecureCookies); >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const >+{ >+ return cookiesForSession(*this, firstParty, sameSiteInfo, url, frameID, pageID, IncludeHTTPOnly, includeSecureCookies); >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const CookieRequestHeaderFieldProxy& headerFieldProxy) const >+{ >+ return cookiesForSession(*this, headerFieldProxy.firstParty, headerFieldProxy.sameSiteInfo, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, IncludeHTTPOnly, headerFieldProxy.includeSecureCookies); >+} >+ >+void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& cookieStr) const >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ // <rdar://problem/5632883> On 10.5, NSHTTPCookieStorage would store an empty cookie, >+ // which would be sent as "Cookie: =". >+ if (cookieStr.isEmpty()) >+ return; >+ >+ // <http://bugs.webkit.org/show_bug.cgi?id=6531>, <rdar://4409034> >+ // cookiesWithResponseHeaderFields doesn't parse cookies without a value >+ String cookieString = cookieStr.contains('=') ? cookieStr : cookieStr + "="; >+ >+ NSURL *cookieURL = url; >+ NSDictionary *headerFields = [NSDictionary dictionaryWithObject:cookieString forKey:@"Set-Cookie"]; >+ >+#if PLATFORM(MAC) >+ NSArray *unfilteredCookies = [NSHTTPCookie _parsedCookiesWithResponseHeaderFields:headerFields forURL:cookieURL]; >+#else >+ NSArray *unfilteredCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:headerFields forURL:cookieURL]; >+#endif >+ >+ RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies); >+ ASSERT([filteredCookies.get() count] <= 1); >+ >+#if HAVE(CFNETWORK_STORAGE_PARTITIONING) >+ if (shouldBlockCookies(firstParty, url)) >+ return; >+ >+ String partition = cookieStoragePartition(firstParty, url, frameID, pageID); >+ if (!partition.isEmpty()) >+ filteredCookies = applyPartitionToCookies(partition, filteredCookies.get()); >+#else >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+#endif >+ >+ setHTTPCookiesForURL(cookieStorage().get(), filteredCookies.get(), cookieURL, firstParty, sameSiteInfo); >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+} >+ >+static NSHTTPCookieAcceptPolicy httpCookieAcceptPolicy(CFHTTPCookieStorageRef cookieStorage) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ >+ if (!cookieStorage) >+ return [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy]; >+ >+ return static_cast<NSHTTPCookieAcceptPolicy>(CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage)); >+} >+ >+bool NetworkStorageSession::cookiesEnabled() const >+{ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ NSHTTPCookieAcceptPolicy cookieAcceptPolicy = httpCookieAcceptPolicy(cookieStorage().get()); >+ return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain; >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+ return false; >+} >+ >+bool NetworkStorageSession::getRawCookies(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) const >+{ >+ rawCookies.clear(); >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ NSArray *cookies = cookiesForURL(*this, firstParty, sameSiteInfo, url, frameID, pageID); >+ NSUInteger count = [cookies count]; >+ rawCookies.reserveCapacity(count); >+ for (NSUInteger i = 0; i < count; ++i) { >+ NSHTTPCookie *cookie = (NSHTTPCookie *)[cookies objectAtIndex:i]; >+ rawCookies.uncheckedAppend({ cookie }); >+ } >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+ return true; >+} >+ >+void NetworkStorageSession::deleteCookie(const URL& url, const String& cookieName) const >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ RetainPtr<CFHTTPCookieStorageRef> cookieStorage = this->cookieStorage(); >+ NSArray *cookies = httpCookiesForURL(cookieStorage.get(), nil, std::nullopt, url); >+ >+ NSString *cookieNameString = cookieName; >+ >+ NSUInteger count = [cookies count]; >+ for (NSUInteger i = 0; i < count; ++i) { >+ NSHTTPCookie *cookie = (NSHTTPCookie *)[cookies objectAtIndex:i]; >+ if ([[cookie name] isEqualToString:cookieNameString]) >+ deleteHTTPCookie(cookieStorage.get(), cookie); >+ } >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+} >+ >+void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& hostnames) >+{ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ NSArray *cookies = httpCookies(cookieStorage().get()); >+ >+ for (NSHTTPCookie* cookie in cookies) >+ hostnames.add([cookie domain]); >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+} >+ >+void NetworkStorageSession::deleteAllCookies() >+{ >+ deleteAllHTTPCookies(cookieStorage().get()); >+} >+ >+void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& hostnames) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ >+ BEGIN_BLOCK_OBJC_EXCEPTIONS; >+ >+ RetainPtr<CFHTTPCookieStorageRef> cookieStorage = this->cookieStorage(); >+ NSArray *cookies = httpCookies(cookieStorage.get()); >+ if (!cookies) >+ return; >+ >+ HashMap<String, Vector<RetainPtr<NSHTTPCookie>>> cookiesByDomain; >+ for (NSHTTPCookie* cookie in cookies) { >+ auto& cookies = cookiesByDomain.add(cookie.domain, Vector<RetainPtr<NSHTTPCookie>>()).iterator->value; >+ cookies.append(cookie); >+ } >+ >+ for (const auto& hostname : hostnames) { >+ auto it = cookiesByDomain.find(hostname); >+ if (it == cookiesByDomain.end()) >+ continue; >+ >+ for (auto& cookie : it->value) >+ deleteHTTPCookie(cookieStorage.get(), cookie.get()); >+ } >+ >+ [nsCookieStorage() _saveCookies]; >+ >+ END_BLOCK_OBJC_EXCEPTIONS; >+} >+ >+void NetworkStorageSession::deleteAllCookiesModifiedSince(WallTime timePoint) >+{ >+ ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >+ >+ if (![NSHTTPCookieStorage instancesRespondToSelector:@selector(removeCookiesSinceDate:)]) >+ return; >+ >+ NSTimeInterval timeInterval = timePoint.secondsSinceEpoch().seconds(); >+ NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval]; >+ >+ auto *storage = nsCookieStorage(); >+ >+ [storage removeCookiesSinceDate:date]; >+ [storage _saveCookies]; >+} >+ > } // namespace WebCore >diff --git a/Source/WebCore/platform/network/curl/CookieJarCurl.cpp b/Source/WebCore/platform/network/curl/CookieJarCurl.cpp >deleted file mode 100644 >index 5b4a245275824c080d982d960905e444de619096..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/network/curl/CookieJarCurl.cpp >+++ /dev/null >@@ -1,90 +0,0 @@ >-/* >- * Copyright (C) 2011 Apple Inc. All rights reserved. >- * Copyright (C) 2018 Sony Interactive Entertainment Inc. >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Lesser General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Lesser General Public License for more details. >- * >- * You should have received a copy of the GNU Lesser General Public >- * License along with this library; if not, write to the Free Software >- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >- */ >- >-#include "config.h" >-#include "CookieJarCurl.h" >- >-#if USE(CURL) >-#include "Cookie.h" >-#include "CookieRequestHeaderFieldProxy.h" >-#include "NetworkStorageSession.h" >-#include "URL.h" >- >-#include <wtf/text/WTFString.h> >- >-namespace WebCore { >- >-std::pair<String, bool> cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) >-{ >- return session.cookieStorage().cookiesForDOM(session, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >-} >- >-void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& value) >-{ >- session.cookieStorage().setCookiesFromDOM(session, firstParty, sameSiteInfo, url, frameID, pageID, value); >-} >- >-std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) >-{ >- return session.cookieStorage().cookieRequestHeaderFieldValue(session, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >-} >- >-std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const CookieRequestHeaderFieldProxy& headerFieldProxy) >-{ >- return session.cookieStorage().cookieRequestHeaderFieldValue(session, headerFieldProxy.firstParty, headerFieldProxy.sameSiteInfo, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, headerFieldProxy.includeSecureCookies); >-} >- >-bool cookiesEnabled(const NetworkStorageSession& session) >-{ >- return session.cookieStorage().cookiesEnabled(session); >-} >- >-bool getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) >-{ >- return session.cookieStorage().getRawCookies(session, firstParty, sameSiteInfo, url, frameID, pageID, rawCookies); >-} >- >-void deleteCookie(const NetworkStorageSession& session, const URL& url, const String& cookie) >-{ >- session.cookieStorage().deleteCookie(session, url, cookie); >-} >- >-void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames) >-{ >- session.cookieStorage().getHostnamesWithCookies(session, hostnames); >-} >- >-void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& cookieHostNames) >-{ >- session.cookieStorage().deleteCookiesForHostnames(session, cookieHostNames); >-} >- >-void deleteAllCookies(const NetworkStorageSession& session) >-{ >- session.cookieStorage().deleteAllCookies(session); >-} >- >-void deleteAllCookiesModifiedSince(const NetworkStorageSession& session, WallTime since) >-{ >- session.cookieStorage().deleteAllCookiesModifiedSince(session, since); >-} >- >-} >- >-#endif >diff --git a/Source/WebCore/platform/network/curl/CookieJarCurl.h b/Source/WebCore/platform/network/curl/CookieJarCurl.h >index 2aa8dfda1b70e109cfeb8a4bef3b41f4666e68ee..e0b21cc137748a8e16274832607c18d7a48160fe 100644 >--- a/Source/WebCore/platform/network/curl/CookieJarCurl.h >+++ b/Source/WebCore/platform/network/curl/CookieJarCurl.h >@@ -18,10 +18,22 @@ > > #pragma once > >-#include "PlatformCookieJar.h" >+#include <wtf/Forward.h> >+#include <wtf/HashSet.h> >+#include <wtf/WallTime.h> >+#include <wtf/text/WTFString.h> > > namespace WebCore { > >+class URL; >+class NetworkStorageSession; >+ >+struct Cookie; >+struct CookieRequestHeaderFieldProxy; >+struct SameSiteInfo; >+ >+enum class IncludeSecureCookies; >+ > class CookieJarCurl { > public: > virtual std::pair<String, bool> cookiesForDOM(const NetworkStorageSession&, const URL& firstParty, const SameSiteInfo&, const URL&, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies) const = 0; >diff --git a/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp b/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp >index 061df190596e3bb9f1ff9d165b77f7ffaf3cc793..86a41df732c7fe0f2c5e61cb5db35dec45596c6c 100644 >--- a/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp >+++ b/Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp >@@ -31,13 +31,16 @@ > #include "Cookie.h" > #include "CookieJarCurlDatabase.h" > #include "CookieJarDB.h" >+#include "CookieRequestHeaderFieldProxy.h" > #include "CurlContext.h" > #include "FileSystem.h" > #include "NetworkingContext.h" > #include "ResourceHandle.h" >+#include "URL.h" > > #include <wtf/MainThread.h> > #include <wtf/NeverDestroyed.h> >+#include <wtf/text/WTFString.h> > > namespace WebCore { > >@@ -103,6 +106,21 @@ void NetworkStorageSession::switchToNewTestingSession() > // FIXME: Implement for WebKit to use. > } > >+void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& value) const >+{ >+ cookieStorage().setCookiesFromDOM(*this, firstParty, sameSiteInfo, url, frameID, pageID, value); >+} >+ >+bool NetworkStorageSession::cookiesEnabled() const >+{ >+ return cookieStorage().cookiesEnabled(*this); >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookiesForDOM(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const >+{ >+ return cookieStorage().cookiesForDOM(*this, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+} >+ > void NetworkStorageSession::setCookies(const Vector<Cookie>&, const URL&, const URL&) > { > // FIXME: Implement for WebKit to use. >@@ -118,23 +136,63 @@ void NetworkStorageSession::deleteCookie(const Cookie&) > // FIXME: Implement for WebKit to use. > } > >+void NetworkStorageSession::deleteCookie(const URL& url, const String& cookie) const >+{ >+ cookieStorage().deleteCookie(*this, url, cookie); >+} >+ >+void NetworkStorageSession::deleteAllCookies() >+{ >+ cookieStorage().deleteAllCookies(*this); >+} >+ >+void NetworkStorageSession::deleteAllCookiesModifiedSince(WallTime since) >+{ >+ cookieStorage().deleteAllCookiesModifiedSince(*this, since); >+} >+ >+void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& cookieHostNames) >+{ >+ cookieStorage().deleteCookiesForHostnames(*this, cookieHostNames); >+} >+ > Vector<Cookie> NetworkStorageSession::getAllCookies() > { > // FIXME: Implement for WebKit to use. > return { }; > } > >+void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& hostnames) >+{ >+ cookieStorage().getHostnamesWithCookies(*this, hostnames); >+} >+ > Vector<Cookie> NetworkStorageSession::getCookies(const URL&) > { > // FIXME: Implement for WebKit to use. > return { }; > } > >+bool NetworkStorageSession::getRawCookies(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) const >+{ >+ return cookieStorage().getRawCookies(*this, firstParty, sameSiteInfo, url, frameID, pageID, rawCookies); >+} >+ > void NetworkStorageSession::flushCookieStore() > { > // FIXME: Implement for WebKit to use. > } > >+std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const >+{ >+ return cookieStorage().cookieRequestHeaderFieldValue(*this, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const CookieRequestHeaderFieldProxy& headerFieldProxy) const >+{ >+ return cookieStorage().cookieRequestHeaderFieldValue(*this, headerFieldProxy.firstParty, headerFieldProxy.sameSiteInfo, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, headerFieldProxy.includeSecureCookies); >+} >+ > } // namespace WebCore > > #endif // USE(CURL) >diff --git a/Source/WebCore/platform/network/mac/CookieJarMac.mm b/Source/WebCore/platform/network/mac/CookieJarMac.mm >deleted file mode 100644 >index c2640bd06df210b6d2d3208265061102f8d92185..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/network/mac/CookieJarMac.mm >+++ /dev/null >@@ -1,470 +0,0 @@ >-/* >- * Copyright (C) 2003-2018 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. ``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 >- * 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. >- */ >- >-#import "config.h" >-#import "PlatformCookieJar.h" >- >-#import "CookieRequestHeaderFieldProxy.h" >-#import "CookiesStrategy.h" >-#import "NetworkStorageSession.h" >-#import <pal/spi/cf/CFNetworkSPI.h> >-#import <wtf/BlockObjCExceptions.h> >- >-#import "Cookie.h" >-#import "CookieStorage.h" >-#import "SameSiteInfo.h" >-#import "URL.h" >-#import <wtf/Optional.h> >-#import <wtf/ProcessPrivilege.h> >-#import <wtf/text/StringBuilder.h> >- >-@interface NSURL () >-- (CFURLRef)_cfurl; >-@end >- >-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >-@interface NSHTTPCookieStorage (Staging) >-- (void)_getCookiesForURL:(NSURL *)url mainDocumentURL:(NSURL *)mainDocumentURL partition:(NSString *)partition policyProperties:(NSDictionary*)props completionHandler:(void (^)(NSArray *))completionHandler; >-- (void)_setCookies:(NSArray *)cookies forURL:(NSURL *)URL mainDocumentURL:(NSURL *)mainDocumentURL policyProperties:(NSDictionary*) props; >-@end >-#endif >- >-namespace WebCore { >- >-static NSArray *httpCookies(CFHTTPCookieStorageRef cookieStorage) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- if (!cookieStorage) >- return [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]; >- >- auto cookies = adoptCF(CFHTTPCookieStorageCopyCookies(cookieStorage)); >- return [NSHTTPCookie _cf2nsCookies:cookies.get()]; >-} >- >-static void deleteHTTPCookie(CFHTTPCookieStorageRef cookieStorage, NSHTTPCookie *cookie) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- if (!cookieStorage) { >- [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie]; >- return; >- } >- >- CFHTTPCookieStorageDeleteCookie(cookieStorage, [cookie _GetInternalCFHTTPCookie]); >-} >- >-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >-static RetainPtr<NSDictionary> policyProperties(const SameSiteInfo& sameSiteInfo, NSURL *url) >-{ >- static NSURL *emptyURL = [[NSURL alloc] initWithString:@""]; >- NSDictionary *policyProperties = @{ >- @"_kCFHTTPCookiePolicyPropertySiteForCookies": sameSiteInfo.isSameSite ? url : emptyURL, >- @"_kCFHTTPCookiePolicyPropertyIsTopLevelNavigation": [NSNumber numberWithBool:sameSiteInfo.isTopSite], >- }; >- return policyProperties; >-} >-#endif >- >-static NSArray *cookiesForURL(NSHTTPCookieStorage *storage, NSURL *url, NSURL *mainDocumentURL, const std::optional<SameSiteInfo>& sameSiteInfo, NSString *partition = nullptr) >-{ >- // The _getCookiesForURL: method calls the completionHandler synchronously. We use std::optional<> to ensure this invariant. >- std::optional<RetainPtr<NSArray *>> cookiesPtr; >- auto completionHandler = [&cookiesPtr] (NSArray *cookies) { cookiesPtr = retainPtr(cookies); }; >-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >- if ([storage respondsToSelector:@selector(_getCookiesForURL:mainDocumentURL:partition:policyProperties:completionHandler:)]) >- [storage _getCookiesForURL:url mainDocumentURL:mainDocumentURL partition:partition policyProperties:sameSiteInfo ? policyProperties(sameSiteInfo.value(), url).get() : nullptr completionHandler:completionHandler]; >- else >- [storage _getCookiesForURL:url mainDocumentURL:mainDocumentURL partition:partition completionHandler:completionHandler]; >-#else >- [storage _getCookiesForURL:url mainDocumentURL:mainDocumentURL partition:partition completionHandler:completionHandler]; >- UNUSED_PARAM(sameSiteInfo); >-#endif >- ASSERT(!!cookiesPtr); >- return cookiesPtr->autorelease(); >-} >- >-static void setHTTPCookiesForURL(CFHTTPCookieStorageRef cookieStorage, NSArray *cookies, NSURL *url, NSURL *mainDocumentURL, const SameSiteInfo& sameSiteInfo) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- if (!cookieStorage) { >-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >- if ([NSHTTPCookieStorage instancesRespondToSelector:@selector(_setCookies:forURL:mainDocumentURL:policyProperties:)]) >- [[NSHTTPCookieStorage sharedHTTPCookieStorage] _setCookies:cookies forURL:url mainDocumentURL:mainDocumentURL policyProperties:policyProperties(sameSiteInfo, url).get()]; >- else >-#endif >- [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:cookies forURL:url mainDocumentURL:mainDocumentURL]; >- return; >- } >-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >- if ([NSHTTPCookieStorage instancesRespondToSelector:@selector(_setCookies:forURL:mainDocumentURL:policyProperties:)]) { >- // FIXME: Stop creating a new NSHTTPCookieStorage object each time we want to query the cookie jar. >- // NetworkStorageSession could instead keep a NSHTTPCookieStorage object for us. >- RetainPtr<NSHTTPCookieStorage> nsCookieStorage = adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:cookieStorage]); >- [nsCookieStorage _setCookies:cookies forURL:url mainDocumentURL:mainDocumentURL policyProperties:policyProperties(sameSiteInfo, url).get()]; >- } else { >-#endif >- auto cfCookies = adoptCF([NSHTTPCookie _ns2cfCookies:cookies]); >- CFHTTPCookieStorageSetCookies(cookieStorage, cfCookies.get(), [url _cfurl], [mainDocumentURL _cfurl]); >-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) >- } >-#else >- UNUSED_PARAM(sameSiteInfo); >-#endif >-} >- >-static NSArray *httpCookiesForURL(CFHTTPCookieStorageRef cookieStorage, NSURL *firstParty, const std::optional<SameSiteInfo>& sameSiteInfo, NSURL *url) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- if (!cookieStorage) >- cookieStorage = _CFHTTPCookieStorageGetDefault(kCFAllocatorDefault); >- >- // FIXME: Stop creating a new NSHTTPCookieStorage object each time we want to query the cookie jar. >- // NetworkStorageSession could instead keep a NSHTTPCookieStorage object for us. >- RetainPtr<NSHTTPCookieStorage> nsCookieStorage = adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:cookieStorage]); >- return cookiesForURL(nsCookieStorage.get(), url, firstParty, sameSiteInfo); >-} >- >-static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- NSUInteger count = [unfilteredCookies count]; >- RetainPtr<NSMutableArray> filteredCookies = adoptNS([[NSMutableArray alloc] initWithCapacity:count]); >- >- for (NSUInteger i = 0; i < count; ++i) { >- NSHTTPCookie *cookie = (NSHTTPCookie *)[unfilteredCookies objectAtIndex:i]; >- >- // <rdar://problem/5632883> On 10.5, NSHTTPCookieStorage would store an empty cookie, >- // which would be sent as "Cookie: =". We have a workaround in setCookies() to prevent >- // that, but we also need to avoid sending cookies that were previously stored, and >- // there's no harm to doing this check because such a cookie is never valid. >- if (![[cookie name] length]) >- continue; >- >- if ([cookie isHTTPOnly]) >- continue; >- >- [filteredCookies.get() addObject:cookie]; >- } >- >- return filteredCookies; >-} >- >-#if HAVE(CFNETWORK_STORAGE_PARTITIONING) >- >-static NSArray *applyPartitionToCookies(NSString *partition, NSArray *cookies) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- >- // FIXME 24747739: CFNetwork should expose this key as SPI >- static NSString * const partitionKey = @"StoragePartition"; >- >- NSMutableArray *partitionedCookies = [NSMutableArray arrayWithCapacity:cookies.count]; >- for (NSHTTPCookie *cookie in cookies) { >- RetainPtr<NSMutableDictionary> properties = adoptNS([cookie.properties mutableCopy]); >- [properties setObject:partition forKey:partitionKey]; >- [partitionedCookies addObject:[NSHTTPCookie cookieWithProperties:properties.get()]]; >- } >- >- return partitionedCookies; >-} >- >-static bool cookiesAreBlockedForURL(const NetworkStorageSession& session, const URL& firstParty, const URL& url) >-{ >- return session.shouldBlockCookies(firstParty, url); >-} >- >-static NSArray *cookiesInPartitionForURL(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- String partition = session.cookieStoragePartition(firstParty, url, frameID, pageID); >- if (partition.isEmpty()) >- return nil; >- >- // FIXME: Stop creating a new NSHTTPCookieStorage object each time we want to query the cookie jar. >- // NetworkStorageSession could instead keep a NSHTTPCookieStorage object for us. >- RetainPtr<NSHTTPCookieStorage> cookieStorage; >- if (auto storage = session.cookieStorage()) >- cookieStorage = adoptNS([[NSHTTPCookieStorage alloc] _initWithCFHTTPCookieStorage:storage.get()]); >- else >- cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; >- return cookiesForURL(cookieStorage.get(), url, firstParty, sameSiteInfo, partition); >-} >- >-#endif // HAVE(CFNETWORK_STORAGE_PARTITIONING) >- >-static NSArray *cookiesForURL(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) >-{ >-#if HAVE(CFNETWORK_STORAGE_PARTITIONING) >- if (cookiesAreBlockedForURL(session, firstParty, url)) >- return nil; >- >- if (NSArray *cookies = cookiesInPartitionForURL(session, firstParty, sameSiteInfo, url, frameID, pageID)) >- return cookies; >-#else >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >-#endif >- return httpCookiesForURL(session.cookieStorage().get(), firstParty, sameSiteInfo, url); >-} >- >-enum IncludeHTTPOnlyOrNot { DoNotIncludeHTTPOnly, IncludeHTTPOnly }; >-static std::pair<String, bool> cookiesForSession(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeHTTPOnlyOrNot includeHTTPOnly, IncludeSecureCookies includeSecureCookies) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- >- BEGIN_BLOCK_OBJC_EXCEPTIONS; >- >- NSArray *cookies = cookiesForURL(session, firstParty, sameSiteInfo, url, frameID, pageID); >- if (![cookies count]) >- return { String(), false }; // Return a null string, not an empty one that StringBuilder would create below. >- >- StringBuilder cookiesBuilder; >- bool didAccessSecureCookies = false; >- for (NSHTTPCookie *cookie in cookies) { >- if (![[cookie name] length]) >- continue; >- >- if (!includeHTTPOnly && [cookie isHTTPOnly]) >- continue; >- >- if ([cookie isSecure]) { >- didAccessSecureCookies = true; >- if (includeSecureCookies == IncludeSecureCookies::No) >- continue; >- } >- >- if (!cookiesBuilder.isEmpty()) >- cookiesBuilder.appendLiteral("; "); >- >- cookiesBuilder.append([cookie name]); >- cookiesBuilder.append('='); >- cookiesBuilder.append([cookie value]); >- } >- return { cookiesBuilder.toString(), didAccessSecureCookies }; >- >- END_BLOCK_OBJC_EXCEPTIONS; >- return { String(), false }; >-} >- >-static void deleteAllHTTPCookies(CFHTTPCookieStorageRef cookieStorage) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- >- if (!cookieStorage) { >- NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; >- NSArray *cookies = [cookieStorage cookies]; >- if (!cookies) >- return; >- >- for (NSHTTPCookie *cookie in cookies) >- [cookieStorage deleteCookie:cookie]; >- return; >- } >- >- CFHTTPCookieStorageDeleteAllCookies(cookieStorage); >-} >- >-std::pair<String, bool> cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) >-{ >- return cookiesForSession(session, firstParty, sameSiteInfo, url, frameID, pageID, DoNotIncludeHTTPOnly, includeSecureCookies); >-} >- >-std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) >-{ >- return cookiesForSession(session, firstParty, sameSiteInfo, url, frameID, pageID, IncludeHTTPOnly, includeSecureCookies); >-} >- >-std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const CookieRequestHeaderFieldProxy& headerFieldProxy) >-{ >- return cookiesForSession(session, headerFieldProxy.firstParty, headerFieldProxy.sameSiteInfo, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, IncludeHTTPOnly, headerFieldProxy.includeSecureCookies); >-} >- >-void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& cookieStr) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- >- BEGIN_BLOCK_OBJC_EXCEPTIONS; >- >- // <rdar://problem/5632883> On 10.5, NSHTTPCookieStorage would store an empty cookie, >- // which would be sent as "Cookie: =". >- if (cookieStr.isEmpty()) >- return; >- >- // <http://bugs.webkit.org/show_bug.cgi?id=6531>, <rdar://4409034> >- // cookiesWithResponseHeaderFields doesn't parse cookies without a value >- String cookieString = cookieStr.contains('=') ? cookieStr : cookieStr + "="; >- >- NSURL *cookieURL = url; >- NSDictionary *headerFields = [NSDictionary dictionaryWithObject:cookieString forKey:@"Set-Cookie"]; >- >-#if PLATFORM(MAC) >- NSArray *unfilteredCookies = [NSHTTPCookie _parsedCookiesWithResponseHeaderFields:headerFields forURL:cookieURL]; >-#else >- NSArray *unfilteredCookies = [NSHTTPCookie cookiesWithResponseHeaderFields:headerFields forURL:cookieURL]; >-#endif >- >- RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies); >- ASSERT([filteredCookies.get() count] <= 1); >- >-#if HAVE(CFNETWORK_STORAGE_PARTITIONING) >- if (session.shouldBlockCookies(firstParty, url)) >- return; >- >- String partition = session.cookieStoragePartition(firstParty, url, frameID, pageID); >- if (!partition.isEmpty()) >- filteredCookies = applyPartitionToCookies(partition, filteredCookies.get()); >-#else >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >-#endif >- >- setHTTPCookiesForURL(session.cookieStorage().get(), filteredCookies.get(), cookieURL, firstParty, sameSiteInfo); >- >- END_BLOCK_OBJC_EXCEPTIONS; >-} >- >-static NSHTTPCookieAcceptPolicy httpCookieAcceptPolicy(CFHTTPCookieStorageRef cookieStorage) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- >- if (!cookieStorage) >- return [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy]; >- >- return static_cast<NSHTTPCookieAcceptPolicy>(CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage)); >-} >- >-bool cookiesEnabled(const NetworkStorageSession& session) >-{ >- BEGIN_BLOCK_OBJC_EXCEPTIONS; >- >- NSHTTPCookieAcceptPolicy cookieAcceptPolicy = httpCookieAcceptPolicy(session.cookieStorage().get()); >- return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain; >- >- END_BLOCK_OBJC_EXCEPTIONS; >- return false; >-} >- >-bool getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) >-{ >- rawCookies.clear(); >- BEGIN_BLOCK_OBJC_EXCEPTIONS; >- >- NSArray *cookies = cookiesForURL(session, firstParty, sameSiteInfo, url, frameID, pageID); >- NSUInteger count = [cookies count]; >- rawCookies.reserveCapacity(count); >- for (NSUInteger i = 0; i < count; ++i) { >- NSHTTPCookie *cookie = (NSHTTPCookie *)[cookies objectAtIndex:i]; >- rawCookies.uncheckedAppend({ cookie }); >- } >- >- END_BLOCK_OBJC_EXCEPTIONS; >- return true; >-} >- >-void deleteCookie(const NetworkStorageSession& session, const URL& url, const String& cookieName) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- >- BEGIN_BLOCK_OBJC_EXCEPTIONS; >- >- RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage(); >- NSArray *cookies = httpCookiesForURL(cookieStorage.get(), nil, std::nullopt, url); >- >- NSString *cookieNameString = cookieName; >- >- NSUInteger count = [cookies count]; >- for (NSUInteger i = 0; i < count; ++i) { >- NSHTTPCookie *cookie = (NSHTTPCookie *)[cookies objectAtIndex:i]; >- if ([[cookie name] isEqualToString:cookieNameString]) >- deleteHTTPCookie(cookieStorage.get(), cookie); >- } >- >- END_BLOCK_OBJC_EXCEPTIONS; >-} >- >-void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames) >-{ >- BEGIN_BLOCK_OBJC_EXCEPTIONS; >- >- NSArray *cookies = httpCookies(session.cookieStorage().get()); >- >- for (NSHTTPCookie* cookie in cookies) >- hostnames.add([cookie domain]); >- >- END_BLOCK_OBJC_EXCEPTIONS; >-} >- >-void deleteAllCookies(const NetworkStorageSession& session) >-{ >- deleteAllHTTPCookies(session.cookieStorage().get()); >-} >- >-void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& hostnames) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- >- BEGIN_BLOCK_OBJC_EXCEPTIONS; >- >- RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage(); >- NSArray *cookies = httpCookies(cookieStorage.get()); >- if (!cookies) >- return; >- >- HashMap<String, Vector<RetainPtr<NSHTTPCookie>>> cookiesByDomain; >- for (NSHTTPCookie* cookie in cookies) { >- auto& cookies = cookiesByDomain.add(cookie.domain, Vector<RetainPtr<NSHTTPCookie>>()).iterator->value; >- cookies.append(cookie); >- } >- >- for (const auto& hostname : hostnames) { >- auto it = cookiesByDomain.find(hostname); >- if (it == cookiesByDomain.end()) >- continue; >- >- for (auto& cookie : it->value) >- deleteHTTPCookie(cookieStorage.get(), cookie.get()); >- } >- >- [session.nsCookieStorage() _saveCookies]; >- >- END_BLOCK_OBJC_EXCEPTIONS; >-} >- >-void deleteAllCookiesModifiedSince(const NetworkStorageSession& session, WallTime timePoint) >-{ >- ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); >- >- if (![NSHTTPCookieStorage instancesRespondToSelector:@selector(removeCookiesSinceDate:)]) >- return; >- >- NSTimeInterval timeInterval = timePoint.secondsSinceEpoch().seconds(); >- NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval]; >- >- auto *storage = session.nsCookieStorage(); >- >- [storage removeCookiesSinceDate:date]; >- [storage _saveCookies]; >-} >- >-} >diff --git a/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm b/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm >index 88763100ad4e66d9412268a7a91c39fd39902633..b3e907ffdde285f8c803d671a27ff74a0921c26c 100644 >--- a/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm >+++ b/Source/WebCore/platform/network/mac/WebCoreResourceHandleAsOperationQueueDelegate.mm >@@ -29,6 +29,7 @@ > #import "AuthenticationChallenge.h" > #import "AuthenticationMac.h" > #import "Logging.h" >+#import "NetworkingContext.h" > #import "ResourceHandle.h" > #import "ResourceHandleClient.h" > #import "ResourceRequest.h" >diff --git a/Source/WebCore/platform/network/soup/CookieJarSoup.cpp b/Source/WebCore/platform/network/soup/CookieJarSoup.cpp >deleted file mode 100644 >index 5ee8761f65b15ab09a24edb90edaa85233d531c7..0000000000000000000000000000000000000000 >--- a/Source/WebCore/platform/network/soup/CookieJarSoup.cpp >+++ /dev/null >@@ -1,260 +0,0 @@ >-/* >- * Copyright (C) 2008 Xan Lopez <xan@gnome.org> >- * Copyright (C) 2009 Igalia S.L. >- * Copyright (C) 2008 Apple Inc. All rights reserved. >- * >- * This library is free software; you can redistribute it and/or >- * modify it under the terms of the GNU Lesser General Public >- * License as published by the Free Software Foundation; either >- * version 2 of the License, or (at your option) any later version. >- * >- * This library is distributed in the hope that it will be useful, >- * but WITHOUT ANY WARRANTY; without even the implied warranty of >- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >- * Lesser General Public License for more details. >- * >- * You should have received a copy of the GNU Lesser General Public >- * License along with this library; if not, write to the Free Software >- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >- */ >- >-#include "config.h" >- >-#if USE(SOUP) >- >-#include "Cookie.h" >-#include "CookieRequestHeaderFieldProxy.h" >-#include "CookiesStrategy.h" >-#include "GUniquePtrSoup.h" >-#include "NetworkStorageSession.h" >-#include "NetworkingContext.h" >-#include "PlatformCookieJar.h" >-#include "SoupNetworkSession.h" >-#include "URL.h" >-#include <wtf/DateMath.h> >-#include <wtf/glib/GRefPtr.h> >-#include <wtf/text/CString.h> >- >-namespace WebCore { >- >-static inline bool httpOnlyCookieExists(const GSList* cookies, const gchar* name, const gchar* path) >-{ >- for (const GSList* iter = cookies; iter; iter = g_slist_next(iter)) { >- SoupCookie* cookie = static_cast<SoupCookie*>(iter->data); >- if (!strcmp(soup_cookie_get_name(cookie), name) >- && !g_strcmp0(soup_cookie_get_path(cookie), path)) { >- if (soup_cookie_get_http_only(cookie)) >- return true; >- break; >- } >- } >- return false; >-} >- >-void setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& value) >-{ >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >- GUniquePtr<SoupURI> origin = url.createSoupURI(); >- if (!origin) >- return; >- >- GUniquePtr<SoupURI> firstPartyURI = firstParty.createSoupURI(); >- if (!firstPartyURI) >- return; >- >- // Get existing cookies for this origin. >- SoupCookieJar* jar = session.cookieStorage(); >- GSList* existingCookies = soup_cookie_jar_get_cookie_list(jar, origin.get(), TRUE); >- >- for (auto& cookieString : value.split('\n')) { >- GUniquePtr<SoupCookie> cookie(soup_cookie_parse(cookieString.utf8().data(), origin.get())); >- if (!cookie) >- continue; >- >- // Make sure the cookie is not httpOnly since such cookies should not be set from JavaScript. >- if (soup_cookie_get_http_only(cookie.get())) >- continue; >- >- // Make sure we do not overwrite httpOnly cookies from JavaScript. >- if (httpOnlyCookieExists(existingCookies, soup_cookie_get_name(cookie.get()), soup_cookie_get_path(cookie.get()))) >- continue; >- >- soup_cookie_jar_add_cookie_with_first_party(jar, firstPartyURI.get(), cookie.release()); >- } >- >- soup_cookies_free(existingCookies); >-} >- >-static std::pair<String, bool> cookiesForSession(const NetworkStorageSession& session, const URL& url, bool forHTTPHeader, IncludeSecureCookies includeSecureCookies) >-{ >- GUniquePtr<SoupURI> uri = url.createSoupURI(); >- if (!uri) >- return { { }, false }; >- >- GSList* cookies = soup_cookie_jar_get_cookie_list(session.cookieStorage(), uri.get(), forHTTPHeader); >- bool didAccessSecureCookies = false; >- >- // libsoup should omit secure cookies itself if the protocol is not https. >- if (url.protocolIs("https")) { >- GSList* item = cookies; >- while (item) { >- auto cookie = static_cast<SoupCookie*>(item->data); >- if (soup_cookie_get_secure(cookie)) { >- didAccessSecureCookies = true; >- if (includeSecureCookies == IncludeSecureCookies::No) { >- GSList* next = item->next; >- soup_cookie_free(static_cast<SoupCookie*>(item->data)); >- cookies = g_slist_remove_link(cookies, item); >- item = next; >- continue; >- } >- } >- item = item->next; >- } >- } >- >- if (!cookies) >- return { { }, false }; >- >- GUniquePtr<char> cookieHeader(soup_cookies_to_cookie_header(cookies)); >- soup_cookies_free(cookies); >- >- return { String::fromUTF8(cookieHeader.get()), didAccessSecureCookies }; >-} >- >-std::pair<String, bool> cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) >-{ >- UNUSED_PARAM(firstParty); >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >- return cookiesForSession(session, url, false, includeSecureCookies); >-} >- >-std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) >-{ >- UNUSED_PARAM(firstParty); >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >- // Secure cookies will still only be included if url's protocol is https. >- return cookiesForSession(session, url, true, includeSecureCookies); >-} >- >-std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const CookieRequestHeaderFieldProxy& headerFieldProxy) >-{ >- return cookieRequestHeaderFieldValue(session, headerFieldProxy.firstParty, headerFieldProxy.sameSiteInfo, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, headerFieldProxy.includeSecureCookies); >-} >- >-bool cookiesEnabled(const NetworkStorageSession& session) >-{ >- auto policy = soup_cookie_jar_get_accept_policy(session.cookieStorage()); >- return policy == SOUP_COOKIE_JAR_ACCEPT_ALWAYS || policy == SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY; >-} >- >-bool getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) >-{ >- UNUSED_PARAM(firstParty); >- UNUSED_PARAM(frameID); >- UNUSED_PARAM(pageID); >- rawCookies.clear(); >- GUniquePtr<SoupURI> uri = url.createSoupURI(); >- if (!uri) >- return false; >- >- GUniquePtr<GSList> cookies(soup_cookie_jar_get_cookie_list(session.cookieStorage(), uri.get(), TRUE)); >- if (!cookies) >- return false; >- >- for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) { >- SoupCookie* soupCookie = static_cast<SoupCookie*>(iter->data); >- Cookie cookie; >- cookie.name = String::fromUTF8(soupCookie->name); >- cookie.value = String::fromUTF8(soupCookie->value); >- cookie.domain = String::fromUTF8(soupCookie->domain); >- cookie.path = String::fromUTF8(soupCookie->path); >- cookie.created = 0; >- cookie.expires = soupCookie->expires ? static_cast<double>(soup_date_to_time_t(soupCookie->expires)) * 1000 : 0; >- cookie.httpOnly = soupCookie->http_only; >- cookie.secure = soupCookie->secure; >- cookie.session = !soupCookie->expires; >- rawCookies.append(WTFMove(cookie)); >- soup_cookie_free(soupCookie); >- } >- >- return true; >-} >- >-void deleteCookie(const NetworkStorageSession& session, const URL& url, const String& name) >-{ >- GUniquePtr<SoupURI> uri = url.createSoupURI(); >- if (!uri) >- return; >- >- SoupCookieJar* jar = session.cookieStorage(); >- GUniquePtr<GSList> cookies(soup_cookie_jar_get_cookie_list(jar, uri.get(), TRUE)); >- if (!cookies) >- return; >- >- CString cookieName = name.utf8(); >- bool wasDeleted = false; >- for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) { >- SoupCookie* cookie = static_cast<SoupCookie*>(iter->data); >- if (!wasDeleted && cookieName == cookie->name) { >- soup_cookie_jar_delete_cookie(jar, cookie); >- wasDeleted = true; >- } >- soup_cookie_free(cookie); >- } >-} >- >-void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames) >-{ >- GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(session.cookieStorage())); >- for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { >- SoupCookie* cookie = static_cast<SoupCookie*>(item->data); >- if (cookie->domain) >- hostnames.add(String::fromUTF8(cookie->domain)); >- soup_cookie_free(cookie); >- } >-} >- >-void deleteCookiesForHostnames(const NetworkStorageSession& session, const Vector<String>& hostnames) >-{ >- SoupCookieJar* cookieJar = session.cookieStorage(); >- >- for (const auto& hostname : hostnames) { >- CString hostNameString = hostname.utf8(); >- >- GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); >- for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { >- SoupCookie* cookie = static_cast<SoupCookie*>(item->data); >- if (soup_cookie_domain_matches(cookie, hostNameString.data())) >- soup_cookie_jar_delete_cookie(cookieJar, cookie); >- soup_cookie_free(cookie); >- } >- } >-} >- >-void deleteAllCookies(const NetworkStorageSession& session) >-{ >- SoupCookieJar* cookieJar = session.cookieStorage(); >- GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); >- for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { >- SoupCookie* cookie = static_cast<SoupCookie*>(item->data); >- soup_cookie_jar_delete_cookie(cookieJar, cookie); >- soup_cookie_free(cookie); >- } >-} >- >-void deleteAllCookiesModifiedSince(const NetworkStorageSession& session, WallTime timestamp) >-{ >- // FIXME: Add support for deleting cookies modified since the given timestamp. It should probably be added to libsoup. >- if (timestamp == WallTime::fromRawSeconds(0)) >- deleteAllCookies(session); >- else >- g_warning("Deleting cookies modified since a given time span is not supported yet"); >-} >- >-} >- >-#endif >diff --git a/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp b/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp >index 5e3c245a3c6c636b7e62d3361c3b7ff3fc82d600..b3d71a4b40e5ded09b6832008bef0061d1fed15f 100644 >--- a/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp >+++ b/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp >@@ -32,6 +32,7 @@ > #if USE(SOUP) > > #include "Cookie.h" >+#include "CookieRequestHeaderFieldProxy.h" > #include "GUniquePtrSoup.h" > #include "ResourceHandle.h" > #include "SoupNetworkSession.h" >@@ -291,6 +292,62 @@ void NetworkStorageSession::saveCredentialToPersistentStorage(const ProtectionSp > #endif > } > >+bool NetworkStorageSession::cookiesEnabled() const >+{ >+ auto policy = soup_cookie_jar_get_accept_policy(cookieStorage()); >+ return policy == SOUP_COOKIE_JAR_ACCEPT_ALWAYS || policy == SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY; >+} >+ >+static inline bool httpOnlyCookieExists(const GSList* cookies, const gchar* name, const gchar* path) >+{ >+ for (const GSList* iter = cookies; iter; iter = g_slist_next(iter)) { >+ SoupCookie* cookie = static_cast<SoupCookie*>(iter->data); >+ if (!strcmp(soup_cookie_get_name(cookie), name) >+ && !g_strcmp0(soup_cookie_get_path(cookie), path)) { >+ if (soup_cookie_get_http_only(cookie)) >+ return true; >+ break; >+ } >+ } >+ return false; >+} >+ >+void NetworkStorageSession::setCookiesFromDOM(const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& value) const >+{ >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+ GUniquePtr<SoupURI> origin = url.createSoupURI(); >+ if (!origin) >+ return; >+ >+ GUniquePtr<SoupURI> firstPartyURI = firstParty.createSoupURI(); >+ if (!firstPartyURI) >+ return; >+ >+ // Get existing cookies for this origin. >+ SoupCookieJar* jar = cookieStorage(); >+ GSList* existingCookies = soup_cookie_jar_get_cookie_list(jar, origin.get(), TRUE); >+ >+ for (auto& cookieString : value.split('\n')) { >+ GUniquePtr<SoupCookie> cookie(soup_cookie_parse(cookieString.utf8().data(), origin.get())); >+ >+ if (!cookie) >+ continue; >+ >+ // Make sure the cookie is not httpOnly since such cookies should not be set from JavaScript. >+ if (soup_cookie_get_http_only(cookie.get())) >+ continue; >+ >+ // Make sure we do not overwrite httpOnly cookies from JavaScript. >+ if (httpOnlyCookieExists(existingCookies, soup_cookie_get_name(cookie.get()), soup_cookie_get_path(cookie.get()))) >+ continue; >+ >+ soup_cookie_jar_add_cookie_with_first_party(jar, firstPartyURI.get(), cookie.release()); >+ } >+ >+ soup_cookies_free(existingCookies); >+} >+ > void NetworkStorageSession::setCookies(const Vector<Cookie>& cookies, const URL&, const URL&) > { > for (auto cookie : cookies) >@@ -308,6 +365,77 @@ void NetworkStorageSession::deleteCookie(const Cookie& cookie) > soup_cookie_jar_delete_cookie(cookieStorage(), targetCookie.get()); > } > >+void NetworkStorageSession::deleteCookie(const URL& url, const String& name) const >+{ >+ GUniquePtr<SoupURI> uri = url.createSoupURI(); >+ if (!uri) >+ return; >+ >+ SoupCookieJar* jar = cookieStorage(); >+ GUniquePtr<GSList> cookies(soup_cookie_jar_get_cookie_list(jar, uri.get(), TRUE)); >+ if (!cookies) >+ return; >+ >+ CString cookieName = name.utf8(); >+ bool wasDeleted = false; >+ for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) { >+ SoupCookie* cookie = static_cast<SoupCookie*>(iter->data); >+ if (!wasDeleted && cookieName == cookie->name) { >+ soup_cookie_jar_delete_cookie(jar, cookie); >+ wasDeleted = true; >+ } >+ soup_cookie_free(cookie); >+ } >+} >+ >+void NetworkStorageSession::deleteAllCookies() >+{ >+ SoupCookieJar* cookieJar = cookieStorage(); >+ GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); >+ for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { >+ SoupCookie* cookie = static_cast<SoupCookie*>(item->data); >+ soup_cookie_jar_delete_cookie(cookieJar, cookie); >+ soup_cookie_free(cookie); >+ } >+} >+ >+void NetworkStorageSession::deleteAllCookiesModifiedSince(WallTime timestamp) >+{ >+ // FIXME: Add support for deleting cookies modified since the given timestamp. It should probably be added to libsoup. >+ if (timestamp == WallTime::fromRawSeconds(0)) >+ deleteAllCookies(); >+ else >+ g_warning("Deleting cookies modified since a given time span is not supported yet"); >+} >+ >+void NetworkStorageSession::deleteCookiesForHostnames(const Vector<String>& hostnames) >+{ >+ SoupCookieJar* cookieJar = cookieStorage(); >+ >+ for (const auto& hostname : hostnames) { >+ CString hostNameString = hostname.utf8(); >+ >+ GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar)); >+ for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { >+ SoupCookie* cookie = static_cast<SoupCookie*>(item->data); >+ if (soup_cookie_domain_matches(cookie, hostNameString.data())) >+ soup_cookie_jar_delete_cookie(cookieJar, cookie); >+ soup_cookie_free(cookie); >+ } >+ } >+} >+ >+void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& hostnames) >+{ >+ GUniquePtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieStorage())); >+ for (GSList* item = cookies.get(); item; item = g_slist_next(item)) { >+ SoupCookie* cookie = static_cast<SoupCookie*>(item->data); >+ if (cookie->domain) >+ hostnames.add(String::fromUTF8(cookie->domain)); >+ soup_cookie_free(cookie); >+ } >+} >+ > Vector<Cookie> NetworkStorageSession::getAllCookies() > { > // FIXME: Implement for WK2 to use. >@@ -330,6 +458,98 @@ Vector<Cookie> NetworkStorageSession::getCookies(const URL& url) > return cookies; > } > >+bool NetworkStorageSession::getRawCookies(const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) const >+{ >+ UNUSED_PARAM(firstParty); >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+ rawCookies.clear(); >+ GUniquePtr<SoupURI> uri = url.createSoupURI(); >+ if (!uri) >+ return false; >+ >+ GUniquePtr<GSList> cookies(soup_cookie_jar_get_cookie_list(cookieStorage(), uri.get(), TRUE)); >+ if (!cookies) >+ return false; >+ >+ for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) { >+ SoupCookie* soupCookie = static_cast<SoupCookie*>(iter->data); >+ Cookie cookie; >+ cookie.name = String::fromUTF8(soupCookie->name); >+ cookie.value = String::fromUTF8(soupCookie->value); >+ cookie.domain = String::fromUTF8(soupCookie->domain); >+ cookie.path = String::fromUTF8(soupCookie->path); >+ cookie.created = 0; >+ cookie.expires = soupCookie->expires ? static_cast<double>(soup_date_to_time_t(soupCookie->expires)) * 1000 : 0; >+ cookie.httpOnly = soupCookie->http_only; >+ cookie.secure = soupCookie->secure; >+ cookie.session = !soupCookie->expires; >+ rawCookies.append(WTFMove(cookie)); >+ soup_cookie_free(soupCookie); >+ } >+ >+ return true; >+} >+ >+static std::pair<String, bool> cookiesForSession(const NetworkStorageSession& session, const URL& url, bool forHTTPHeader, IncludeSecureCookies includeSecureCookies) >+{ >+ GUniquePtr<SoupURI> uri = url.createSoupURI(); >+ if (!uri) >+ return { { }, false }; >+ >+ GSList* cookies = soup_cookie_jar_get_cookie_list(session.cookieStorage(), uri.get(), forHTTPHeader); >+ bool didAccessSecureCookies = false; >+ >+ // libsoup should omit secure cookies itself if the protocol is not https. >+ if (url.protocolIs("https")) { >+ GSList* item = cookies; >+ while (item) { >+ auto cookie = static_cast<SoupCookie*>(item->data); >+ if (soup_cookie_get_secure(cookie)) { >+ didAccessSecureCookies = true; >+ if (includeSecureCookies == IncludeSecureCookies::No) { >+ GSList* next = item->next; >+ soup_cookie_free(static_cast<SoupCookie*>(item->data)); >+ cookies = g_slist_remove_link(cookies, item); >+ item = next; >+ continue; >+ } >+ } >+ item = item->next; >+ } >+ } >+ >+ if (!cookies) >+ return { { }, false }; >+ >+ GUniquePtr<char> cookieHeader(soup_cookies_to_cookie_header(cookies)); >+ soup_cookies_free(cookies); >+ >+ return { String::fromUTF8(cookieHeader.get()), didAccessSecureCookies }; >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookiesForDOM(const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const >+{ >+ UNUSED_PARAM(firstParty); >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+ return cookiesForSession(*this, url, false, includeSecureCookies); >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo&, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) const >+{ >+ UNUSED_PARAM(firstParty); >+ UNUSED_PARAM(frameID); >+ UNUSED_PARAM(pageID); >+ // Secure cookies will still only be included if url's protocol is https. >+ return cookiesForSession(*this, url, true, includeSecureCookies); >+} >+ >+std::pair<String, bool> NetworkStorageSession::cookieRequestHeaderFieldValue(const CookieRequestHeaderFieldProxy& headerFieldProxy) const >+{ >+ return cookieRequestHeaderFieldValue(headerFieldProxy.firstParty, headerFieldProxy.sameSiteInfo, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, headerFieldProxy.includeSecureCookies); >+} >+ > void NetworkStorageSession::flushCookieStore() > { > // FIXME: Implement for WK2 to use. >diff --git a/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp b/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp >index fe92bc1c98fff3cf76038426cb9795c1cee88205..0bb149ca15550e1a9c8d3e469ab26ce646b8cba5 100644 >--- a/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp >+++ b/Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp >@@ -33,7 +33,6 @@ > #include <WebCore/Cookie.h> > #include <WebCore/CookieStorage.h> > #include <WebCore/NetworkStorageSession.h> >-#include <WebCore/PlatformCookieJar.h> > #include <WebCore/URL.h> > #include <wtf/MainThread.h> > #include <wtf/text/StringHash.h> >@@ -60,7 +59,7 @@ void WebCookieManager::getHostnamesWithCookies(PAL::SessionID sessionID, Callbac > { > HashSet<String> hostnames; > if (auto* storageSession = NetworkStorageSession::storageSession(sessionID)) >- WebCore::getHostnamesWithCookies(*storageSession, hostnames); >+ storageSession->getHostnamesWithCookies(hostnames); > > m_process.send(Messages::WebCookieManagerProxy::DidGetHostnamesWithCookies(copyToVector(hostnames), callbackID), 0); > } >@@ -68,14 +67,14 @@ void WebCookieManager::getHostnamesWithCookies(PAL::SessionID sessionID, Callbac > void WebCookieManager::deleteCookiesForHostname(PAL::SessionID sessionID, const String& hostname) > { > if (auto* storageSession = NetworkStorageSession::storageSession(sessionID)) >- WebCore::deleteCookiesForHostnames(*storageSession, { hostname }); >+ storageSession->deleteCookiesForHostnames({ hostname }); > } > > > void WebCookieManager::deleteAllCookies(PAL::SessionID sessionID) > { > if (auto* storageSession = NetworkStorageSession::storageSession(sessionID)) >- WebCore::deleteAllCookies(*storageSession); >+ storageSession->deleteAllCookies(); > } > > void WebCookieManager::deleteCookie(PAL::SessionID sessionID, const Cookie& cookie, CallbackID callbackID) >@@ -89,7 +88,7 @@ void WebCookieManager::deleteCookie(PAL::SessionID sessionID, const Cookie& cook > void WebCookieManager::deleteAllCookiesModifiedSince(PAL::SessionID sessionID, WallTime time, CallbackID callbackID) > { > if (auto* storageSession = NetworkStorageSession::storageSession(sessionID)) >- WebCore::deleteAllCookiesModifiedSince(*storageSession, time); >+ storageSession->deleteAllCookiesModifiedSince(time); > > m_process.send(Messages::WebCookieManagerProxy::DidDeleteCookies(callbackID), 0); > } >diff --git a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >index a31f171217e45073e35965838589d1f425d1ef61..0838930852b12fa7b1406cbc40e71d769e849eec 100644 >--- a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >@@ -52,7 +52,6 @@ > #include "WebsiteDataStore.h" > #include "WebsiteDataStoreParameters.h" > #include <WebCore/NetworkStorageSession.h> >-#include <WebCore/PlatformCookieJar.h> > #include <WebCore/ResourceLoaderOptions.h> > #include <WebCore/ResourceRequest.h> > #include <WebCore/SameSiteInfo.h> >@@ -379,7 +378,7 @@ void NetworkConnectionToWebProcess::convertMainResourceLoadToDownload(PAL::Sessi > void NetworkConnectionToWebProcess::cookiesForDOM(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies, String& cookieString, bool& secureCookiesAccessed) > { > auto& networkStorageSession = storageSession(sessionID); >- std::tie(cookieString, secureCookiesAccessed) = WebCore::cookiesForDOM(networkStorageSession, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+ std::tie(cookieString, secureCookiesAccessed) = networkStorageSession.cookiesForDOM(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); > #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED > if (NetworkProcess::singleton().shouldLogCookieInformation()) > NetworkResourceLoader::logCookieInformation("NetworkConnectionToWebProcess::cookiesForDOM", reinterpret_cast<const void*>(this), networkStorageSession, firstParty, sameSiteInfo, url, emptyString(), frameID, pageID, std::nullopt); >@@ -389,7 +388,7 @@ void NetworkConnectionToWebProcess::cookiesForDOM(PAL::SessionID sessionID, cons > void NetworkConnectionToWebProcess::setCookiesFromDOM(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& cookieString) > { > auto& networkStorageSession = storageSession(sessionID); >- WebCore::setCookiesFromDOM(networkStorageSession, firstParty, sameSiteInfo, url, frameID, pageID, cookieString); >+ networkStorageSession.setCookiesFromDOM(firstParty, sameSiteInfo, url, frameID, pageID, cookieString); > #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED > if (NetworkProcess::singleton().shouldLogCookieInformation()) > NetworkResourceLoader::logCookieInformation("NetworkConnectionToWebProcess::setCookiesFromDOM", reinterpret_cast<const void*>(this), networkStorageSession, firstParty, sameSiteInfo, url, emptyString(), frameID, pageID, std::nullopt); >@@ -398,22 +397,22 @@ void NetworkConnectionToWebProcess::setCookiesFromDOM(PAL::SessionID sessionID, > > void NetworkConnectionToWebProcess::cookiesEnabled(PAL::SessionID sessionID, bool& result) > { >- result = WebCore::cookiesEnabled(storageSession(sessionID)); >+ result = storageSession(sessionID).cookiesEnabled(); > } > > void NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies, String& cookieString, bool& secureCookiesAccessed) > { >- std::tie(cookieString, secureCookiesAccessed) = WebCore::cookieRequestHeaderFieldValue(storageSession(sessionID), firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+ std::tie(cookieString, secureCookiesAccessed) = storageSession(sessionID).cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); > } > > void NetworkConnectionToWebProcess::getRawCookies(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& result) > { >- WebCore::getRawCookies(storageSession(sessionID), firstParty, sameSiteInfo, url, frameID, pageID, result); >+ storageSession(sessionID).getRawCookies(firstParty, sameSiteInfo, url, frameID, pageID, result); > } > > void NetworkConnectionToWebProcess::deleteCookie(PAL::SessionID sessionID, const URL& url, const String& cookieName) > { >- WebCore::deleteCookie(storageSession(sessionID), url, cookieName); >+ storageSession(sessionID).deleteCookie(url, cookieName); > } > > void NetworkConnectionToWebProcess::registerFileBlobURL(const URL& url, const String& path, SandboxExtension::Handle&& extensionHandle, const String& contentType) >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index 8bfefe362a85bf2594845ac28f640933ca689669..5a124c8cc8eab79781222caead4b873b28b9b316 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -65,7 +65,6 @@ > #include <WebCore/MIMETypeRegistry.h> > #include <WebCore/NetworkStateNotifier.h> > #include <WebCore/NetworkStorageSession.h> >-#include <WebCore/PlatformCookieJar.h> > #include <WebCore/ResourceRequest.h> > #include <WebCore/RuntimeApplicationChecks.h> > #include <WebCore/SchemeRegistry.h> >@@ -533,7 +532,7 @@ void NetworkProcess::fetchWebsiteData(PAL::SessionID sessionID, OptionSet<Websit > > if (websiteDataTypes.contains(WebsiteDataType::Cookies)) { > if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) >- getHostnamesWithCookies(*networkStorageSession, callbackAggregator->m_websiteData.hostNamesWithCookies); >+ networkStorageSession->getHostnamesWithCookies(callbackAggregator->m_websiteData.hostNamesWithCookies); > } > > if (websiteDataTypes.contains(WebsiteDataType::Credentials)) { >@@ -565,7 +564,7 @@ void NetworkProcess::deleteWebsiteData(PAL::SessionID sessionID, OptionSet<Websi > > if (websiteDataTypes.contains(WebsiteDataType::Cookies)) { > if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) >- deleteAllCookiesModifiedSince(*networkStorageSession, modifiedSince); >+ networkStorageSession->deleteAllCookiesModifiedSince(modifiedSince); > } > > if (websiteDataTypes.contains(WebsiteDataType::Credentials)) { >@@ -613,7 +612,7 @@ void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, Optio > { > if (websiteDataTypes.contains(WebsiteDataType::Cookies)) { > if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) >- deleteCookiesForHostnames(*networkStorageSession, cookieHostNames); >+ networkStorageSession->deleteCookiesForHostnames(cookieHostNames); > } > > auto clearTasksHandler = WTF::CallbackAggregator::create([this, callbackID] { >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >index 52ebf9af539dc80de21692f056b1c33fb98abd70..caa7cd5ebe8d5acc850177955e0fb5196e9a1a9c 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >@@ -59,7 +59,6 @@ > > #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED > #include <WebCore/NetworkStorageSession.h> >-#include <WebCore/PlatformCookieJar.h> > #endif > > #if USE(QUICK_LOOK) >@@ -1014,7 +1013,7 @@ static void logCookieInformationInternal(const String& label, const void* logged > ASSERT(NetworkResourceLoader::shouldLogCookieInformation()); > > Vector<WebCore::Cookie> cookies; >- if (!WebCore::getRawCookies(networkStorageSession, partition, sameSiteInfo, url, frameID, pageID, cookies)) >+ if (!networkStorageSession.getRawCookies(partition, sameSiteInfo, url, frameID, pageID, cookies)) > return; > > auto escapedURL = escapeForJSON(url.string()); >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >index b72dc15ffe0ae9388d6dfbb4ce6c0ed17e74af98..2ff0ca2691b065f40cd8075b78dd459dd1adef9d 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp >@@ -35,7 +35,6 @@ > #include <WebCore/HTTPHeaderNames.h> > #include <WebCore/LowPowerModeNotifier.h> > #include <WebCore/NetworkStorageSession.h> >-#include <WebCore/PlatformCookieJar.h> > #include <WebCore/ResourceRequest.h> > #include <WebCore/ResourceResponse.h> > #include <WebCore/SharedBuffer.h> >diff --git a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp >index 6913135815ea7d00819425cce848468ee3e4fdf7..ae7388f9a49c30fcc6c86c851fa065821733bf50 100644 >--- a/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp >+++ b/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp >@@ -54,7 +54,6 @@ > #include <WebCore/Page.h> > #include <WebCore/PageGroup.h> > #include <WebCore/PasteboardItemInfo.h> >-#include <WebCore/PlatformCookieJar.h> > #include <WebCore/PlatformPasteboard.h> > #include <WebCore/ProgressTracker.h> > #include <WebCore/ResourceError.h> >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm >index 3450672d5cb5196dd3a3a6fb06009cd77b98e7c8..b53188ebfcdf5a74133185198ec3d24fe39ad855 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm >@@ -33,7 +33,6 @@ > #import <WebCore/Frame.h> > #import <WebCore/NetworkStorageSession.h> > #import <WebCore/PasteboardItemInfo.h> >-#import <WebCore/PlatformCookieJar.h> > #import <WebCore/PlatformPasteboard.h> > #import <WebCore/SharedBuffer.h> > #import <WebCore/SubframeLoader.h> >@@ -75,38 +74,38 @@ BlobRegistry* WebPlatformStrategies::createBlobRegistry() > > std::pair<String, bool> WebPlatformStrategies::cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) > { >- return WebCore::cookiesForDOM(session, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+ return session.cookiesForDOM(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); > } > > void WebPlatformStrategies::setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& cookieString) > { >- WebCore::setCookiesFromDOM(session, firstParty, sameSiteInfo, url, frameID, pageID, cookieString); >+ session.setCookiesFromDOM(firstParty, sameSiteInfo, url, frameID, pageID, cookieString); > } > > bool WebPlatformStrategies::cookiesEnabled(const NetworkStorageSession& session) > { >- return WebCore::cookiesEnabled(session); >+ return session.cookiesEnabled(); > } > > std::pair<String, bool> WebPlatformStrategies::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) > { >- return WebCore::cookieRequestHeaderFieldValue(session, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+ return session.cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); > } > > std::pair<String, bool> WebPlatformStrategies::cookieRequestHeaderFieldValue(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) > { > auto& session = sessionID.isEphemeral() ? WebFrameNetworkingContext::ensurePrivateBrowsingSession() : NetworkStorageSession::defaultStorageSession(); >- return WebCore::cookieRequestHeaderFieldValue(session, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+ return session.cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); > } > > bool WebPlatformStrategies::getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) > { >- return WebCore::getRawCookies(session, firstParty, sameSiteInfo, url, frameID, pageID, rawCookies); >+ return session.getRawCookies(firstParty, sameSiteInfo, url, frameID, pageID, rawCookies); > } > > void WebPlatformStrategies::deleteCookie(const NetworkStorageSession& session, const URL& url, const String& cookieName) > { >- WebCore::deleteCookie(session, url, cookieName); >+ session.deleteCookie(url, cookieName); > } > > void WebPlatformStrategies::getTypes(Vector<String>& types, const String& pasteboardName) >diff --git a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm >index c4d7422de71ffcc14cdda8333e69726a704ee743..7718d05aeda6266e23130a14e821be1e866c47c7 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebPreferences.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebPreferences.mm >@@ -42,7 +42,6 @@ > #import <WebCore/AudioSession.h> > #import <WebCore/DeprecatedGlobalSettings.h> > #import <WebCore/NetworkStorageSession.h> >-#import <WebCore/PlatformCookieJar.h> > #import <WebCore/RuntimeApplicationChecks.h> > #import <WebCore/Settings.h> > #import <WebCore/TextEncodingRegistry.h> >@@ -1877,7 +1876,7 @@ static NSString *classIBCreatorID = nil; > > + (void)_clearNetworkLoaderSession > { >- WebCore::deleteAllCookies(NetworkStorageSession::defaultStorageSession()); >+ NetworkStorageSession::defaultStorageSession().deleteAllCookies(); > } > > + (void)_setCurrentNetworkLoaderSessionCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy >diff --git a/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp b/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp >index de262684388dbaeb3b396600068f92ea3a300876..fab42184868f22761988ab40845f79ec73988e4c 100644 >--- a/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp >+++ b/Source/WebKitLegacy/win/WebCoreSupport/WebPlatformStrategies.cpp >@@ -32,7 +32,6 @@ > #include <WebCore/NetworkStorageSession.h> > #include <WebCore/Page.h> > #include <WebCore/PageGroup.h> >-#include <WebCore/PlatformCookieJar.h> > > #if USE(CFURLCONNECTION) > #include <WebKitSystemInterface/WebKitSystemInterface.h> >@@ -72,36 +71,36 @@ BlobRegistry* WebPlatformStrategies::createBlobRegistry() > > std::pair<String, bool> WebPlatformStrategies::cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) > { >- return WebCore::cookiesForDOM(session, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+ return session.cookiesForDOM(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); > } > > void WebPlatformStrategies::setCookiesFromDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, const String& cookieString) > { >- WebCore::setCookiesFromDOM(session, firstParty, sameSiteInfo, url, frameID, pageID, cookieString); >+ session.setCookiesFromDOM(firstParty, sameSiteInfo, url, frameID, pageID, cookieString); > } > > bool WebPlatformStrategies::cookiesEnabled(const NetworkStorageSession& session) > { >- return WebCore::cookiesEnabled(session); >+ return session.cookiesEnabled(); > } > > std::pair<String, bool> WebPlatformStrategies::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) > { >- return WebCore::cookieRequestHeaderFieldValue(session, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+ return session.cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); > } > > std::pair<String, bool> WebPlatformStrategies::cookieRequestHeaderFieldValue(PAL::SessionID sessionID, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, IncludeSecureCookies includeSecureCookies) > { > auto& session = sessionID.isEphemeral() ? WebFrameNetworkingContext::ensurePrivateBrowsingSession() : NetworkStorageSession::defaultStorageSession(); >- return WebCore::cookieRequestHeaderFieldValue(session, firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); >+ return session.cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies); > } > > bool WebPlatformStrategies::getRawCookies(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID, Vector<Cookie>& rawCookies) > { >- return WebCore::getRawCookies(session, firstParty, sameSiteInfo, url, frameID, pageID, rawCookies); >+ return session.getRawCookies(firstParty, sameSiteInfo, url, frameID, pageID, rawCookies); > } > > void WebPlatformStrategies::deleteCookie(const NetworkStorageSession& session, const URL& url, const String& cookieName) > { >- WebCore::deleteCookie(session, url, cookieName); >+ session.deleteCookie(url, cookieName); > } >diff --git a/Source/WebKitLegacy/win/WebPreferences.cpp b/Source/WebKitLegacy/win/WebPreferences.cpp >index e100412028a33c49439287dd7908e6a3a5720d66..c08f2f72720a26ac67e69e923617ad7616531af9 100644 >--- a/Source/WebKitLegacy/win/WebPreferences.cpp >+++ b/Source/WebKitLegacy/win/WebPreferences.cpp >@@ -42,7 +42,6 @@ > #include <WebCore/FontCascade.h> > #include <WebCore/LocalizedStrings.h> > #include <WebCore/NetworkStorageSession.h> >-#include <WebCore/PlatformCookieJar.h> > #include <limits> > #include <shlobj.h> > #include <wchar.h> >@@ -2120,7 +2119,7 @@ HRESULT WebPreferences::mediaPreloadingEnabled(_Out_ BOOL* enabled) > > HRESULT WebPreferences::clearNetworkLoaderSession() > { >- WebCore::deleteAllCookies(NetworkStorageSession::defaultStorageSession()); >+ NetworkStorageSession::defaultStorageSession().deleteAllCookies(); > return S_OK; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188137
:
345998
|
346015
|
346023
|
346026
| 346030