Commit df42b5ce authored by Tom Schuster's avatar Tom Schuster
Browse files

Bug 1834737 - Make RFPTarget parameter of ShouldResistFingerprinting with...

Bug 1834737 - Make RFPTarget parameter of ShouldResistFingerprinting with nsIGlobalObject non-optional. r=tjr

Differential Revision: https://phabricator.services.mozilla.com/D179229
parent 71b1d38b
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -2158,9 +2158,8 @@ bool nsContentUtils::ShouldResistFingerprinting(
}

/* static */
bool nsContentUtils::ShouldResistFingerprinting(
    nsIGlobalObject* aGlobalObject,
    RFPTarget aTarget /* = RFPTarget::Unknown */) {
bool nsContentUtils::ShouldResistFingerprinting(nsIGlobalObject* aGlobalObject,
                                                RFPTarget aTarget) {
  if (!aGlobalObject) {
    return ShouldResistFingerprinting("Null Object", aTarget);
  }
+5 −5
Original line number Diff line number Diff line
@@ -356,13 +356,13 @@ class nsContentUtils {
  // This function can be called both in the main thread and worker threads.
  static bool ShouldResistFingerprinting(
      RFPTarget aTarget = RFPTarget::Unknown);
  static bool ShouldResistFingerprinting(
      nsIGlobalObject* aGlobalObject, RFPTarget aTarget = RFPTarget::Unknown);
  static bool ShouldResistFingerprinting(nsIGlobalObject* aGlobalObject,
                                         RFPTarget aTarget);
  // Similar to the function above, but always allows CallerType::System
  // callers.
  static bool ShouldResistFingerprinting(
      mozilla::dom::CallerType aCallerType, nsIGlobalObject* aGlobalObject,
      RFPTarget aTarget = RFPTarget::Unknown);
  static bool ShouldResistFingerprinting(mozilla::dom::CallerType aCallerType,
                                         nsIGlobalObject* aGlobalObject,
                                         RFPTarget aTarget);
  static bool ShouldResistFingerprinting(nsIDocShell* aDocShell,
                                         RFPTarget aTarget);
  // These functions are the new, nuanced functions
+2 −2
Original line number Diff line number Diff line
@@ -221,8 +221,8 @@ CSSIntPoint MouseEvent::ScreenPoint(CallerType aCallerType) const {
    return {};
  }

  if (aCallerType != CallerType::System &&
      nsContentUtils::ShouldResistFingerprinting(GetParentObject())) {
  if (nsContentUtils::ShouldResistFingerprinting(aCallerType, GetParentObject(),
                                                 RFPTarget::Unknown)) {
    // Sanitize to something sort of like client cooords, but not quite
    // (defaulting to (0,0) instead of our pre-specified client coords).
    return Event::GetClientCoords(mPresContext, mEvent, mEvent->mRefPoint,
+2 −1
Original line number Diff line number Diff line
@@ -62,7 +62,8 @@ void AudioStreamTrack::SetAudioOutputVolume(void* aKey, float aVolume) {
void AudioStreamTrack::GetLabel(nsAString& aLabel, CallerType aCallerType) {
  nsIGlobalObject* global =
      GetParentObject() ? GetParentObject()->AsGlobal() : nullptr;
  if (nsContentUtils::ShouldResistFingerprinting(aCallerType, global)) {
  if (nsContentUtils::ShouldResistFingerprinting(aCallerType, global,
                                                 RFPTarget::StreamTrackLabel)) {
    aLabel.AssignLiteral("Internal Microphone");
    return;
  }
+2 −1
Original line number Diff line number Diff line
@@ -321,7 +321,8 @@ void MediaStreamTrack::GetSettings(dom::MediaTrackSettings& aResult,

  // Spoof values when privacy.resistFingerprinting is true.
  nsIGlobalObject* global = mWindow ? mWindow->AsGlobal() : nullptr;
  if (!nsContentUtils::ShouldResistFingerprinting(aCallerType, global)) {
  if (!nsContentUtils::ShouldResistFingerprinting(
          aCallerType, global, RFPTarget::StreamVideoFacingMode)) {
    return;
  }
  if (aResult.mFacingMode.WasPassed()) {
Loading