[tbb-commits] [tor-browser/tor-browser-38.4.0esr-5.0-1] Bug #17207: Hide mime types and plugins when resisting fingerprinting
gk at torproject.org
gk at torproject.org
Thu Dec 10 10:04:23 UTC 2015
commit 7267388a1c76a609d55300b3a726fb872bb5ef1d
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date: Fri Oct 16 16:09:54 2015 -0700
Bug #17207: Hide mime types and plugins when resisting fingerprinting
---
dom/base/nsMimeTypeArray.cpp | 19 +++++++++++++++++++
dom/base/nsPluginArray.cpp | 13 ++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/dom/base/nsMimeTypeArray.cpp b/dom/base/nsMimeTypeArray.cpp
index 257abf6..ee530a3 100644
--- a/dom/base/nsMimeTypeArray.cpp
+++ b/dom/base/nsMimeTypeArray.cpp
@@ -14,6 +14,7 @@
#include "nsIMIMEInfo.h"
#include "Navigator.h"
#include "nsServiceManagerUtils.h"
+#include "nsContentUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
@@ -39,6 +40,12 @@ nsMimeTypeArray::~nsMimeTypeArray()
{
}
+static bool
+ResistFingerprinting() {
+ return !nsContentUtils::ThreadsafeIsCallerChrome() &&
+ nsContentUtils::ResistFingerprinting();
+}
+
JSObject*
nsMimeTypeArray::WrapObject(JSContext* aCx)
{
@@ -78,6 +85,10 @@ nsMimeTypeArray::IndexedGetter(uint32_t aIndex, bool &aFound)
{
aFound = false;
+ if (ResistFingerprinting()) {
+ return nullptr;
+ }
+
EnsurePluginMimeTypes();
if (aIndex >= mMimeTypes.Length()) {
@@ -108,6 +119,10 @@ nsMimeTypeArray::NamedGetter(const nsAString& aName, bool &aFound)
{
aFound = false;
+ if (ResistFingerprinting()) {
+ return nullptr;
+ }
+
EnsurePluginMimeTypes();
nsString lowerName(aName);
@@ -181,6 +196,10 @@ nsMimeTypeArray::NameIsEnumerable(const nsAString& aName)
uint32_t
nsMimeTypeArray::Length()
{
+ if (ResistFingerprinting()) {
+ return 0;
+ }
+
EnsurePluginMimeTypes();
return mMimeTypes.Length();
diff --git a/dom/base/nsPluginArray.cpp b/dom/base/nsPluginArray.cpp
index 1dcd551..8f789ee 100644
--- a/dom/base/nsPluginArray.cpp
+++ b/dom/base/nsPluginArray.cpp
@@ -20,6 +20,7 @@
#include "nsIWeakReference.h"
#include "mozilla/Services.h"
#include "nsIInterfaceRequestorUtils.h"
+#include "nsContentUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
@@ -43,6 +44,12 @@ nsPluginArray::~nsPluginArray()
{
}
+static bool
+ResistFingerprinting() {
+ return !nsContentUtils::ThreadsafeIsCallerChrome() &&
+ nsContentUtils::ResistFingerprinting();
+}
+
nsPIDOMWindow*
nsPluginArray::GetParentObject() const
{
@@ -174,7 +181,7 @@ nsPluginArray::IndexedGetter(uint32_t aIndex, bool &aFound)
{
aFound = false;
- if (!AllowPlugins()) {
+ if (!AllowPlugins() || ResistFingerprinting()) {
return nullptr;
}
@@ -217,7 +224,7 @@ nsPluginArray::NamedGetter(const nsAString& aName, bool &aFound)
{
aFound = false;
- if (!AllowPlugins()) {
+ if (!AllowPlugins() || ResistFingerprinting()) {
return nullptr;
}
@@ -241,7 +248,7 @@ nsPluginArray::NameIsEnumerable(const nsAString& aName)
uint32_t
nsPluginArray::Length()
{
- if (!AllowPlugins()) {
+ if (!AllowPlugins() || ResistFingerprinting()) {
return 0;
}
More information about the tbb-commits
mailing list