Skip to content

Commit

Permalink
Trigger Storage Access API prompt quirk only on triggering pages
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270204
rdar://problem/123727259

Reviewed by Wenson Hsieh.

We currently trigger the quirk on any page that matches the quirk's top-frame
site. This broad matching behavior can result in excessive and incorrect
prompting. This change introduces a notion of "triggering pages" which define
the exact pages where the quirk should be used. We can extend this to support
globs in the future.

Covered by existing API tests and a new one.

* Source/WebCore/PAL/pal/cocoa/WebPrivacySoftLink.h:
* Source/WebCore/PAL/pal/cocoa/WebPrivacySoftLink.mm:

Fix a typo and add a missing class

* Source/WebCore/PAL/pal/spi/cocoa/WebPrivacySPI.h:
* Source/WebCore/platform/network/NetworkStorageSession.cpp:
(WebCore::NetworkStorageSession::storageAccessQuirkForTopFrameDomain):
(WebCore::NetworkStorageSession::storageAccessQuirkForDomainPair):
* Source/WebCore/platform/network/NetworkStorageSession.h:
* Source/WebCore/platform/network/OrganizationStorageAccessPromptQuirk.h:
(WebCore::OrganizationStorageAccessPromptQuirk::OrganizationStorageAccessPromptQuirk):
* Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
(WebKit::ResourceLoadStatisticsStore::grantStorageAccess):
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::storageAccessQuirkForTopFrameDomain):
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* Source/WebKit/Platform/cocoa/WebPrivacyHelpers.mm:
(WebKit::StorageAccessPromptQuirkController::setCachedQuirks):
(WebKit::quirkDomainsDictToMap):
(WebKit::quirkPagesArrayToVector):
(WebKit::StorageAccessPromptQuirkController::updateQuirks):
(WebKit::domainPairingsDictToMap): Deleted.
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _setStorageAccessPromptQuirkForTesting:withSubFrameDomains:withTriggerPages:completionHandler:]):
(-[WKWebsiteDataStore _setStorageAccessPromptQuirkForTesting:withSubFrameDomains:completionHandler:]): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::requestStorageAccessConfirm):
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* Source/WebKit/UIProcess/WebProcessPool.cpp:
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::setStorageAccessPromptQuirkForTesting):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::loadStorageAccessQuirksIfNeeded):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
(TEST):

Canonical link: https://commits.webkit.org/276151@main
  • Loading branch information
sysrqb authored and Matthew Finkel committed Mar 15, 2024
1 parent 84313c5 commit 69d1d39
Show file tree
Hide file tree
Showing 21 changed files with 199 additions and 43 deletions.
3 changes: 2 additions & 1 deletion Source/WebCore/PAL/pal/cocoa/WebPrivacySoftLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, WebPrivacy)
SOFT_LINK_CLASS_FOR_HEADER(PAL, WPResourceRequestOptions)
SOFT_LINK_CLASS_FOR_HEADER(PAL, WPResources)
SOFT_LINK_CLASS_FOR_HEADER(PAL, WPLinkFilteringData)
SOFT_LINK_CLASS_FOR_HEADER(PAL, WPStorageAccessQuirksData)
SOFT_LINK_CLASS_FOR_HEADER(PAL, WPStorageAccessPromptQuirk)
SOFT_LINK_CLASS_FOR_HEADER(PAL, WPStorageAccessPromptQuirksData)
SOFT_LINK_CLASS_FOR_HEADER(PAL, WPStorageAccessUserAgentStringQuirkData)
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, WebPrivacy, WPNotificationUserInfoResourceTypeKey, NSString *)
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, WebPrivacy, WPResourceDataChangedNotificationName, NSNotificationName)
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/PAL/pal/cocoa/WebPrivacySoftLink.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, WebPrivacy, WPResourceRequestOptions, PAL_EXPORT)
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, WebPrivacy, WPResources, PAL_EXPORT)
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, WebPrivacy, WPLinkFilteringData, PAL_EXPORT)
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, WebPrivacy, WPStorageAccessQuirksData, PAL_EXPORT)
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, WebPrivacy, WPStorageAccessPromptQuirk, PAL_EXPORT)
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, WebPrivacy, WPStorageAccessPromptQuirksData, PAL_EXPORT)
SOFT_LINK_CLASS_FOR_SOURCE_OPTIONAL_WITH_EXPORT(PAL, WebPrivacy, WPStorageAccessUserAgentStringQuirkData, PAL_EXPORT)
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, WebPrivacy, WPNotificationUserInfoResourceTypeKey, NSString *, PAL_EXPORT)
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, WebPrivacy, WPResourceDataChangedNotificationName, NSNotificationName, PAL_EXPORT)
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/PAL/pal/spi/cocoa/WebPrivacySPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ constexpr NSInteger WPResourceTypeStorageAccessPromptQuirksData = 7;
@interface WPStorageAccessPromptQuirk : NSObject
@property (nonatomic, readonly) NSString *name;
@property (nonatomic, readonly) NSDictionary<NSString *, NSArray<NSString *> *> *domainPairings;
@property (nonatomic, readonly) NSDictionary<NSString *, NSArray<NSString *> *> *quirkDomains;
@property (nonatomic, readonly) NSArray<NSString *> *triggerPages;
@end

