nsICookiePermission.idl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsISupports.idl"
  5. interface nsICookie2;
  6. interface nsIURI;
  7. interface nsIChannel;
  8. typedef long nsCookieAccess;
  9. /**
  10. * An interface to test for cookie permissions
  11. */
  12. [scriptable, uuid(11ddd4ed-8f5b-40b3-b2a0-27c20ea1c88d)]
  13. interface nsICookiePermission : nsISupports
  14. {
  15. /**
  16. * nsCookieAccess values
  17. */
  18. const nsCookieAccess ACCESS_DEFAULT = 0;
  19. const nsCookieAccess ACCESS_ALLOW = 1;
  20. const nsCookieAccess ACCESS_DENY = 2;
  21. /**
  22. * additional values for nsCookieAccess which may not match
  23. * nsIPermissionManager. Keep 3-7 available to allow nsIPermissionManager to
  24. * add values without colliding. ACCESS_SESSION is not directly returned by
  25. * any methods on this interface.
  26. */
  27. const nsCookieAccess ACCESS_SESSION = 8;
  28. const nsCookieAccess ACCESS_ALLOW_FIRST_PARTY_ONLY = 9;
  29. const nsCookieAccess ACCESS_LIMIT_THIRD_PARTY = 10;
  30. /**
  31. * setAccess
  32. *
  33. * this method is called to block cookie access for the given URI. this
  34. * may result in other URIs being blocked as well (e.g., URIs which share
  35. * the same host name).
  36. *
  37. * @param aURI
  38. * the URI to block
  39. * @param aAccess
  40. * the new cookie access for the URI.
  41. */
  42. void setAccess(in nsIURI aURI,
  43. in nsCookieAccess aAccess);
  44. /**
  45. * canAccess
  46. *
  47. * this method is called to test whether or not the given URI/channel may
  48. * access the cookie database, either to set or get cookies.
  49. *
  50. * @param aURI
  51. * the URI trying to access cookies
  52. * @param aChannel
  53. * the channel corresponding to aURI
  54. *
  55. * @return one of the following nsCookieAccess values:
  56. * ACCESS_DEFAULT, ACCESS_ALLOW, ACCESS_DENY, or
  57. * ACCESS_ALLOW_FIRST_PARTY_ONLY
  58. */
  59. nsCookieAccess canAccess(in nsIURI aURI,
  60. in nsIChannel aChannel);
  61. /**
  62. * canSetCookie
  63. *
  64. * this method is called to test whether or not the given URI/channel may
  65. * set a specific cookie. this method is always preceded by a call to
  66. * canAccess. it may modify the isSession and expiry attributes of the
  67. * cookie via the aIsSession and aExpiry parameters, in order to limit
  68. * or extend the lifetime of the cookie. this is useful, for instance, to
  69. * downgrade a cookie to session-only if it fails to meet certain criteria.
  70. *
  71. * @param aURI
  72. * the URI trying to set the cookie
  73. * @param aChannel
  74. * the channel corresponding to aURI
  75. * @param aCookie
  76. * the cookie being added to the cookie database
  77. * @param aIsSession
  78. * when canSetCookie is invoked, this is the current isSession attribute
  79. * of the cookie. canSetCookie may leave this value unchanged to
  80. * preserve this attribute of the cookie.
  81. * @param aExpiry
  82. * when canSetCookie is invoked, this is the current expiry time of
  83. * the cookie. canSetCookie may leave this value unchanged to
  84. * preserve this attribute of the cookie.
  85. *
  86. * @return true if the cookie can be set.
  87. */
  88. boolean canSetCookie(in nsIURI aURI,
  89. in nsIChannel aChannel,
  90. in nsICookie2 aCookie,
  91. inout boolean aIsSession,
  92. inout int64_t aExpiry);
  93. };
  94. %{ C++
  95. /**
  96. * The nsICookiePermission implementation is an XPCOM service registered
  97. * under the ContractID:
  98. */
  99. #define NS_COOKIEPERMISSION_CONTRACTID "@mozilla.org/cookie/permission;1"
  100. %}