diff options
-rw-r--r-- | dom/base/Navigator.cpp | 18 | ||||
-rw-r--r-- | dom/base/Navigator.h | 2 | ||||
-rw-r--r-- | dom/base/nsContentUtils.cpp | 10 | ||||
-rw-r--r-- | dom/base/nsContentUtils.h | 6 | ||||
-rw-r--r-- | dom/interfaces/base/nsIDOMNavigator.idl | 1 | ||||
-rw-r--r-- | dom/webidl/Navigator.webidl | 8 | ||||
-rw-r--r-- | dom/webidl/WorkerNavigator.webidl | 1 | ||||
-rw-r--r-- | dom/workers/WorkerNavigator.h | 6 | ||||
-rw-r--r-- | modules/libpref/init/all.js | 4 | ||||
-rw-r--r-- | netwerk/protocol/http/nsHttpAtomList.h | 2 | ||||
-rw-r--r-- | netwerk/protocol/http/nsHttpChannel.cpp | 15 | ||||
-rw-r--r-- | netwerk/protocol/http/nsHttpChannel.h | 2 | ||||
-rw-r--r-- | netwerk/protocol/http/nsHttpHandler.cpp | 22 | ||||
-rw-r--r-- | netwerk/protocol/http/nsHttpHandler.h | 4 |
14 files changed, 46 insertions, 55 deletions
diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index e15e32d328..0e4a406fee 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -630,22 +630,10 @@ Navigator::GetBuildID(nsAString& aBuildID) return NS_OK; } -NS_IMETHODIMP -Navigator::GetDoNotTrack(nsAString &aResult) +bool +Navigator::GlobalPrivacyControl() { - bool doNotTrack = nsContentUtils::DoNotTrackEnabled(); - if (!doNotTrack) { - nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(mWindow); - doNotTrack = loadContext && loadContext->UseTrackingProtection(); - } - - if (doNotTrack) { - aResult.AssignLiteral("1"); - } else { - aResult.AssignLiteral("unspecified"); - } - - return NS_OK; + return nsContentUtils::GPCEnabled(); } bool diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index df99844ca9..56e7dfaf8a 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -129,7 +129,7 @@ public: nsMimeTypeArray* GetMimeTypes(ErrorResult& aRv); nsPluginArray* GetPlugins(ErrorResult& aRv); Permissions* GetPermissions(ErrorResult& aRv); - // The XPCOM GetDoNotTrack is ok + bool GlobalPrivacyControl(); Geolocation* GetGeolocation(ErrorResult& aRv); static void AppName(nsAString& aAppName, bool aUsePrefOverriddenValue); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index fdffd95531..e88e31bd9d 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -306,7 +306,7 @@ bool nsContentUtils::sFragmentParsingActive = false; bool nsContentUtils::sDOMWindowDumpEnabled; #endif -bool nsContentUtils::sDoNotTrackEnabled = false; +bool nsContentUtils::sGPCEnabled = false; mozilla::LazyLogModule nsContentUtils::sDOMDumpLog("Dump"); @@ -623,8 +623,8 @@ nsContentUtils::Init() "browser.dom.window.dump.enabled"); #endif - Preferences::AddBoolVarCache(&sDoNotTrackEnabled, - "privacy.donottrackheader.enabled", false); + Preferences::AddBoolVarCache(&sGPCEnabled, + "privacy.GPCheader.enabled", false); Preferences::AddBoolVarCache(&sUseActivityCursor, "ui.use_activity_cursor", false); @@ -7122,9 +7122,9 @@ nsContentUtils::DOMWindowDumpEnabled() } bool -nsContentUtils::DoNotTrackEnabled() +nsContentUtils::GPCEnabled() { - return nsContentUtils::sDoNotTrackEnabled; + return nsContentUtils::sGPCEnabled; } mozilla::LogModule* diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index b3bc22f286..5c9d12a684 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -2404,9 +2404,9 @@ public: static bool DOMWindowDumpEnabled(); /** - * Returns true if the privacy.donottrackheader.enabled pref is set. + * Returns true if the privacy.GPCheader.enabled pref is set. */ - static bool DoNotTrackEnabled(); + static bool GPCEnabled(); /** * Returns a LogModule that dump calls from content script are logged to. @@ -2891,7 +2891,7 @@ private: #if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP)) static bool sDOMWindowDumpEnabled; #endif - static bool sDoNotTrackEnabled; + static bool sGPCEnabled; static mozilla::LazyLogModule sDOMDumpLog; }; diff --git a/dom/interfaces/base/nsIDOMNavigator.idl b/dom/interfaces/base/nsIDOMNavigator.idl index 5fd16b8aeb..d4a06c21dc 100644 --- a/dom/interfaces/base/nsIDOMNavigator.idl +++ b/dom/interfaces/base/nsIDOMNavigator.idl @@ -22,5 +22,4 @@ interface nsIDOMNavigator : nsISupports readonly attribute DOMString productSub; readonly attribute DOMString userAgent; readonly attribute DOMString buildID; - readonly attribute DOMString doNotTrack; }; diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index 43d53cbac0..379585ef9f 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -30,6 +30,7 @@ Navigator implements NavigatorContentUtils; Navigator implements NavigatorStorageUtils; Navigator implements NavigatorConcurrentHardware; Navigator implements NavigatorStorage; +Navigator implements NavigatorGlobalPrivacyControl; [NoInterfaceObject, Exposed=(Window,Worker)] interface NavigatorID { @@ -111,9 +112,10 @@ partial interface Navigator { readonly attribute PluginArray plugins; }; -// http://www.w3.org/TR/tracking-dnt/ sort of -partial interface Navigator { - readonly attribute DOMString doNotTrack; +// https://globalprivacycontrol.github.io/gpc-spec/ +[NoInterfaceObject, Exposed=(Window,Worker)] +interface NavigatorGlobalPrivacyControl { + readonly attribute boolean globalPrivacyControl; }; // http://www.w3.org/TR/geolocation-API/#geolocation_interface diff --git a/dom/webidl/WorkerNavigator.webidl b/dom/webidl/WorkerNavigator.webidl index 44d1e29f68..fc3fd603c6 100644 --- a/dom/webidl/WorkerNavigator.webidl +++ b/dom/webidl/WorkerNavigator.webidl @@ -12,3 +12,4 @@ WorkerNavigator implements NavigatorLanguage; WorkerNavigator implements NavigatorOnLine; WorkerNavigator implements NavigatorConcurrentHardware; WorkerNavigator implements NavigatorStorage; +WorkerNavigator implements NavigatorGlobalPrivacyControl; diff --git a/dom/workers/WorkerNavigator.h b/dom/workers/WorkerNavigator.h index 5617b7351d..f845ac12f5 100644 --- a/dom/workers/WorkerNavigator.h +++ b/dom/workers/WorkerNavigator.h @@ -8,6 +8,7 @@ #include "Workers.h" #include "RuntimeService.h" +#include "nsContentUtils.h" #include "nsString.h" #include "nsWrapperCache.h" #include "mozilla/dom/StorageManager.h" @@ -100,6 +101,11 @@ public: mOnline = aOnline; } + bool GlobalPrivacyControl() const + { + return nsContentUtils::GPCEnabled(); + } + void SetLanguages(const nsTArray<nsString>& aLanguages); uint64_t HardwareConcurrency() const; diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 01309308b6..1cfc1f1623 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1205,8 +1205,8 @@ pref("content.sink.pending_event_mode", 0); // 2 = openAbused pref("privacy.popups.disable_from_plugins", 2); -// send "do not track" HTTP header, disabled by default -pref("privacy.donottrackheader.enabled", false); +// Send "Sec-GPC" HTTP header, disabled by default +pref("privacy.GPCheader.enabled", false); // Enforce tracking protection in all modes pref("privacy.trackingprotection.enabled", false); // Enforce tracking protection in Private Browsing mode diff --git a/netwerk/protocol/http/nsHttpAtomList.h b/netwerk/protocol/http/nsHttpAtomList.h index 5db985613e..867ac0010d 100644 --- a/netwerk/protocol/http/nsHttpAtomList.h +++ b/netwerk/protocol/http/nsHttpAtomList.h @@ -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") diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 464f7507d8..3ba812b923 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -5711,7 +5711,7 @@ nsHttpChannel::BeginConnect() mRequestHead.SetHTTPS(isHttps); mRequestHead.SetOrigin(scheme, host, port); - SetDoNotTrack(); + SetGPC(); NeckoOriginAttributes originAttributes; NS_GetOriginAttributes(this, originAttributes); @@ -8035,18 +8035,13 @@ nsHttpChannel::ResumeInternal() } 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); } diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index b7f39b2f09..76cffe8670 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -453,7 +453,7 @@ private: void SetPushedStream(Http2PushedStreamWrapper *stream); - void SetDoNotTrack(); + void SetGPC(); private: nsCOMPtr<nsICancelable> mProxyRequest; diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 42c7b1a8fe..81b8a9f550 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -89,12 +89,12 @@ #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 H2MANDATORY_SUITE "security.ssl3.ecdhe_rsa_aes_128_gcm_sha256" -#define ALLOW_EXPERIMENTS "network.allow-experiments" -#define SAFE_HINT_HEADER_VALUE "safeHint.enabled" -#define SECURITY_PREFIX "security." -#define NEW_TAB_REMOTE_MODE "browser.newtabpage.remote.mode" +#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" +#define SECURITY_PREFIX "security." +#define NEW_TAB_REMOTE_MODE "browser.newtabpage.remote.mode" #define GUA_PREF(_pref) GENERAL_UA_PREF_PREFIX _pref #define UA_PREF(_pref) HTTP_PREF_PREFIX UA_PREF_PREFIX _pref @@ -184,7 +184,7 @@ nsHttpHandler::nsHttpHandler() , mAcceptLanguagesIsDirty(true) , mPromptTempRedirect(true) , mEnablePersistentHttpsCaching(false) - , mDoNotTrackEnabled(false) + , mGPCEnabled(false) , mSafeHintEnabled(false) , mParentalControlEnabled(false) , mHandlerActive(false) @@ -282,7 +282,7 @@ nsHttpHandler::Init() prefBranch->AddObserver(GENERAL_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); @@ -1500,11 +1500,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 diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index c3f6290095..caeabf81de 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -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; |