LibWeb+LibWebView+WebContent: Replace DNT with GPC

Global Privacy Control aims to be a replacement for Do Not Track. DNT
ended up not being a great solution, as it wasn't enforced by law. This
actually resulted in the DNT header serving as an extra fingerprinting
data point.

GPC is becoming enforced by law in USA states such as California and
Colorado. CA is further working on a bill which requires that browsers
implement such an opt-out preference signal (OOPS):

https://cppa.ca.gov/announcements/2025/20250911.html

This patch replaces DNT with GPC and hooks up the associated settings.
This commit is contained in:
Timothy Flynn 2025-04-02 09:30:34 -04:00 committed by Jelle Raaijmakers
parent d9ebd44924
commit b4df857a57
Notes: github-actions[bot] 2025-09-16 08:39:19 +00:00
22 changed files with 105 additions and 60 deletions

View file

@ -134,18 +134,6 @@ WebIDL::Long Navigator::max_touch_points()
return 0;
}
// https://www.w3.org/TR/tracking-dnt/#dom-navigator-donottrack
Optional<FlyString> Navigator::do_not_track() const
{
// The value is null if no DNT header field would be sent (e.g., because a tracking preference is not
// enabled and no user-granted exception is applicable); otherwise, the value is a string beginning with
// "0" or "1", possibly followed by DNT-extension characters.
if (ResourceLoader::the().enable_do_not_track())
return "1"_fly_string;
return {};
}
GC::Ref<ServiceWorker::ServiceWorkerContainer> Navigator::service_worker()
{
if (!m_service_worker_container)

View file

@ -8,6 +8,7 @@
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/EncryptedMediaExtensions/NavigatorEncryptedMediaExtensionsPartial.h>
#include <LibWeb/GPC/GlobalPrivacyControl.h>
#include <LibWeb/Gamepad/NavigatorGamepad.h>
#include <LibWeb/HTML/MimeTypeArray.h>
#include <LibWeb/HTML/NavigatorBeacon.h>
@ -24,11 +25,13 @@
namespace Web::HTML {
class Navigator : public Bindings::PlatformObject
class Navigator
: public Bindings::PlatformObject
, public NavigatorBeaconPartial
, public NavigatorConcurrentHardwareMixin
, public NavigatorDeviceMemoryMixin
, public Gamepad::NavigatorGamepadPartial
, public GlobalPrivacyControl::GlobalPrivacyControlMixin
, public EncryptedMediaExtensions::NavigatorEncryptedMediaExtensionsPartial
, public NavigatorIDMixin
, public NavigatorLanguageMixin
@ -63,8 +66,6 @@ public:
[[nodiscard]] GC::Ref<UserActivation> user_activation();
[[nodiscard]] GC::Ref<CredentialManagement::CredentialsContainer> credentials();
Optional<FlyString> do_not_track() const;
GC::Ref<ServiceWorker::ServiceWorkerContainer> service_worker();
GC::Ref<MediaCapabilitiesAPI::MediaCapabilities> media_capabilities();

View file

@ -3,6 +3,7 @@
#import <EncryptedMediaExtensions/MediaKeySystemAccess.idl>
#import <Gamepad/Gamepad.idl>
#import <Geolocation/Geolocation.idl>
#import <GPC/GlobalPrivacyControl.idl>
#import <HTML/MimeTypeArray.idl>
#import <HTML/NavigatorBeacon.idl>
#import <HTML/NavigatorConcurrentHardware.idl>
@ -37,9 +38,6 @@ interface Navigator {
// https://html.spec.whatwg.org/multipage/interaction.html#useractivation
[SameObject] readonly attribute UserActivation userActivation;
// https://www.w3.org/TR/tracking-dnt/#dom-navigator-donottrack
readonly attribute DOMString? doNotTrack;
// https://w3c.github.io/ServiceWorker/#navigator-serviceworker
[SecureContext, SameObject] readonly attribute ServiceWorkerContainer serviceWorker;
@ -77,6 +75,7 @@ interface mixin NavigatorAutomationInformation {
readonly attribute boolean webdriver;
};
Navigator includes GlobalPrivacyControl;
Navigator includes NavigatorID;
Navigator includes NavigatorLanguage;
Navigator includes NavigatorOnLine;

View file

@ -8,6 +8,7 @@
#pragma once
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/GPC/GlobalPrivacyControl.h>
#include <LibWeb/HTML/NavigatorConcurrentHardware.h>
#include <LibWeb/HTML/NavigatorDeviceMemory.h>
#include <LibWeb/HTML/NavigatorID.h>
@ -20,7 +21,9 @@
namespace Web::HTML {
class WorkerNavigator : public Bindings::PlatformObject
class WorkerNavigator
: public Bindings::PlatformObject
, public GlobalPrivacyControl::GlobalPrivacyControlMixin
, public NavigatorConcurrentHardwareMixin
, public NavigatorDeviceMemoryMixin
, public NavigatorIDMixin

View file

@ -1,3 +1,4 @@
#import <GPC/GlobalPrivacyControl.idl>
#import <HTML/NavigatorConcurrentHardware.idl>
#import <HTML/NavigatorDeviceMemory.idl>
#import <HTML/NavigatorID.idl>
@ -20,6 +21,7 @@ interface WorkerNavigator {
[SecureContext, SameObject] readonly attribute ServiceWorkerContainer serviceWorker;
};
Navigator includes GlobalPrivacyControl;
WorkerNavigator includes NavigatorID;
WorkerNavigator includes NavigatorLanguage;
WorkerNavigator includes NavigatorOnLine;