WebKit Bugzilla
Attachment 339898 Details for
Bug 185454
: Storage Access API: Make user opt-in sticky
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185454-20180508164713.patch (text/plain), 12.85 KB, created by
John Wilander
on 2018-05-08 16:47:14 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
John Wilander
Created:
2018-05-08 16:47:14 PDT
Size:
12.85 KB
patch
obsolete
>Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 231523) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,25 @@ >+2018-05-08 John Wilander <wilander@apple.com> >+ >+ Storage Access API: Make user opt-in sticky >+ https://bugs.webkit.org/show_bug.cgi?id=185454 >+ <rdar://problem/40003946> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch persists the user's choice to opt-in to access under specific domains. >+ Such storage access should age out with the accessing domain's cookies and website >+ data. The opt-in prompt is still an experimental feature. >+ >+ * UIProcess/WebResourceLoadStatisticsStore.cpp: >+ (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess): >+ (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess): >+ (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener): >+ (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess): >+ (WebKit::WebResourceLoadStatisticsStore::grantStorageAccessInternal): >+ (WebKit::WebResourceLoadStatisticsStore::hasUserGrantedStorageAccessThroughPrompt const): >+ (WebKit::WebResourceLoadStatisticsStore::hasHadUnexpiredRecentUserInteraction const): >+ * UIProcess/WebResourceLoadStatisticsStore.h: >+ > 2018-05-08 Daniel Bates <dabates@apple.com> > > Do not apply X-Frame-Options and CSP frame-ancestors to Quick Look-applicable responses in NetworkProcess >Index: Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp >=================================================================== >--- Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (revision 231523) >+++ Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (working copy) >@@ -342,16 +342,24 @@ void WebResourceLoadStatisticsStore::has > > auto& subFrameStatistic = ensureResourceStatisticsForPrimaryDomain(subFramePrimaryDomain); > if (shouldBlockCookies(subFrameStatistic)) { >- callback(false); >+ RunLoop::main().dispatch([callback = WTFMove(callback)] { >+ callback(false); >+ }); > return; > } > > if (!shouldPartitionCookies(subFrameStatistic)) { >- callback(true); >+ RunLoop::main().dispatch([callback = WTFMove(callback)] { >+ callback(true); >+ }); > return; > } > >- m_hasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, WTFMove(callback)); >+ m_hasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, [callback = WTFMove(callback)] (bool value) mutable { >+ RunLoop::main().dispatch([callback = WTFMove(callback), value] () mutable { >+ callback(value); >+ }); >+ }); > }); > } > >@@ -384,7 +392,8 @@ void WebResourceLoadStatisticsStore::req > return; > } > >- if (promptEnabled) { >+ auto userWasPromptedEarlier = promptEnabled && hasUserGrantedStorageAccessThroughPrompt(subFrameStatistic, topFramePrimaryDomain); >+ if (promptEnabled && !userWasPromptedEarlier) { > RunLoop::main().dispatch([callback = WTFMove(callback)] { > callback(StorageAccessStatus::RequiresUserPrompt); > }); >@@ -393,7 +402,7 @@ void WebResourceLoadStatisticsStore::req > > subFrameStatistic.timesAccessedAsFirstPartyDueToStorageAccessAPI++; > >- grantStorageAccessInternal(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, false, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable { >+ grantStorageAccessInternal(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, userWasPromptedEarlier, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable { > RunLoop::main().dispatch([callback = WTFMove(callback), wasGrantedAccess] () mutable { > callback(wasGrantedAccess ? StorageAccessStatus::HasAccess : StorageAccessStatus::CannotRequestAccess); > }); >@@ -401,15 +410,15 @@ void WebResourceLoadStatisticsStore::req > }); > } > >-void WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener(String&& domainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerDomain, bool isTriggeredByUserGesture) >+void WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener(String&& primaryDomainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerPrimaryDomain, bool isTriggeredByUserGesture) > { >- ASSERT(domainInNeedOfStorageAccess != openerDomain); >+ ASSERT(primaryDomainInNeedOfStorageAccess != openerPrimaryDomain); > ASSERT(!RunLoop::isMain()); > >- if (domainInNeedOfStorageAccess == openerDomain) >+ if (primaryDomainInNeedOfStorageAccess == openerPrimaryDomain) > return; > >- auto& domainInNeedOfStorageAccessStatistic = ensureResourceStatisticsForPrimaryDomain(domainInNeedOfStorageAccess); >+ auto& domainInNeedOfStorageAccessStatistic = ensureResourceStatisticsForPrimaryDomain(primaryDomainInNeedOfStorageAccess); > auto cookiesBlocked = shouldBlockCookies(domainInNeedOfStorageAccessStatistic); > > // There are no cookies to get access to if the domain has its cookies blocked and did not get user interaction now. >@@ -420,17 +429,24 @@ void WebResourceLoadStatisticsStore::req > if (!cookiesBlocked && !shouldPartitionCookies(domainInNeedOfStorageAccessStatistic)) > return; > >- grantStorageAccessInternal(WTFMove(domainInNeedOfStorageAccess), WTFMove(openerDomain), std::nullopt, openerPageID, false, [](bool) { }); > #if !RELEASE_LOG_DISABLED >- 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")); >+ 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")); > #endif >+ grantStorageAccessInternal(WTFMove(primaryDomainInNeedOfStorageAccess), WTFMove(openerPrimaryDomain), std::nullopt, openerPageID, false, [](bool) { }); > } > >-void WebResourceLoadStatisticsStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& callback) >+void WebResourceLoadStatisticsStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& callback) > { > ASSERT(RunLoop::isMain()); >- m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPrompted, callback = WTFMove(callback)] () mutable { >- grantStorageAccessInternal(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable { >+ m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPromptedNow, callback = WTFMove(callback)] () mutable { >+ auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost); >+ auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost); >+ if (userWasPromptedNow) { >+ auto& subFrameStatistic = ensureResourceStatisticsForPrimaryDomain(subFramePrimaryDomain); >+ ASSERT(subFrameStatistic.hadUserInteraction); >+ subFrameStatistic.storageAccessUnderTopFrameOrigins.add(topFramePrimaryDomain); >+ } >+ grantStorageAccessInternal(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPromptedNow, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable { > RunLoop::main().dispatch([callback = WTFMove(callback), wasGrantedAccess] () mutable { > callback(wasGrantedAccess); > }); >@@ -438,16 +454,16 @@ void WebResourceLoadStatisticsStore::gra > }); > } > >-void WebResourceLoadStatisticsStore::grantStorageAccessInternal(String&& subFrameHost, String&& topFrameHost, std::optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& callback) >+void WebResourceLoadStatisticsStore::grantStorageAccessInternal(String&& subFramePrimaryDomain, String&& topFramePrimaryDomain, std::optional<uint64_t> frameID, uint64_t pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&& callback) > { >+ UNUSED_PARAM(userWasPromptedNowOrEarlier); > ASSERT(!RunLoop::isMain()); >- auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost); >- auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost); >+ > if (subFramePrimaryDomain == topFramePrimaryDomain) { > callback(true); > return; > } >- >+ > m_grantStorageAccessHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, WTFMove(callback)); > } > >@@ -1045,6 +1061,11 @@ bool WebResourceLoadStatisticsStore::sho > return statistic.isPrevalentResource && !statistic.hadUserInteraction; > } > >+bool WebResourceLoadStatisticsStore::hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics& statistic, const String& firstPartyPrimaryDomain) const >+{ >+ return statistic.storageAccessUnderTopFrameOrigins.contains(firstPartyPrimaryDomain); >+} >+ > void WebResourceLoadStatisticsStore::updateCookiePartitioning(CompletionHandler<void()>&& callback) > { > ASSERT(!RunLoop::isMain()); >@@ -1193,6 +1214,7 @@ bool WebResourceLoadStatisticsStore::has > // Set timestamp to 0 so that statistics merge will know > // it has been reset as opposed to its default -1. > resourceStatistic.mostRecentUserInteractionTime = { }; >+ resourceStatistic.storageAccessUnderTopFrameOrigins.clear(); > resourceStatistic.hadUserInteraction = false; > } > >Index: Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h >=================================================================== >--- Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (revision 231523) >+++ Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (working copy) >@@ -91,8 +91,8 @@ public: > > void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback); > void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); >- void requestStorageAccessUnderOpener(String&& domainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerDomain, bool isTriggeredByUserGesture); >- void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&); >+ void requestStorageAccessUnderOpener(String&& primaryDomainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerPrimaryDomain, bool isTriggeredByUserGesture); >+ void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&); > void requestStorageAccessCallback(bool wasGranted, uint64_t contextId); > > void processWillOpenConnection(WebProcessProxy&, IPC::Connection&); >@@ -171,6 +171,7 @@ private: > > bool shouldPartitionCookies(const WebCore::ResourceLoadStatistics&) const; > bool shouldBlockCookies(const WebCore::ResourceLoadStatistics&) const; >+ bool hasUserGrantedStorageAccessThroughPrompt(const WebCore::ResourceLoadStatistics&, const String& firstPartyPrimaryDomain) const; > bool hasStatisticsExpired(const WebCore::ResourceLoadStatistics&) const; > bool hasHadUnexpiredRecentUserInteraction(WebCore::ResourceLoadStatistics&) const; > void includeTodayAsOperatingDateIfNecessary(); >@@ -185,7 +186,8 @@ private: > void processStatisticsAndDataRecords(); > > void resetCookiePartitioningState(); >- void grantStorageAccessInternal(String&& subFrameHost, String&& topFrameHost, std::optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&); >+ StorageAccessStatus storageAccessStatus(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain); >+ void grantStorageAccessInternal(String&& subFrameHost, String&& topFrameHost, std::optional<uint64_t> frameID, uint64_t pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&&); > void removeAllStorageAccess(); > > void setDebugLogggingEnabled(bool enabled) { m_debugLoggingEnabled = enabled; }
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
Flags:
achristensen
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185454
: 339898