summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-10-07 21:38:26 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-01 14:41:51 +0200
commitc030a50228349fa1b2c0b4fbc2e83752324dd4d7 (patch)
tree7102015febc58021d3e6af6ac40b3299e437f1d2 /dom
parente4c6db86b806a9b7b11b94323189954736d45a67 (diff)
downloaduxp-c030a50228349fa1b2c0b4fbc2e83752324dd4d7.tar.gz
Issue #1721 - Implement GlobalPrivacyControl
(and get rid of failed DoNotTrack)
Diffstat (limited to 'dom')
-rw-r--r--dom/base/Navigator.cpp18
-rw-r--r--dom/base/Navigator.h2
-rw-r--r--dom/base/nsContentUtils.cpp10
-rw-r--r--dom/base/nsContentUtils.h6
-rw-r--r--dom/interfaces/base/nsIDOMNavigator.idl1
-rw-r--r--dom/webidl/Navigator.webidl8
-rw-r--r--dom/webidl/WorkerNavigator.webidl1
-rw-r--r--dom/workers/WorkerNavigator.h6
8 files changed, 24 insertions, 28 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;