/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsIFingerprintingWebCompatService.idl"
#include "nsIRFPTargetSetIDL.idl"

interface nsIPrincipal;
interface nsIChannel;

/**
 * The singleton serivce which handles fingerprinting protection stuffs.
 */
[scriptable, builtinclass, uuid(20093b2e-d5d5-4ce0-8355-96b8d2dc7ff5)]
interface nsIRFPService : nsISupports
{
  /**
   * Set the fingerprinting overrides.
   *
   * @param aOverrides
   *        An array of fingerprinting overrides.
   */
  void setFingerprintingOverrides(in Array<nsIFingerprintingOverride> aOverrides);

  /**
   * Get the fingerprinting overrides of the given scope. This is for testing
   * purpose.
   *
   * @param aScope
   *        The scope of the fingerprinting override.
   * @return The RFPTarget flags for the fingerprinting overrides of the given
   *         scope. 0 if the overridden scope doesn't exist.
   *
   */
  nsIRFPTargetSetIDL getFingerprintingOverrides(in ACString aDomainKey);

  /**
   * Clean all overrides. This is for testing purpose.
   */
  void cleanAllOverrides();

  /**
   * Enabled baseline FPP targets.
   */
  readonly attribute nsIRFPTargetSetIDL enabledFingerprintingProtectionsBaseline;

  /**
   * Enabled FPP targets.
   */
  readonly attribute nsIRFPTargetSetIDL enabledFingerprintingProtections;

  /**
   * Clean all fingerprinting randomization keys.
   */
  void cleanAllRandomKeys();

  /**
   * Clean the fingerprinting randomization key by the given principal.
   */
  void cleanRandomKeyByPrincipal(in nsIPrincipal aPrincipal);

  /**
   * Clean the fingerprinting randomization key by the given domain.
   */
  [implicit_jscontext]
  void cleanRandomKeyBySite(in ACString aSchemelessSite, in jsval originAttributes);

  /**
   * Clean the fingerprinting randomization key by the given host and
   * OriginAttributesPattern.
   */
  void cleanRandomKeyByHost(in ACString aHost,
                            in AString  aPattern);

  /**
   * Clean the fingerprinting randomization key by the given
   * OriginAttributesPattern.
   */
  void cleanRandomKeyByOriginAttributesPattern(in AString aPattern);

  [binaryname(GetSpoofedUserAgentService)]
  ACString getSpoofedUserAgent(in boolean aDesktopMode);

  /**
   * Test function for generating and return the fingerprinting randomization
   * key for the given channel.
   */
  Array<uint8_t> testGenerateRandomKey(in nsIChannel aChannel);
};