@interface WPStorageAccessPromptQuirksData : NSObject
Expand Down
17 changes: 10 additions & 7 deletions Source/WebCore/platform/network/NetworkStorageSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,15 @@ std::optional<RegistrableDomain> NetworkStorageSession::findAdditionalLoginDomai
return std::nullopt;
}

Vector<RegistrableDomain> NetworkStorageSession::storageAccessQuirkForTopFrameDomain(const TopFrameDomain& topDomain)
Vector<RegistrableDomain> NetworkStorageSession::storageAccessQuirkForTopFrameDomain(const URL& topFrameURL)
{
for (auto&& quirk : updatableStorageAccessPromptQuirks()) {
auto& domainPairings = quirk.domainPairings;
auto entry = domainPairings.find(topDomain);
if (entry == domainPairings.end())
if (!quirk.triggerPages.isEmpty() && !quirk.triggerPages.contains(topFrameURL))
continue;

auto quirkDomains = quirk.quirkDomains;
auto entry = quirkDomains.find(RegistrableDomain { topFrameURL });
if (entry == quirkDomains.end())
continue;
return entry->value;
}
Expand All @@ -509,9 +512,9 @@ Vector<RegistrableDomain> NetworkStorageSession::storageAccessQuirkForTopFrameDo
std::optional<OrganizationStorageAccessPromptQuirk> NetworkStorageSession::storageAccessQuirkForDomainPair(const TopFrameDomain& topDomain, const SubResourceDomain& subDomain)
{
for (auto&& quirk : updatableStorageAccessPromptQuirks()) {
auto& domainPairings = quirk.domainPairings;
auto entry = domainPairings.find(topDomain);
if (entry == domainPairings.end())
auto& quirkDomains = quirk.quirkDomains;
auto entry = quirkDomains.find(topDomain);
if (entry == quirkDomains.end())
continue;
if (!WTF::anyOf(entry->value, [&subDomain](auto&& entry) { return entry == subDomain; }))
break;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/network/NetworkStorageSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class NetworkStorageSession : public CanMakeWeakPtr<NetworkStorageSession> {
WEBCORE_EXPORT static std::optional<HashSet<RegistrableDomain>> subResourceDomainsInNeedOfStorageAccessForFirstParty(const RegistrableDomain&);
WEBCORE_EXPORT static bool loginDomainMatchesRequestingDomain(const TopFrameDomain&, const SubResourceDomain&);
WEBCORE_EXPORT static std::optional<RegistrableDomain> findAdditionalLoginDomain(const TopFrameDomain&, const SubResourceDomain&);
WEBCORE_EXPORT static Vector<RegistrableDomain> storageAccessQuirkForTopFrameDomain(const TopFrameDomain&);
WEBCORE_EXPORT static Vector<RegistrableDomain> storageAccessQuirkForTopFrameDomain(const URL& topFrameURL);
WEBCORE_EXPORT static std::optional<OrganizationStorageAccessPromptQuirk> storageAccessQuirkForDomainPair(const TopFrameDomain&, const SubResourceDomain&);

#if ENABLE(APP_BOUND_DOMAINS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ namespace WebCore {

struct OrganizationStorageAccessPromptQuirk {
String organizationName;
HashMap<RegistrableDomain, Vector<RegistrableDomain>> domainPairings;
HashMap<RegistrableDomain, Vector<RegistrableDomain>> quirkDomains;
Vector<URL> triggerPages;

bool isHashTableDeletedValue() const { return organizationName.isHashTableDeletedValue(); }

OrganizationStorageAccessPromptQuirk(String&& organizationName, HashMap<RegistrableDomain, Vector<RegistrableDomain>>&& domainPairings)
OrganizationStorageAccessPromptQuirk(String&& organizationName, HashMap<RegistrableDomain, Vector<RegistrableDomain>>&& quirkDomains, Vector<URL>&& triggerPages)
: organizationName { WTFMove(organizationName) }
, domainPairings { WTFMove(domainPairings) }
, quirkDomains { WTFMove(quirkDomains) }
, triggerPages { WTFMove(triggerPages) }
{ }

OrganizationStorageAccessPromptQuirk(WTF::HashTableDeletedValueType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ void ResourceLoadStatisticsStore::grantStorageAccess(SubFrameDomain&& subFrameDo
return;
}
if (additionalDomainGrants) {
for (auto&& [quirkTopFrameDomain, subFrameDomains] : additionalDomainGrants->domainPairings) {
for (auto&& [quirkTopFrameDomain, subFrameDomains] : additionalDomainGrants->quirkDomains) {
for (auto&& quirkSubFrameDomain : subFrameDomains) {
if (quirkTopFrameDomain == topFrameDomain && quirkSubFrameDomain == subFrameDomain)
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,9 @@ void NetworkConnectionToWebProcess::requestStorageAccess(RegistrableDomain&& sub
completionHandler({ WebCore::StorageAccessWasGranted::Yes, WebCore::StorageAccessPromptWasShown::No, scope, topFrameDomain, subFrameDomain });
}

void NetworkConnectionToWebProcess::storageAccessQuirkForTopFrameDomain(WebCore::RegistrableDomain&& topFrameDomain, CompletionHandler<void(Vector<RegistrableDomain>)>&& completionHandler)
void NetworkConnectionToWebProcess::storageAccessQuirkForTopFrameDomain(URL&& topFrameURL, CompletionHandler<void(Vector<RegistrableDomain>)>&& completionHandler)
{
completionHandler(NetworkStorageSession::storageAccessQuirkForTopFrameDomain(topFrameDomain));
completionHandler(NetworkStorageSession::storageAccessQuirkForTopFrameDomain(topFrameURL));
}

void NetworkConnectionToWebProcess::requestStorageAccessUnderOpener(WebCore::RegistrableDomain&& domainInNeedOfStorageAccess, PageIdentifier openerPageID, WebCore::RegistrableDomain&& openerDomain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class NetworkConnectionToWebProcess
void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&, CompletionHandler<void()>&&);
void hasStorageAccess(RegistrableDomain&& subFrameDomain, RegistrableDomain&& topFrameDomain, WebCore::FrameIdentifier, WebCore::PageIdentifier, CompletionHandler<void(bool)>&&);
void requestStorageAccess(RegistrableDomain&& subFrameDomain, RegistrableDomain&& topFrameDomain, WebCore::FrameIdentifier, WebCore::PageIdentifier, WebPageProxyIdentifier, WebCore::StorageAccessScope, CompletionHandler<void(WebCore::RequestStorageAccessResult)>&&);
void storageAccessQuirkForTopFrameDomain(WebCore::RegistrableDomain&&, CompletionHandler<void(Vector<RegistrableDomain>)>&&);
void storageAccessQuirkForTopFrameDomain(URL&& topFrameURL, CompletionHandler<void(Vector<RegistrableDomain>)>&&);
void requestStorageAccessUnderOpener(WebCore::RegistrableDomain&& domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::RegistrableDomain&& openerDomain);

void addOriginAccessAllowListEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ messages -> NetworkConnectionToWebProcess LegacyReceiver {
ResourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics> statistics) -> ()
HasStorageAccess(WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID) -> (bool hasStorageAccess)
RequestStorageAccess(WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier webPageID, WebKit::WebPageProxyIdentifier webPageProxyID, enum:bool WebCore::StorageAccessScope scope) -> (struct WebCore::RequestStorageAccessResult result)
StorageAccessQuirkForTopFrameDomain(WebCore::RegistrableDomain topFrameDomain) -> (Vector<WebCore::RegistrableDomain> domains)
StorageAccessQuirkForTopFrameDomain(URL topFrameURL) -> (Vector<WebCore::RegistrableDomain> domains)
RequestStorageAccessUnderOpener(WebCore::RegistrableDomain domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::RegistrableDomain openerDomain)

AddOriginAccessAllowListEntry(String sourceOrigin, String destinationProtocol, String destinationHost, bool allowDestinationSubdomains);
Expand Down
26 changes: 21 additions & 5 deletions Source/WebKit/Platform/cocoa/WebPrivacyHelpers.mm
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ void requestLinkDecorationFilteringData(LinkFilteringRulesCallback&& callback)
{
m_cachedQuirks = WTFMove(quirks);
m_cachedQuirks.shrinkToFit();
RELEASE_LOG_ERROR(ResourceLoadStatistics, "StorageAccessPromptQuirkController::setCachedQuirks: Loaded %lu storage access prompt(s) quirks from WebPrivacy.", quirks.size());
}

void StorageAccessPromptQuirkController::setCachedQuirksForTesting(Vector<WebCore::OrganizationStorageAccessPromptQuirk>&& quirks)
Expand All @@ -313,13 +314,13 @@ void requestLinkDecorationFilteringData(LinkFilteringRulesCallback&& callback)
});
}

static HashMap<WebCore::RegistrableDomain, Vector<WebCore::RegistrableDomain>> domainPairingsDictToMap(NSDictionary<NSString *, NSArray<NSString *> *> *domainPairings)
static HashMap<WebCore::RegistrableDomain, Vector<WebCore::RegistrableDomain>> quirkDomainsDictToMap(NSDictionary<NSString *, NSArray<NSString *> *> *quirkDomains)
{
HashMap<WebCore::RegistrableDomain, Vector<WebCore::RegistrableDomain>> map;
auto* topDomains = domainPairings.allKeys;
auto* topDomains = quirkDomains.allKeys;
for (NSString *topDomain : topDomains) {
Vector<WebCore::RegistrableDomain> subFrameDomains;
for (NSString *subFrameDomain : [domainPairings objectForKey:topDomain])
for (NSString *subFrameDomain : [quirkDomains objectForKey:topDomain])
subFrameDomains.append(WebCore::RegistrableDomain::fromRawString(subFrameDomain));
map.add(WebCore::RegistrableDomain::fromRawString(String { topDomain }), WTFMove(subFrameDomains));
}
Expand All @@ -339,6 +340,16 @@ void requestLinkDecorationFilteringData(LinkFilteringRulesCallback&& callback)
m_wasInitialized = true;
}

static Vector<URL> quirkPagesArrayToVector(NSArray<NSString *> *triggerPages)
{
Vector<URL> triggers;
for (NSString *page : triggerPages) {
if (![page isEqualToString:@"*"])
triggers.append(URL { page });
}
return triggers;
}

void StorageAccessPromptQuirkController::updateQuirks(CompletionHandler<void()>&& completionHandler)
{
ASSERT(RunLoop::isMain());
Expand All @@ -361,8 +372,13 @@ void requestLinkDecorationFilteringData(LinkFilteringRulesCallback&& callback)
RELEASE_LOG_ERROR(ResourceLoadStatistics, "Failed to request storage access quirks from WebPrivacy.");
else {
auto quirks = [data quirks];
for (WPStorageAccessPromptQuirk *quirk : quirks)
result.append(WebCore::OrganizationStorageAccessPromptQuirk { quirk.name, domainPairingsDictToMap(quirk.domainPairings) });
auto hasQuirkDomainsAndTriggerPages = [PAL::getWPStorageAccessPromptQuirkClass() instancesRespondToSelector:@selector(quirkDomains)] && [PAL::getWPStorageAccessPromptQuirkClass() instancesRespondToSelector:@selector(triggerPages)];
for (WPStorageAccessPromptQuirk *quirk : quirks) {
if (hasQuirkDomainsAndTriggerPages)
result.append(WebCore::OrganizationStorageAccessPromptQuirk { quirk.name, quirkDomainsDictToMap(quirk.quirkDomains), quirkPagesArrayToVector(quirk.triggerPages) });
else
result.append(WebCore::OrganizationStorageAccessPromptQuirk { quirk.name, quirkDomainsDictToMap(quirk.domainPairings), { } });
}
setCachedQuirks(WTFMove(result));
}

Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
Original file line number Diff line number Diff line change
Expand Up @@ -7512,7 +7512,8 @@ struct WebCore::Length {

struct WebCore::OrganizationStorageAccessPromptQuirk {
String organizationName;
HashMap<WebCore::RegistrableDomain, Vector<WebCore::RegistrableDomain>> domainPairings;
HashMap<WebCore::RegistrableDomain, Vector<WebCore::RegistrableDomain>> quirkDomains;
Vector<URL> triggerPages;
};

#if ENABLE(SHAREABLE_RESOURCE)
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -708,12 +708,12 @@ - (void)_setResourceLoadStatisticsTestingCallback:(void (^)(WKWebsiteDataStore *
_websiteDataStore->setStatisticsTestingCallback(nullptr);
}

- (void)_setStorageAccessPromptQuirkForTesting:(NSString *)topFrameDomain withSubFrameDomains:(NSArray<NSString *> *)subFrameDomains completionHandler:(void(^)(void))completionHandler
- (void)_setStorageAccessPromptQuirkForTesting:(NSString *)topFrameDomain withSubFrameDomains:(NSArray<NSString *> *)subFrameDomains withTriggerPages:(NSArray<NSString *> *)triggerPages completionHandler:(void(^)(void))completionHandler
{
if (!_websiteDataStore->isPersistent())
return;

_websiteDataStore->setStorageAccessPromptQuirkForTesting(topFrameDomain, makeVector<String>(subFrameDomains), makeBlockPtr(completionHandler));
_websiteDataStore->setStorageAccessPromptQuirkForTesting(topFrameDomain, makeVector<String>(subFrameDomains), makeVector<String>(triggerPages), makeBlockPtr(completionHandler));
}

- (void)_grantStorageAccessForTesting:(NSString *)topFrameDomain withSubFrameDomains:(NSArray<NSString *> *)subFrameDomains completionHandler:(void(^)(void))completionHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ typedef NS_ENUM(uint8_t, _WKRestrictedOpenerType) {
- (void)_loadedSubresourceDomainsFor:(WKWebView *)webView completionHandler:(void (^)(NSArray<NSString *> *domains))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));
- (void)_clearLoadedSubresourceDomainsFor:(WKWebView *)webView WK_API_AVAILABLE(macos(12.0), ios(15.0));
+ (void)_allowWebsiteDataRecordsForAllOrigins WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
- (void)_setStorageAccessPromptQuirkForTesting:(NSString *)topFrameDomain withSubFrameDomains:(NSArray<NSString *> *)subFrameDomains completionHandler:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_setStorageAccessPromptQuirkForTesting:(NSString *)topFrameDomain withSubFrameDomains:(NSArray<NSString *> *)subFrameDomains withTriggerPages:(NSArray<NSString *> *)triggerPages completionHandler:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (void)_grantStorageAccessForTesting:(NSString *)topFrameDomain withSubFrameDomains:(NSArray<NSString *> *)subFrameDomains completionHandler:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

- (void)_scheduleCookieBlockingUpdate:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(10.15), ios(13.0));
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@

NSMutableDictionary<NSString *, NSArray<NSString *> *> *quirkDomains = [NSMutableDictionary dictionaryWithCapacity:1];
if (organizationStorageAccessPromptQuirk) {
for (auto& [topFrameDomain, subFrameDomains] : organizationStorageAccessPromptQuirk->domainPairings) {
for (auto& [topFrameDomain, subFrameDomains] : organizationStorageAccessPromptQuirk->quirkDomains) {
NSMutableArray<NSString *> *mutableSubFrameDomains = [NSMutableArray arrayWithCapacity:subFrameDomains.size()];
for (auto& subFrameDomain : subFrameDomains)
[mutableSubFrameDomains addObject:subFrameDomain.string()];
Expand All @@ -479,7 +479,7 @@

if (organizationStorageAccessPromptQuirk) {
#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
presentStorageAccessAlertSSOQuirk(m_uiDelegate->m_webView.get().get(), organizationStorageAccessPromptQuirk->organizationName, organizationStorageAccessPromptQuirk->domainPairings, WTFMove(completionHandler));
presentStorageAccessAlertSSOQuirk(m_uiDelegate->m_webView.get().get(), organizationStorageAccessPromptQuirk->organizationName, organizationStorageAccessPromptQuirk->quirkDomains, WTFMove(completionHandler));
#endif
return;
}
Expand Down
7 changes: 6 additions & 1 deletion Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,12 @@ static void logProcessPoolState(const WebProcessPool& pool)
parameters.storageAccessUserAgentStringQuirksData = StorageAccessUserAgentStringQuirkController::shared().cachedQuirks();

for (auto&& entry : StorageAccessPromptQuirkController::shared().cachedQuirks()) {
for (auto&& domain : entry.domainPairings.keys())
if (!entry.triggerPages.isEmpty()) {
for (auto&& page : entry.triggerPages)
parameters.storageAccessPromptQuirksDomains.add(RegistrableDomain { page });
continue;
}
for (auto&& domain : entry.quirkDomains.keys())
parameters.storageAccessPromptQuirksDomains.add(domain);
}
#endif
Expand Down
7 changes: 6 additions & 1 deletion Source/WebKit/UIProcess/WebProcessPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,12 @@ WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration& configuration)
if (RefPtr protectedThis = weakThis.get()) {
HashSet<WebCore::RegistrableDomain> domainSet;
for (auto&& entry : StorageAccessPromptQuirkController::shared().cachedQuirks()) {
for (auto&& domain : entry.domainPairings.keys())
if (!entry.triggerPages.isEmpty()) {
for (auto&& page : entry.triggerPages)
domainSet.add(RegistrableDomain::uncheckedCreateFromRegistrableDomainString(page.string()));
continue;
}
for (auto&& domain : entry.quirkDomains.keys())
domainSet.add(domain);
}
protectedThis->sendToAllProcesses(Messages::WebProcess::UpdateDomainsWithStorageAccessQuirks(domainSet));
Expand Down
Loading

0 comments on commit 69d1d39

Please sign in to comment.