Skip to content

Commit

Permalink
Add SPI for setting default value of TrackingPreventionEnabled flag o…
Browse files Browse the repository at this point in the history
…n _WKWebsiteDataStoreConfiguration

https://bugs.webkit.org/show_bug.cgi?id=270505
rdar://124053569

Reviewed by Chris Dumez.

In current implementation, when client does not explicitly set TrackingPreventionEnabled flag on WebsiteDataStore, we
will use the default value, which is the TCC permission value. For clients that do not want to use the TCC permission
value by chance, add a new SPI for setting the default value at data store creation time.

* Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
(-[_WKWebsiteDataStoreConfiguration defaultTrackingPreventionEnabledOverride]):
(-[_WKWebsiteDataStoreConfiguration setDefaultTrackingPreventionEnabledOverride:]):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::defaultTrackingPreventionEnabled const):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
(WebKit::WebsiteDataStoreConfiguration::defaultTrackingPreventionEnabledOverride const):
(WebKit::WebsiteDataStoreConfiguration::setDefaultTrackingPreventionEnabledOverride):

Canonical link: https://commits.webkit.org/275753@main
  • Loading branch information
szewai committed Mar 6, 2024
1 parent de89f29 commit 048ee14
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ WK_CLASS_AVAILABLE(macos(10.13), ios(11.0))
@property (nonatomic) _WKUnifiedOriginStorageLevel unifiedOriginStorageLevel WK_API_AVAILABLE(macos(13.3), ios(16.4));
@property (nonatomic, nullable, copy) NSNumber *volumeCapacityOverride WK_API_AVAILABLE(macos(14.0), ios(17.0));
@property (nonatomic) BOOL isDeclarativeWebPushEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, nullable, copy) NSNumber *defaultTrackingPreventionEnabledOverride WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

// Testing only.
@property (nonatomic) BOOL allLoadsBlockedByDeviceManagementRestrictionsForTesting WK_API_AVAILABLE(macos(10.15), ios(13.0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,24 @@ - (void)setResourceLoadStatisticsDebugModeEnabled:(BOOL)enabled
_configuration->setResourceLoadStatisticsDebugModeEnabled(enabled);
}

- (NSNumber *)defaultTrackingPreventionEnabledOverride
{
auto enabled = _configuration->defaultTrackingPreventionEnabledOverride();
if (!enabled)
return nil;

return [NSNumber numberWithBool:*enabled];
}

- (void)setDefaultTrackingPreventionEnabledOverride:(NSNumber *)defaultTrackingPreventionEnabledOverride
{
std::optional<bool> enabled;
if (defaultTrackingPreventionEnabledOverride)
enabled = [defaultTrackingPreventionEnabledOverride boolValue];

_configuration->setDefaultTrackingPreventionEnabledOverride(enabled);
}

- (NSUUID *)identifier
{
auto currentIdentifier = _configuration->identifier();
Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,9 @@ void WebsiteDataStore::sendNetworkProcessDidResume()
bool WebsiteDataStore::defaultTrackingPreventionEnabled() const
{
#if PLATFORM(COCOA)
if (auto enabledOverride = m_configuration->defaultTrackingPreventionEnabledOverride())
return *enabledOverride;

return doesAppHaveTrackingPreventionEnabled();
#else
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class WebsiteDataStoreConfiguration : public API::ObjectImpl<API::Object::Type::
bool resourceLoadStatisticsDebugModeEnabled() const { return m_trackingPreventionDebugModeEnabled; }
void setResourceLoadStatisticsDebugModeEnabled(bool enabled) { m_trackingPreventionDebugModeEnabled = enabled; }

std::optional<bool> defaultTrackingPreventionEnabledOverride() const { return m_defaultTrackingPreventionEnabledOverride; }
void setDefaultTrackingPreventionEnabledOverride(std::optional<bool> enabled) { m_defaultTrackingPreventionEnabledOverride = enabled; }

unsigned testSpeedMultiplier() const { return m_testSpeedMultiplier; }
void setTestSpeedMultiplier(unsigned multiplier) { m_testSpeedMultiplier = multiplier; }

Expand Down Expand Up @@ -326,6 +329,7 @@ class WebsiteDataStoreConfiguration : public API::ObjectImpl<API::Object::Type::
RetainPtr<CFDictionaryRef> m_proxyConfiguration;
#endif
Vector<size_t> m_memoryFootprintNotificationThresholds;
std::optional<bool> m_defaultTrackingPreventionEnabledOverride;
};

}

0 comments on commit 048ee14

Please sign in to comment.