nsICookieManager2.idl 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsICookieManager.idl"
  6. interface nsICookie2;
  7. interface nsIFile;
  8. /**
  9. * Additions to the frozen nsICookieManager
  10. */
  11. [scriptable, uuid(daf0caa7-b431-4b4d-ba51-08c179bb9dfe)]
  12. interface nsICookieManager2 : nsICookieManager
  13. {
  14. /**
  15. * Add a cookie. nsICookieService is the normal way to do this. This
  16. * method is something of a backdoor.
  17. *
  18. * @param aHost
  19. * the host or domain for which the cookie is set. presence of a
  20. * leading dot indicates a domain cookie; otherwise, the cookie
  21. * is treated as a non-domain cookie (see RFC2109). The host string
  22. * will be normalized to ASCII or ACE; any trailing dot will be
  23. * stripped. To be a domain cookie, the host must have at least two
  24. * subdomain parts (e.g. '.foo.com', not '.com'), otherwise an
  25. * exception will be thrown. An empty string is acceptable
  26. * (e.g. file:// URI's).
  27. * @param aPath
  28. * path within the domain for which the cookie is valid
  29. * @param aName
  30. * cookie name
  31. * @param aValue
  32. * cookie data
  33. * @param aIsSecure
  34. * true if the cookie should only be sent over a secure connection.
  35. * @param aIsHttpOnly
  36. * true if the cookie should only be sent to, and can only be
  37. * modified by, an http connection.
  38. * @param aIsSession
  39. * true if the cookie should exist for the current session only.
  40. * see aExpiry.
  41. * @param aExpiry
  42. * expiration date, in seconds since midnight (00:00:00), January 1,
  43. * 1970 UTC. note that expiry time will also be honored for session cookies;
  44. * in this way, the more restrictive of the two will take effect.
  45. * @param aOriginAttributes The originAttributes of this cookie. This
  46. * attribute is optional to avoid breaking add-ons.
  47. */
  48. [implicit_jscontext, optional_argc]
  49. void add(in AUTF8String aHost,
  50. in AUTF8String aPath,
  51. in ACString aName,
  52. in ACString aValue,
  53. in boolean aIsSecure,
  54. in boolean aIsHttpOnly,
  55. in boolean aIsSession,
  56. in int64_t aExpiry,
  57. [optional] in jsval aOriginAttributes);
  58. [notxpcom]
  59. nsresult addNative(in AUTF8String aHost,
  60. in AUTF8String aPath,
  61. in ACString aName,
  62. in ACString aValue,
  63. in boolean aIsSecure,
  64. in boolean aIsHttpOnly,
  65. in boolean aIsSession,
  66. in int64_t aExpiry,
  67. in NeckoOriginAttributesPtr aOriginAttributes);
  68. /**
  69. * Find whether a given cookie already exists.
  70. *
  71. * @param aCookie
  72. * the cookie to look for
  73. * @param aOriginAttributes
  74. * nsICookie2 contains an originAttributes but if nsICookie2 is
  75. * implemented in JS, we can't retrieve its originAttributes because
  76. * the getter is marked [implicit_jscontext]. This optional parameter
  77. * is a workaround.
  78. *
  79. * @return true if a cookie was found which matches the host, path, and name
  80. * fields of aCookie
  81. */
  82. [implicit_jscontext, optional_argc]
  83. boolean cookieExists(in nsICookie2 aCookie,
  84. [optional] in jsval aOriginAttributes);
  85. [notxpcom]
  86. nsresult cookieExistsNative(in nsICookie2 aCookie,
  87. in NeckoOriginAttributesPtr aOriginAttributes,
  88. out boolean aExists);
  89. /**
  90. * Count how many cookies exist within the base domain of 'aHost'.
  91. * Thus, for a host "weather.yahoo.com", the base domain would be "yahoo.com",
  92. * and any host or domain cookies for "yahoo.com" and its subdomains would be
  93. * counted.
  94. *
  95. * @param aHost
  96. * the host string to search for, e.g. "google.com". this should consist
  97. * of only the host portion of a URI. see @add for a description of
  98. * acceptable host strings.
  99. *
  100. * @return the number of cookies found.
  101. */
  102. unsigned long countCookiesFromHost(in AUTF8String aHost);
  103. /**
  104. * Returns an enumerator of cookies that exist within the base domain of
  105. * 'aHost'. Thus, for a host "weather.yahoo.com", the base domain would be
  106. * "yahoo.com", and any host or domain cookies for "yahoo.com" and its
  107. * subdomains would be returned.
  108. *
  109. * @param aHost
  110. * the host string to search for, e.g. "google.com". this should consist
  111. * of only the host portion of a URI. see @add for a description of
  112. * acceptable host strings.
  113. * @param aOriginAttributes The originAttributes of cookies that would be
  114. * retrived. This attribute is optional to avoid
  115. * breaking add-ons.
  116. *
  117. * @return an nsISimpleEnumerator of nsICookie2 objects.
  118. *
  119. * @see countCookiesFromHost
  120. */
  121. [implicit_jscontext, optional_argc]
  122. nsISimpleEnumerator getCookiesFromHost(in AUTF8String aHost,
  123. [optional] in jsval aOriginAttributes);
  124. /**
  125. * Import an old-style cookie file. Imported cookies will be added to the
  126. * existing database. If the database contains any cookies the same as those
  127. * being imported (i.e. domain, name, and path match), they will be replaced.
  128. *
  129. * @param aCookieFile the file to import, usually cookies.txt
  130. */
  131. void importCookies(in nsIFile aCookieFile);
  132. /**
  133. * Returns an enumerator of all cookies whose origin attributes matches aPattern
  134. *
  135. * @param aPattern origin attribute pattern in JSON format
  136. *
  137. * @param aHost
  138. * the host string to search for, e.g. "google.com". this should consist
  139. * of only the host portion of a URI. see @add for a description of
  140. * acceptable host strings. This attribute is optional. It will search
  141. * all hosts if this attribute is not given.
  142. */
  143. nsISimpleEnumerator getCookiesWithOriginAttributes(in DOMString aPattern,
  144. [optional] in AUTF8String aHost);
  145. /**
  146. * Remove all the cookies whose origin attributes matches aPattern
  147. *
  148. * @param aPattern origin attribute pattern in JSON format
  149. */
  150. void removeCookiesWithOriginAttributes(in DOMString aPattern,
  151. [optional] in AUTF8String aHost);
  152. };