#include "nsISupports.idl"

interface nsIDOMElement;
interface nsIPrefBranch;

[scriptable, uuid(14027e96-1afb-4066-8846-e6c89b5faf3b)]
interface nsIRequestPolicy : nsISupports
{
  AString getUriIdentifier(in AString uri);

  void registerHistoryRequest(in AString destinationUri);
  void registerFormSubmitted(in AString originUri, in AString destinationUri);
  void registerLinkClicked(in AString originUri, in AString destinationUri);
  void registerAllowedRedirect(in AString originUri, in AString destinationUri);

  void temporarilyAllowOrigin(in AString siteIdentifier);
  boolean isTemporarilyAllowedOrigin(in AString siteIdentifier);

  void allowOrigin(in AString siteIdentifier);
  void allowOriginDelayStore(in AString siteIdentifier);
  boolean isAllowedOrigin(in AString siteIdentifier);

  void temporarilyAllowDestination(in AString siteIdentifier);
  boolean isTemporarilyAllowedDestination(in AString siteIdentifier);

  void allowDestination(in AString siteIdentifier);
  void allowDestinationDelayStore(in AString siteIdentifier);
  boolean isAllowedDestination(in AString siteIdentifier);

  void temporarilyAllowOriginToDestination(in AString originIdentifier, in AString destinationIdentifier);
  boolean isTemporarilyAllowedOriginToDestination(in AString originIdentifier, in AString destinationIdentifier);

  void allowOriginToDestination(in AString originIdentifier, in AString destinationIdentifier);
  void allowOriginToDestinationDelayStore(in AString originIdentifier, in AString destinationIdentifier);
  boolean isAllowedOriginToDestination(in AString originIdentifier, in AString destinationIdentifier);

  void storeAllPreferenceLists();

  void revokeTemporaryPermissions();
  boolean areTemporaryPermissionsGranted();

  void forbidOrigin(in AString siteIdentifier);
  void forbidOriginDelayStore(in AString siteIdentifier);

  void forbidDestination(in AString siteIdentifier);
  void forbidDestinationDelayStore(in AString siteIdentifier);

  void forbidOriginToDestination(in AString originIdentifier, in AString destinationIdentifier);
  void forbidOriginToDestinationDelayStore(in AString originIdentifier, in AString destinationIdentifier);

  /*
   * Tells RequestPolicy that blocked requests to newDestUri should be
   * additionally checked as if they were requests to origDestUri. This can be
   * used by extensions that rewrite destinations which RequestPolicy would
   * have originally recognized as allowed link clicks, form submissions, etc.
   *
   * @param origDestUri The original destination URI.
   * @param newDestUri The new destination URI.
   */
  void mapDestinations(in AString origDestUri, in AString newDestUri);

  boolean isAllowedRedirect(in AString originUri, in AString destinationUri);

  boolean isPrefetchEnabled();
  boolean isBlockingDisabled();
  boolean isPrivateBrowsingEnabled();

  boolean originHasRejectedRequests(in AString originUri);
  boolean originHasRejectedRequestsRecursive(in AString originUri);

  readonly attribute nsIPrefBranch prefs;
};
