Only cap lifetime of persistent cookies created client-side through document.cookie...
[WebKit-https.git] / Source / WebCore / platform / network / cf / NetworkStorageSessionCFNet.cpp
index 8119fd5..ffd6a61 100644 (file)
@@ -64,12 +64,11 @@ static inline CFTypeID typeID() { return ClassName##GetTypeID(); } \
 };
 
 #if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ALLOW_DEPRECATED_DECLARATIONS_BEGIN
 #endif
 DECLARE_CF_TYPE_TRAIT(CFHTTPCookie);
 #if COMPILER(CLANG)
-#pragma clang diagnostic pop
+ALLOW_DEPRECATED_DECLARATIONS_END
 #endif
 
 #undef DECLARE_CF_TYPE_TRAIT
@@ -221,7 +220,7 @@ void NetworkStorageSession::setStorageAccessAPIEnabled(bool enabled)
     storageAccessAPIEnabled = enabled;
 }
 
-#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
 
 static inline String getPartitioningDomain(const URL& url)
 {
@@ -267,13 +266,21 @@ bool NetworkStorageSession::shouldBlockCookies(const URL& firstPartyForCookies,
     return shouldBlockThirdPartyCookies(resourceDomain);
 }
 
-void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector<String>& domains, bool clearFirst)
+std::optional<Seconds> NetworkStorageSession::maxAgeCacheCap(const ResourceRequest& request)
 {
-    if (clearFirst) {
-        m_topPrivatelyControlledDomainsToBlock.clear();
-        m_framesGrantedStorageAccess.clear();
-    }
+    if (m_cacheMaxAgeCapForPrevalentResources && shouldBlockCookies(request, std::nullopt, std::nullopt))
+        return m_cacheMaxAgeCapForPrevalentResources;
+    return std::nullopt;
+}
+
+void NetworkStorageSession::setShouldCapLifetimeForClientSideCookies(bool value)
+{
+    m_shouldCapLifetimeForClientSideCookies = value;
+}
 
+void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector<String>& domains)
+{
+    m_topPrivatelyControlledDomainsToBlock.clear();
     m_topPrivatelyControlledDomainsToBlock.add(domains.begin(), domains.end());
 }
 
@@ -371,7 +378,16 @@ void NetworkStorageSession::removeAllStorageAccess()
     m_framesGrantedStorageAccess.clear();
 }
 
-#endif // HAVE(CFNETWORK_STORAGE_PARTITIONING)
+void NetworkStorageSession::setCacheMaxAgeCapForPrevalentResources(Seconds seconds)
+{
+    m_cacheMaxAgeCapForPrevalentResources = seconds;
+}
+    
+void NetworkStorageSession::resetCacheMaxAgeCapForPrevalentResources()
+{
+    m_cacheMaxAgeCapForPrevalentResources = std::nullopt;
+}
+#endif //  ENABLE(RESOURCE_LOAD_STATISTICS)
 
 #if !PLATFORM(COCOA)
 void NetworkStorageSession::setCookies(const Vector<Cookie>&, const URL&, const URL&)