Changeset 239403 in webkit
- Timestamp:
- Dec 19, 2018, 4:07:32 PM (8 years ago)
- Location:
- branches/safari-606-branch
- Files:
-
- 2 added
- 16 edited
-
LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js-expected.txt (added)
-
LayoutTests/http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/network/NetworkStorageSession.cpp (modified) (1 diff)
-
Source/WebCore/platform/network/NetworkStorageSession.h (modified) (2 diffs)
-
Source/WebCore/platform/network/mac/CookieJarMac.mm (modified) (3 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.h (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.messages.in (modified) (1 diff)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (modified) (1 diff)
-
Source/WebKit/UIProcess/WebProcessPool.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (modified) (4 diffs)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-606-branch/Source/WebCore/ChangeLog
r239393 r239403 1 2018-12-19 Alan Coon <alancoon@apple.com> 2 3 Apply patch. rdar://problem/46848447 4 5 2018-12-19 Brent Fulgham <bfulgham@apple.com> 6 7 Only cap lifetime of persistent cookies created client-side through document.cookie when resource load statistics is enabled 8 https://bugs.webkit.org/show_bug.cgi?id=190687 9 <rdar://problem/45349024> 10 11 Reviewed by Alex Christensen. 12 13 Test: http/tests/resourceLoadStatistics/capped-lifetime-for-cookie-set-in-js.html 14 15 * platform/network/NetworkStorageSession.cpp: 16 (WebCore::NetworkStorageSession::setShouldCapLifetimeForClientSideCookies): 17 (WebCore::NetworkStorageSession::shouldCapLifetimeForClientSideCookies const): 18 * platform/network/NetworkStorageSession.h: 19 * platform/network/mac/CookieJarMac.mm: 20 (WebCore::filterCookies): 21 (WebCore::setCookiesFromDOM): Now consults the new NetworkStorageSession's 22 m_shouldCapLifetimeForClientSideCookies member variable before capping the 23 lifetime of cookies. 24 1 25 2018-12-19 Kocsen Chung <kocsen_chung@apple.com> 2 26 -
branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.cpp
r229978 r239403 75 75 } 76 76 77 void NetworkStorageSession::setShouldCapLifetimeForClientSideCookies(bool value) 78 { 79 m_shouldCapLifetimeForClientSideCookies = value; 77 80 } 81 82 bool NetworkStorageSession::shouldCapLifetimeForClientSideCookies() const 83 { 84 return m_shouldCapLifetimeForClientSideCookies; 85 } 86 87 } -
branches/safari-606-branch/Source/WebCore/platform/network/NetworkStorageSession.h
r232863 r239403 102 102 WEBCORE_EXPORT String cookieStoragePartition(const URL& firstPartyForCookies, const URL& resource, std::optional<uint64_t> frameID, std::optional<uint64_t> pageID) const; 103 103 WEBCORE_EXPORT void setPrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool clearFirst); 104 WEBCORE_EXPORT void setShouldCapLifetimeForClientSideCookies(bool); 105 WEBCORE_EXPORT bool shouldCapLifetimeForClientSideCookies() const; 104 106 WEBCORE_EXPORT void removePrevalentDomains(const Vector<String>& domains); 105 107 WEBCORE_EXPORT bool hasStorageAccess(const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID) const; … … 176 178 HashMap<uint64_t, HashMap<uint64_t, String, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_framesGrantedStorageAccess; 177 179 HashMap<uint64_t, HashMap<String, String>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_pagesGrantedStorageAccess; 180 bool m_shouldCapLifetimeForClientSideCookies { false }; 178 181 #endif 179 182 -
branches/safari-606-branch/Source/WebCore/platform/network/mac/CookieJarMac.mm
r239393 r239403 146 146 } 147 147 148 static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies )148 static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies, bool shouldCapLifetime) 149 149 { 150 150 ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies)); … … 167 167 168 168 // Cap lifetime of persistent, client-side cookies to a week. 169 if ( ![cookie isSessionOnly]) {169 if (shouldCapLifetime && ![cookie isSessionOnly]) { 170 170 if (!cookie.expiresDate || cookie.expiresDate.timeIntervalSinceNow > secondsPerWeek) { 171 171 RetainPtr<NSMutableDictionary<NSHTTPCookiePropertyKey, id>> properties = adoptNS([[cookie properties] mutableCopy]); … … 336 336 #endif 337 337 338 RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies); 338 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 339 RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, session.shouldCapLifetimeForClientSideCookies()); 340 #else 341 RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, false); 342 #endif 339 343 ASSERT([filteredCookies.get() count] <= 1); 340 344 -
branches/safari-606-branch/Source/WebKit/ChangeLog
r238916 r239403 1 2018-12-19 Alan Coon <alancoon@apple.com> 2 3 Apply patch. rdar://problem/46848447 4 5 2018-12-19 Brent Fulgham <bfulgham@apple.com> 6 7 Only cap lifetime of persistent cookies created client-side through document.cookie when resource load statistics is enabled 8 https://bugs.webkit.org/show_bug.cgi?id=190687 9 <rdar://problem/45349024> 10 11 This patch adds the following:= 12 * The WebProcessPool now tells the WebsiteDataStore when a network process has 13 been created. 14 * The WebsiteDataStore in turn tells the WebResourceLoadStatisticsStore when 15 a network process has been created. 16 * The WebResourceLoadStatisticsStore makes sure to update the network processes 17 with its cookie policy when it's notified that a network process has been 18 created. 19 20 In addition, this patch changes the following: 21 22 * Removes WebsiteDataStore::networkProcessDidCrash() and 23 WebResourceLoadStatisticsStore::scheduleCookieBlockingStateReset() since 24 the call site---WebProcessPool::ensureNetworkProcess()---now calls 25 WebsiteDataStore::didCreateNetworkProcess() after a network process 26 crash and the state sync for cookie blocking is triggered. 27 28 * NetworkProcess/NetworkProcess.cpp: 29 (WebKit::NetworkProcess::setShouldCapLifetimeForClientSideCookies): 30 * NetworkProcess/NetworkProcess.h: 31 * NetworkProcess/NetworkProcess.messages.in: 32 * UIProcess/Network/NetworkProcessProxy.cpp: 33 (WebKit::NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies): 34 (WebKit::NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies): 35 * UIProcess/Network/NetworkProcessProxy.h: 36 * UIProcess/Network/NetworkProcessProxy.messages.in: 37 * UIProcess/WebProcessPool.cpp: 38 (WebKit::WebProcessPool::ensureNetworkProcess): 39 * UIProcess/WebResourceLoadStatisticsStore.cpp: 40 (WebKit::WebResourceLoadStatisticsStore::didCreateNetworkProcess): 41 * UIProcess/WebResourceLoadStatisticsStore.h: 42 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 43 (WebKit::WebsiteDataStore::setShouldCapLifetimeForClientSideCookies): 44 (WebKit::WebsiteDataStore::didCreateNetworkProcess): 45 (WebKit::WebsiteDataStore::networkProcessDidCrash): Deleted. 46 * UIProcess/WebsiteData/WebsiteDataStore.h: 47 1 48 2018-12-05 Alan Coon <alancoon@apple.com> 2 49 -
branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r235702 r239403 427 427 } 428 428 429 void NetworkProcess::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, uint64_t contextId) 430 { 431 if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) 432 networkStorageSession->setShouldCapLifetimeForClientSideCookies(value); 433 parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetShouldCapLifetimeForClientSideCookies(contextId), 0); 434 } 435 429 436 void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId) 430 437 { -
branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.h
r235702 r239403 133 133 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 134 134 void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, bool shouldClearFirst, uint64_t callbackId); 135 void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, bool value, uint64_t contextId); 135 136 void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId); 136 137 void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId); -
branches/safari-606-branch/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r233822 r239403 86 86 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 87 87 UpdatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID sessionID, Vector<String> domainsToPartition, Vector<String> domainsToBlock, Vector<String> domainsToNeitherPartitionNorBlock, bool shouldClearFirst, uint64_t callbackId) 88 SetShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, bool value, uint64_t contextId) 88 89 HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId) 89 90 GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId) -
branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r237535 r239403 445 445 } 446 446 447 void NetworkProcessProxy::setShouldCapLifetimeForClientSideCookies(PAL::SessionID sessionID, ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler) 448 { 449 if (!canSendMessage()) { 450 completionHandler(); 451 return; 452 } 453 454 auto callbackId = generateCallbackID(); 455 auto addResult = m_updatePartitionOrBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable { 456 completionHandler(); 457 }); 458 ASSERT_UNUSED(addResult, addResult.isNewEntry); 459 send(Messages::NetworkProcess::SetShouldCapLifetimeForClientSideCookies(sessionID, shouldCapLifetime == ShouldCapLifetimeForClientSideCookies::Yes, callbackId), 0); 460 } 461 462 void NetworkProcessProxy::didSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId) 463 { 464 m_updatePartitionOrBlockCookiesCallbackMap.take(callbackId)(); 465 } 466 447 467 static uint64_t nextRequestStorageAccessContextId() 448 468 { -
branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r237535 r239403 80 80 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 81 81 void updatePrevalentDomainsToPartitionOrBlockCookies(PAL::SessionID, const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, CompletionHandler<void()>&&); 82 void setShouldCapLifetimeForClientSideCookies(PAL::SessionID, ShouldCapLifetimeForClientSideCookies, CompletionHandler<void()>&&); 82 83 void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback); 83 84 void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&); … … 149 150 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 150 151 void didUpdatePartitionOrBlockCookies(uint64_t callbackId); 152 void didSetShouldCapLifetimeForClientSideCookies(uint64_t contextId); 151 153 void storageAccessRequestResult(bool wasGranted, uint64_t contextId); 152 154 void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId); -
branches/safari-606-branch/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in
r233180 r239403 49 49 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 50 50 DidUpdatePartitionOrBlockCookies(uint64_t callbackId) 51 DidSetShouldCapLifetimeForClientSideCookies(uint64_t callbackId) 51 52 StorageAccessRequestResult(bool wasGranted, uint64_t contextId) 52 53 AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId) -
branches/safari-606-branch/Source/WebKit/UIProcess/WebProcessPool.cpp
r233822 r239403 531 531 m_didNetworkProcessCrash = false; 532 532 reinstateNetworkProcessAssertionState(*m_networkProcess); 533 if (m_websiteDataStore)534 m_websiteDataStore->websiteDataStore().networkProcessDidCrash();535 533 } 536 534 … … 539 537 withWebsiteDataStore->clearPendingCookies(); 540 538 } 539 540 if (m_websiteDataStore) 541 m_websiteDataStore->websiteDataStore().didCreateNetworkProcess(); 541 542 542 543 return *m_networkProcess; -
branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
r234236 r239403 39 39 #include "WebsiteDataStore.h" 40 40 #include <WebCore/ResourceLoadStatistics.h> 41 #include <wtf/CallbackAggregator.h> 41 42 #include <wtf/CrossThreadCopier.h> 42 43 #include <wtf/NeverDestroyed.h> … … 318 319 } 319 320 321 void WebResourceLoadStatisticsStore::didCreateNetworkProcess() 322 { 323 ASSERT(RunLoop::isMain()); 324 325 postTask([this] { 326 if (!m_memoryStore) 327 return; 328 m_memoryStore->updateCookiePartitioning([]() { }); 329 }); 330 331 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 332 if (m_websiteDataStore) 333 m_websiteDataStore->setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies::Yes, []() { }); 334 #endif 335 } 336 320 337 void WebResourceLoadStatisticsStore::removeAllStorageAccess() 321 338 { -
branches/safari-606-branch/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
r234236 r239403 141 141 void callHasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); 142 142 143 void didCreateNetworkProcess(); 144 143 145 private: 144 146 explicit WebResourceLoadStatisticsStore(WebsiteDataStore&); … … 170 172 171 173 WTF::Function<void(const String&)> m_statisticsTestingCallback; 174 175 bool m_firstNetworkProcessCreated { false }; 172 176 }; 173 177 -
branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r234236 r239403 1 1 /* 2 * Copyright (C) 2014-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2014-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 1245 1245 } 1246 1246 1247 void WebsiteDataStore::setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies shouldCapLifetime, CompletionHandler<void()>&& completionHandler) 1248 { 1249 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1250 1251 for (auto& processPool : processPools()) { 1252 if (auto* process = processPool->networkProcess()) 1253 process->setShouldCapLifetimeForClientSideCookies(m_sessionID, shouldCapLifetime, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1254 } 1255 } 1256 1247 1257 void WebsiteDataStore::hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& completionHandler) 1248 1258 { … … 1325 1335 } 1326 1336 #endif 1327 1328 void WebsiteDataStore::networkProcessDidCrash()1329 {1330 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)1331 if (m_resourceLoadStatistics)1332 m_resourceLoadStatistics->scheduleCookiePartitioningStateReset();1333 #endif1334 }1335 1337 1336 1338 void WebsiteDataStore::webPageWasAdded(WebPageProxy& webPageProxy) … … 1624 1626 #endif 1625 1627 1626 } 1628 void WebsiteDataStore::didCreateNetworkProcess() 1629 { 1630 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 1631 if (m_resourceLoadStatistics) 1632 m_resourceLoadStatistics->didCreateNetworkProcess(); 1633 #endif 1634 } 1635 1636 } -
branches/safari-606-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r234236 r239403 1 1 /* 2 * Copyright (C) 2014-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2014-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 73 73 74 74 enum class ShouldClearFirst { No, Yes }; 75 enum class ShouldCapLifetimeForClientSideCookies { No, Yes }; 75 76 76 77 class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessLifetimeObserver, public Identified<WebsiteDataStore>, public CanMakeWeakPtr<WebsiteDataStore> { … … 132 133 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) 133 134 void updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, CompletionHandler<void()>&&); 135 void setShouldCapLifetimeForClientSideCookies(ShouldCapLifetimeForClientSideCookies, CompletionHandler<void()>&&); 134 136 void hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&&); 135 137 void getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&&); … … 141 143 void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&); 142 144 #endif 143 void networkProcessDidCrash();144 145 void resolveDirectoriesIfNecessary(); 145 146 const String& resolvedApplicationCacheDirectory() const { return m_resolvedConfiguration.applicationCacheDirectory; } … … 185 186 #endif 186 187 188 void didCreateNetworkProcess(); 189 187 190 private: 188 191 explicit WebsiteDataStore(PAL::SessionID);
Note:
See TracChangeset
for help on using the changeset viewer.