netwerk/cookie/nsICookiePermission.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/cookie/nsICookiePermission.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "nsISupports.idl"
     1.9 +
    1.10 +interface nsICookie2;
    1.11 +interface nsIURI;
    1.12 +interface nsIChannel;
    1.13 +
    1.14 +typedef long nsCookieAccess;
    1.15 +
    1.16 +/**
    1.17 + * An interface to test for cookie permissions
    1.18 + */
    1.19 +[scriptable, uuid(11ddd4ed-8f5b-40b3-b2a0-27c20ea1c88d)]
    1.20 +interface nsICookiePermission : nsISupports
    1.21 +{
    1.22 +  /**
    1.23 +   * nsCookieAccess values
    1.24 +   */
    1.25 +  const nsCookieAccess ACCESS_DEFAULT = 0;
    1.26 +  const nsCookieAccess ACCESS_ALLOW   = 1;
    1.27 +  const nsCookieAccess ACCESS_DENY    = 2;
    1.28 +
    1.29 +  /**
    1.30 +   * additional values for nsCookieAccess which may not match
    1.31 +   * nsIPermissionManager. Keep 3-7 available to allow nsIPermissionManager to
    1.32 +   * add values without colliding. ACCESS_SESSION is not directly returned by
    1.33 +   * any methods on this interface.
    1.34 +   */
    1.35 +  const nsCookieAccess ACCESS_SESSION = 8;
    1.36 +  const nsCookieAccess ACCESS_ALLOW_FIRST_PARTY_ONLY = 9;
    1.37 +  const nsCookieAccess ACCESS_LIMIT_THIRD_PARTY = 10;
    1.38 +
    1.39 +  /**
    1.40 +   * setAccess
    1.41 +   *
    1.42 +   * this method is called to block cookie access for the given URI.  this
    1.43 +   * may result in other URIs being blocked as well (e.g., URIs which share
    1.44 +   * the same host name).
    1.45 +   *
    1.46 +   * @param aURI
    1.47 +   *        the URI to block
    1.48 +   * @param aAccess
    1.49 +   *        the new cookie access for the URI.
    1.50 +   */
    1.51 +  void setAccess(in nsIURI         aURI,
    1.52 +                 in nsCookieAccess aAccess);
    1.53 +
    1.54 +  /**
    1.55 +   * canAccess
    1.56 +   *
    1.57 +   * this method is called to test whether or not the given URI/channel may
    1.58 +   * access the cookie database, either to set or get cookies.
    1.59 +   *
    1.60 +   * @param aURI
    1.61 +   *        the URI trying to access cookies
    1.62 +   * @param aChannel
    1.63 +   *        the channel corresponding to aURI
    1.64 +   *
    1.65 +   * @return one of the following nsCookieAccess values:
    1.66 +   *         ACCESS_DEFAULT, ACCESS_ALLOW, ACCESS_DENY, or
    1.67 +   *         ACCESS_ALLOW_FIRST_PARTY_ONLY
    1.68 +   */
    1.69 +  nsCookieAccess canAccess(in nsIURI     aURI,
    1.70 +                           in nsIChannel aChannel);
    1.71 +
    1.72 +  /**
    1.73 +   * canSetCookie
    1.74 +   *
    1.75 +   * this method is called to test whether or not the given URI/channel may
    1.76 +   * set a specific cookie.  this method is always preceded by a call to
    1.77 +   * canAccess. it may modify the isSession and expiry attributes of the
    1.78 +   * cookie via the aIsSession and aExpiry parameters, in order to limit
    1.79 +   * or extend the lifetime of the cookie. this is useful, for instance, to
    1.80 +   * downgrade a cookie to session-only if it fails to meet certain criteria.
    1.81 +   *
    1.82 +   * @param aURI
    1.83 +   *        the URI trying to set the cookie
    1.84 +   * @param aChannel
    1.85 +   *        the channel corresponding to aURI
    1.86 +   * @param aCookie
    1.87 +   *        the cookie being added to the cookie database
    1.88 +   * @param aIsSession
    1.89 +   *        when canSetCookie is invoked, this is the current isSession attribute
    1.90 +   *        of the cookie. canSetCookie may leave this value unchanged to
    1.91 +   *        preserve this attribute of the cookie.
    1.92 +   * @param aExpiry
    1.93 +   *        when canSetCookie is invoked, this is the current expiry time of
    1.94 +   *        the cookie. canSetCookie may leave this value unchanged to
    1.95 +   *        preserve this attribute of the cookie.
    1.96 +   *
    1.97 +   * @return true if the cookie can be set.
    1.98 +   */
    1.99 +  boolean canSetCookie(in nsIURI     aURI,
   1.100 +                       in nsIChannel aChannel,
   1.101 +                       in nsICookie2 aCookie,
   1.102 +                       inout boolean aIsSession,
   1.103 +                       inout int64_t aExpiry);
   1.104 +};
   1.105 +
   1.106 +%{ C++
   1.107 +/**
   1.108 + * The nsICookiePermission implementation is an XPCOM service registered
   1.109 + * under the ContractID:
   1.110 + */
   1.111 +#define NS_COOKIEPERMISSION_CONTRACTID "@mozilla.org/cookie/permission;1"
   1.112 +%}

mercurial