Changeset 231524 in webkit
- Timestamp:
- May 8, 2018 4:59:29 PM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r231521 r231524 1 2018-05-08 John Wilander <wilander@apple.com> 2 3 Storage Access API: Make user opt-in sticky 4 https://bugs.webkit.org/show_bug.cgi?id=185454 5 <rdar://problem/40003946> 6 7 Reviewed by Alex Christensen. 8 9 This patch persists the user's choice to opt-in to access under specific domains. 10 Such storage access should age out with the accessing domain's cookies and website 11 data. The opt-in prompt is still an experimental feature. 12 13 * UIProcess/WebResourceLoadStatisticsStore.cpp: 14 (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess): 15 (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess): 16 (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener): 17 (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess): 18 (WebKit::WebResourceLoadStatisticsStore::grantStorageAccessInternal): 19 (WebKit::WebResourceLoadStatisticsStore::hasUserGrantedStorageAccessThroughPrompt const): 20 (WebKit::WebResourceLoadStatisticsStore::hasHadUnexpiredRecentUserInteraction const): 21 * UIProcess/WebResourceLoadStatisticsStore.h: 22 1 23 2018-05-08 Daniel Bates <dabates@apple.com> 2 24 -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
r231501 r231524 343 343 auto& subFrameStatistic = ensureResourceStatisticsForPrimaryDomain(subFramePrimaryDomain); 344 344 if (shouldBlockCookies(subFrameStatistic)) { 345 callback(false); 345 RunLoop::main().dispatch([callback = WTFMove(callback)] { 346 callback(false); 347 }); 346 348 return; 347 349 } 348 350 349 351 if (!shouldPartitionCookies(subFrameStatistic)) { 350 callback(true); 352 RunLoop::main().dispatch([callback = WTFMove(callback)] { 353 callback(true); 354 }); 351 355 return; 352 356 } 353 357 354 m_hasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, WTFMove(callback)); 358 m_hasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, [callback = WTFMove(callback)] (bool value) mutable { 359 RunLoop::main().dispatch([callback = WTFMove(callback), value] () mutable { 360 callback(value); 361 }); 362 }); 355 363 }); 356 364 } … … 385 393 } 386 394 387 if (promptEnabled) { 395 auto userWasPromptedEarlier = promptEnabled && hasUserGrantedStorageAccessThroughPrompt(subFrameStatistic, topFramePrimaryDomain); 396 if (promptEnabled && !userWasPromptedEarlier) { 388 397 RunLoop::main().dispatch([callback = WTFMove(callback)] { 389 398 callback(StorageAccessStatus::RequiresUserPrompt); … … 394 403 subFrameStatistic.timesAccessedAsFirstPartyDueToStorageAccessAPI++; 395 404 396 grantStorageAccessInternal(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, false, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable {405 grantStorageAccessInternal(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, userWasPromptedEarlier, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable { 397 406 RunLoop::main().dispatch([callback = WTFMove(callback), wasGrantedAccess] () mutable { 398 407 callback(wasGrantedAccess ? StorageAccessStatus::HasAccess : StorageAccessStatus::CannotRequestAccess); … … 402 411 } 403 412 404 void WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener(String&& domainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerDomain, bool isTriggeredByUserGesture)405 { 406 ASSERT( domainInNeedOfStorageAccess != openerDomain);407 ASSERT(!RunLoop::isMain()); 408 409 if ( domainInNeedOfStorageAccess == openerDomain)410 return; 411 412 auto& domainInNeedOfStorageAccessStatistic = ensureResourceStatisticsForPrimaryDomain( domainInNeedOfStorageAccess);413 void WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener(String&& primaryDomainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerPrimaryDomain, bool isTriggeredByUserGesture) 414 { 415 ASSERT(primaryDomainInNeedOfStorageAccess != openerPrimaryDomain); 416 ASSERT(!RunLoop::isMain()); 417 418 if (primaryDomainInNeedOfStorageAccess == openerPrimaryDomain) 419 return; 420 421 auto& domainInNeedOfStorageAccessStatistic = ensureResourceStatisticsForPrimaryDomain(primaryDomainInNeedOfStorageAccess); 413 422 auto cookiesBlocked = shouldBlockCookies(domainInNeedOfStorageAccessStatistic); 414 423 … … 421 430 return; 422 431 423 grantStorageAccessInternal(WTFMove(domainInNeedOfStorageAccess), WTFMove(openerDomain), std::nullopt, openerPageID, false, [](bool) { });424 432 #if !RELEASE_LOG_DISABLED 425 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Grant storage access for %{public}s under opener %{public}s, %{public}s user interaction.", domainInNeedOfStorageAccess.utf8().data(), openerDomain.utf8().data(), (isTriggeredByUserGesture ? "with" : "without"));433 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Grant storage access for %{public}s under opener %{public}s, %{public}s user interaction.", primaryDomainInNeedOfStorageAccess.utf8().data(), openerPrimaryDomain.utf8().data(), (isTriggeredByUserGesture ? "with" : "without")); 426 434 #endif 427 } 428 429 void WebResourceLoadStatisticsStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& callback) 435 grantStorageAccessInternal(WTFMove(primaryDomainInNeedOfStorageAccess), WTFMove(openerPrimaryDomain), std::nullopt, openerPageID, false, [](bool) { }); 436 } 437 438 void WebResourceLoadStatisticsStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& callback) 430 439 { 431 440 ASSERT(RunLoop::isMain()); 432 m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPrompted, callback = WTFMove(callback)] () mutable { 433 grantStorageAccessInternal(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable { 441 m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPromptedNow, callback = WTFMove(callback)] () mutable { 442 auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost); 443 auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost); 444 if (userWasPromptedNow) { 445 auto& subFrameStatistic = ensureResourceStatisticsForPrimaryDomain(subFramePrimaryDomain); 446 ASSERT(subFrameStatistic.hadUserInteraction); 447 subFrameStatistic.storageAccessUnderTopFrameOrigins.add(topFramePrimaryDomain); 448 } 449 grantStorageAccessInternal(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPromptedNow, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable { 434 450 RunLoop::main().dispatch([callback = WTFMove(callback), wasGrantedAccess] () mutable { 435 451 callback(wasGrantedAccess); … … 439 455 } 440 456 441 void WebResourceLoadStatisticsStore::grantStorageAccessInternal(String&& subFrame Host, String&& topFrameHost, std::optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& callback)442 { 443 ASSERT(!RunLoop::isMain());444 auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost);445 auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost); 457 void WebResourceLoadStatisticsStore::grantStorageAccessInternal(String&& subFramePrimaryDomain, String&& topFramePrimaryDomain, std::optional<uint64_t> frameID, uint64_t pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&& callback) 458 { 459 UNUSED_PARAM(userWasPromptedNowOrEarlier); 460 ASSERT(!RunLoop::isMain()); 461 446 462 if (subFramePrimaryDomain == topFramePrimaryDomain) { 447 463 callback(true); 448 464 return; 449 465 } 450 466 451 467 m_grantStorageAccessHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, WTFMove(callback)); 452 468 } … … 1046 1062 } 1047 1063 1064 bool WebResourceLoadStatisticsStore::hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics& statistic, const String& firstPartyPrimaryDomain) const 1065 { 1066 return statistic.storageAccessUnderTopFrameOrigins.contains(firstPartyPrimaryDomain); 1067 } 1068 1048 1069 void WebResourceLoadStatisticsStore::updateCookiePartitioning(CompletionHandler<void()>&& callback) 1049 1070 { … … 1194 1215 // it has been reset as opposed to its default -1. 1195 1216 resourceStatistic.mostRecentUserInteractionTime = { }; 1217 resourceStatistic.storageAccessUnderTopFrameOrigins.clear(); 1196 1218 resourceStatistic.hadUserInteraction = false; 1197 1219 } -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
r231501 r231524 92 92 void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback); 93 93 void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 94 void requestStorageAccessUnderOpener(String&& domainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerDomain, bool isTriggeredByUserGesture);95 void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted , CompletionHandler<void(bool)>&&);94 void requestStorageAccessUnderOpener(String&& primaryDomainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerPrimaryDomain, bool isTriggeredByUserGesture); 95 void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&); 96 96 void requestStorageAccessCallback(bool wasGranted, uint64_t contextId); 97 97 … … 172 172 bool shouldPartitionCookies(const WebCore::ResourceLoadStatistics&) const; 173 173 bool shouldBlockCookies(const WebCore::ResourceLoadStatistics&) const; 174 bool hasUserGrantedStorageAccessThroughPrompt(const WebCore::ResourceLoadStatistics&, const String& firstPartyPrimaryDomain) const; 174 175 bool hasStatisticsExpired(const WebCore::ResourceLoadStatistics&) const; 175 176 bool hasHadUnexpiredRecentUserInteraction(WebCore::ResourceLoadStatistics&) const; … … 186 187 187 188 void resetCookiePartitioningState(); 188 void grantStorageAccessInternal(String&& subFrameHost, String&& topFrameHost, std::optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&); 189 StorageAccessStatus storageAccessStatus(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain); 190 void grantStorageAccessInternal(String&& subFrameHost, String&& topFrameHost, std::optional<uint64_t> frameID, uint64_t pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&&); 189 191 void removeAllStorageAccess(); 190 192
Note: See TracChangeset
for help on using the changeset viewer.