Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2023-10-18 11:48:06 +08:00
commit ecd3cd8676
53 changed files with 67 additions and 1452 deletions

View file

@ -45,11 +45,11 @@ HTTP_ATOM(Date, "Date")
HTTP_ATOM(DAV, "DAV")
HTTP_ATOM(Depth, "Depth")
HTTP_ATOM(Destination, "Destination")
HTTP_ATOM(DoNotTrack, "DNT")
HTTP_ATOM(ETag, "Etag")
HTTP_ATOM(Expect, "Expect")
HTTP_ATOM(Expires, "Expires")
HTTP_ATOM(From, "From")
HTTP_ATOM(GlobalPrivacyControl, "Sec-GPC")
HTTP_ATOM(Host, "Host")
HTTP_ATOM(If, "If")
HTTP_ATOM(If_Match, "If-Match")

View file

@ -5711,7 +5711,7 @@ nsHttpChannel::BeginConnect()
mRequestHead.SetOrigin(scheme, host, port);
SetOriginHeader();
SetDoNotTrack();
SetGPC();
NeckoOriginAttributes originAttributes;
NS_GetOriginAttributes(this, originAttributes);
@ -8051,18 +8051,13 @@ nsHttpChannel::SetOriginHeader()
}
void
nsHttpChannel::SetDoNotTrack()
nsHttpChannel::SetGPC()
{
/**
* 'DoNotTrack' header should be added if 'privacy.donottrackheader.enabled'
* is true or tracking protection is enabled. See bug 1258033.
* 'Sec-GPC: 1' header should be added if 'privacy.GPCheader.enabled' is true.
*/
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(this, loadContext);
if ((loadContext && loadContext->UseTrackingProtection()) ||
nsContentUtils::DoNotTrackEnabled()) {
mRequestHead.SetHeader(nsHttp::DoNotTrack,
if (nsContentUtils::GPCEnabled()) {
mRequestHead.SetHeader(nsHttp::GlobalPrivacyControl,
NS_LITERAL_CSTRING("1"),
false);
}

View file

@ -453,7 +453,7 @@ private:
void SetPushedStream(Http2PushedStreamWrapper *stream);
void SetOriginHeader();
void SetDoNotTrack();
void SetGPC();
private:
nsCOMPtr<nsICancelable> mProxyRequest;

View file

@ -87,7 +87,7 @@
#define HTTP_PREF_PREFIX "network.http."
#define INTL_ACCEPT_LANGUAGES "intl.accept_languages"
#define BROWSER_PREF_PREFIX "browser.cache."
#define DONOTTRACK_HEADER_ENABLED "privacy.donottrackheader.enabled"
#define GPC_HEADER_ENABLED "privacy.GPCheader.enabled"
#define H2MANDATORY_SUITE "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256"
#define ALLOW_EXPERIMENTS "network.allow-experiments"
#define SAFE_HINT_HEADER_VALUE "safeHint.enabled"
@ -181,7 +181,7 @@ nsHttpHandler::nsHttpHandler()
, mAcceptLanguagesIsDirty(true)
, mPromptTempRedirect(true)
, mEnablePersistentHttpsCaching(false)
, mDoNotTrackEnabled(false)
, mGPCEnabled(false)
, mSafeHintEnabled(false)
, mParentalControlEnabled(false)
, mHandlerActive(false)
@ -279,7 +279,7 @@ nsHttpHandler::Init()
prefBranch->AddObserver(UA_PREF_PREFIX, this, true);
prefBranch->AddObserver(INTL_ACCEPT_LANGUAGES, this, true);
prefBranch->AddObserver(BROWSER_PREF("disk_cache_ssl"), this, true);
prefBranch->AddObserver(DONOTTRACK_HEADER_ENABLED, this, true);
prefBranch->AddObserver(GPC_HEADER_ENABLED, this, true);
prefBranch->AddObserver(H2MANDATORY_SUITE, this, true);
prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.short_lived_connections"), this, true);
prefBranch->AddObserver(HTTP_PREF("tcp_keepalive.long_lived_connections"), this, true);
@ -1497,11 +1497,11 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
// Tracking options
//
if (PREF_CHANGED(DONOTTRACK_HEADER_ENABLED)) {
if (PREF_CHANGED(GPC_HEADER_ENABLED)) {
cVar = false;
rv = prefs->GetBoolPref(DONOTTRACK_HEADER_ENABLED, &cVar);
rv = prefs->GetBoolPref(GPC_HEADER_ENABLED, &cVar);
if (NS_SUCCEEDED(rv)) {
mDoNotTrackEnabled = cVar;
mGPCEnabled = cVar;
}
}
// Hint option

View file

@ -515,8 +515,8 @@ private:
// Persistent HTTPS caching flag
bool mEnablePersistentHttpsCaching;
// For broadcasting tracking preference
bool mDoNotTrackEnabled;
// For broadcasting Global Privacy Control preference
bool mGPCEnabled;
// for broadcasting safe hint;
bool mSafeHintEnabled;