зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1369319 - Part 1: Block device sensor events when 'privacy.resistFingerprinting' is true. r=arthuredelstein,bz
This patch adds a nsDeviceSensors::IsSensorEventBlocked() function to check whether device sensor events should be blocked and replaces original 'device.sensors.enabled' check with this function. This function will not only check 'privacy.resistFingerprinting' but also check 'device.sensors.enabled'. MozReview-Commit-ID: 7NZiBHWN6y6 --HG-- extra : rebase_source : 54d4cd99e5dfb089f11b19b0b487ff5add34b69c
This commit is contained in:
Родитель
c1ec6a75b3
Коммит
5baaeb9625
|
@ -7,6 +7,7 @@
|
|||
#include "mozilla/Hal.h"
|
||||
#include "mozilla/HalSensor.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDeviceSensors.h"
|
||||
|
||||
#include "nsIDOMEvent.h"
|
||||
|
@ -128,7 +129,7 @@ nsDeviceSensors::~nsDeviceSensors()
|
|||
|
||||
NS_IMETHODIMP nsDeviceSensors::HasWindowListener(uint32_t aType, nsIDOMWindow *aWindow, bool *aRetVal)
|
||||
{
|
||||
if (!mEnabled)
|
||||
if (AreSensorEventsDisabled(aWindow))
|
||||
*aRetVal = false;
|
||||
else
|
||||
*aRetVal = mWindowListeners[aType]->IndexOf(aWindow) != NoIndex;
|
||||
|
@ -169,7 +170,7 @@ static bool sTestSensorEvents = false;
|
|||
|
||||
NS_IMETHODIMP nsDeviceSensors::AddWindowListener(uint32_t aType, nsIDOMWindow *aWindow)
|
||||
{
|
||||
if (!mEnabled)
|
||||
if (AreSensorEventsDisabled(aWindow))
|
||||
return NS_OK;
|
||||
|
||||
if (mWindowListeners[aType]->IndexOf(aWindow) != NoIndex)
|
||||
|
@ -567,3 +568,19 @@ nsDeviceSensors::FireDOMMotionEvent(nsIDOMDocument *domdoc,
|
|||
mLastAcceleration.reset();
|
||||
mLastDOMMotionEventTime = TimeStamp::Now();
|
||||
}
|
||||
|
||||
bool
|
||||
nsDeviceSensors::AreSensorEventsDisabled(nsIDOMWindow* aWindow)
|
||||
{
|
||||
if (!mEnabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aWindow);
|
||||
|
||||
if (!window) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return nsContentUtils::ShouldResistFingerprinting(window->GetDocShell());
|
||||
}
|
||||
|
|
|
@ -74,6 +74,8 @@ private:
|
|||
return mWindowListeners[aType]->Length() > 0;
|
||||
}
|
||||
|
||||
bool AreSensorEventsDisabled(nsIDOMWindow* aWindow);
|
||||
|
||||
mozilla::TimeStamp mLastDOMMotionEventTime;
|
||||
bool mIsUserProximityNear;
|
||||
mozilla::Maybe<DeviceAccelerationInit> mLastAcceleration;
|
||||
|
|
Загрузка…
Ссылка в новой задаче