Backed out 2 changesets (bug 1943998) for causing wd failures @ phases.py CLOSED...
[gecko.git] / netwerk / cookie / nsICookieManager.idl
blob21ff46de687a20e6171fb6876e5f3f5004cb1fba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/. */
6 #include "nsISupports.idl"
7 #include "nsICookie.idl"
8 #include "nsIThirdPartyCookieBlockingExceptionListService.idl"
10 %{ C++
11 namespace mozilla {
12 class OriginAttributes;
13 } // mozilla namespace
16 [ptr] native OriginAttributesPtr(mozilla::OriginAttributes);
18 /**
19 * An optional interface for accessing or removing the cookies
20 * that are in the cookie list
23 [scriptable, builtinclass, uuid(AAAB6710-0F2C-11d5-A53B-0010A401EB10)]
24 interface nsICookieManager : nsISupports
27 /**
28 * Called to remove all cookies from the cookie list
30 void removeAll();
32 /**
33 * Returns an array of cookies in the cookie list.
34 * The objects in the array are of type nsICookie
35 * This array only contains non-private browsing cookies.
36 * To retrieve an array of private browsing cookies, use
37 * getCookiesWithOriginAttributes.
39 readonly attribute Array<nsICookie> cookies;
41 /**
42 * Returns an array of session cookies in the cookie list.
43 * The objects in the array are of type nsICookie
44 * This array only contains non-private browsing cookies.
46 readonly attribute Array<nsICookie> sessionCookies;
48 /**
49 * Returns current effective value of the cookieBehavior. It will return the
50 * different pref according to the aIsPrivate. If aIsPrivate is true, it will
51 * return the pref "network.cookie.cookieBehavior". Otherwise, it will return
52 * the pref "network.cookie.cookieBehavior.pbmode"
54 uint32_t getCookieBehavior(in boolean aIsPrivate);
55 %{C++
56 static uint32_t GetCookieBehavior(bool aIsPrivate);
59 /**
60 * Called to remove an individual cookie from the cookie list, specified
61 * by host, name, and path. If the cookie cannot be found, no exception
62 * is thrown. Typically, the arguments to this method will be obtained
63 * directly from the desired nsICookie object.
65 * @param aHost The host or domain for which the cookie was set. @see
66 * nsICookieManager::add for a description of acceptable host
67 * strings. If the target cookie is a domain cookie, a leading
68 * dot must be present.
69 * @param aName The name specified in the cookie
70 * @param aPath The path for which the cookie was set
71 * @param aOriginAttributes The originAttributes of this cookie.
74 [implicit_jscontext]
75 void remove(in AUTF8String aHost,
76 in ACString aName,
77 in AUTF8String aPath,
78 in jsval aOriginAttributes);
80 [notxpcom]
81 nsresult removeNative(in AUTF8String aHost,
82 in ACString aName,
83 in AUTF8String aPath,
84 in OriginAttributesPtr aOriginAttributes,
85 in nsIDPtr aOperationID);
87 /**
88 * Add a cookie. nsICookieService is the normal way to do this. This
89 * method is something of a backdoor.
91 * @param aHost
92 * the host or domain for which the cookie is set. presence of a
93 * leading dot indicates a domain cookie; otherwise, the cookie
94 * is treated as a non-domain cookie (see RFC2109). The host string
95 * will be normalized to ASCII or ACE; any trailing dot will be
96 * stripped. To be a domain cookie, the host must have at least two
97 * subdomain parts (e.g. '.foo.com', not '.com'), otherwise an
98 * exception will be thrown. An empty string is acceptable
99 * (e.g. file:// URI's).
100 * @param aPath
101 * path within the domain for which the cookie is valid
102 * @param aName
103 * cookie name
104 * @param aValue
105 * cookie data
106 * @param aIsSecure
107 * true if the cookie should only be sent over a secure connection.
108 * @param aIsHttpOnly
109 * true if the cookie should only be sent to, and can only be
110 * modified by, an http connection.
111 * @param aIsSession
112 * true if the cookie should exist for the current session only.
113 * see aExpiry.
114 * @param aExpiry
115 * expiration date, in seconds since midnight (00:00:00), January 1,
116 * 1970 UTC. note that expiry time will also be honored for session cookies;
117 * in this way, the more restrictive of the two will take effect.
118 * @param aOriginAttributes
119 * the originAttributes of this cookie.
120 * @param aSameSite
121 * the SameSite attribute.
122 * @param aSchemeMap
123 * the schemes this cookie has been set on. See nsICookie.idl.
124 * @param aIsPartitioned
125 * true if the cookie should be stored with the Partitioned attribute.
127 [implicit_jscontext]
128 void add(in AUTF8String aHost,
129 in AUTF8String aPath,
130 in ACString aName,
131 in AUTF8String aValue,
132 in boolean aIsSecure,
133 in boolean aIsHttpOnly,
134 in boolean aIsSession,
135 in int64_t aExpiry,
136 in jsval aOriginAttributes,
137 in int32_t aSameSite,
138 in nsICookie_schemeType aSchemeMap,
139 [optional] in boolean aIsPartitioned);
141 [notxpcom]
142 nsresult addNative(in AUTF8String aHost,
143 in AUTF8String aPath,
144 in ACString aName,
145 in AUTF8String aValue,
146 in boolean aIsSecure,
147 in boolean aIsHttpOnly,
148 in boolean aIsSession,
149 in int64_t aExpiry,
150 in OriginAttributesPtr aOriginAttributes,
151 in int32_t aSameSite,
152 in nsICookie_schemeType aSchemeMap,
153 in boolean aIsPartitioned,
154 in nsIDPtr aOperationID);
157 * Find whether a given cookie already exists.
159 * @param aHost
160 * the cookie's host to look for
161 * @param aPath
162 * the cookie's path to look for
163 * @param aName
164 * the cookie's name to look for
165 * @param aOriginAttributes
166 * the cookie's originAttributes to look for
168 * @return true if a cookie was found which matches the host, path, name and
169 * originAttributes fields of aCookie
171 [implicit_jscontext]
172 boolean cookieExists(in AUTF8String aHost,
173 in AUTF8String aPath,
174 in ACString aName,
175 in jsval aOriginAttributes);
177 [notxpcom]
178 nsresult cookieExistsNative(in AUTF8String aHost,
179 in AUTF8String aPath,
180 in ACString aName,
181 in OriginAttributesPtr aOriginAttributes,
182 out boolean aExists);
185 * Get a specific cookie by host, path, name and OriginAttributes.
187 * @param aHost
188 * the cookie's host to look for
189 * @param aPath
190 * the cookie's path to look for
191 * @param aName
192 * the cookie's name to look for
193 * @param aOriginAttributes
194 * the cookie's originAttributes to look for
196 * @return cookie matching the arguments or nullptr if not existing.
198 [notxpcom]
199 nsresult getCookieNative(in AUTF8String aHost,
200 in AUTF8String aPath,
201 in ACString aName,
202 in OriginAttributesPtr aOriginAttributes,
203 out nsICookie aCookie);
206 * Count how many cookies exist within the base domain of 'aHost'.
207 * Thus, for a host "weather.yahoo.com", the base domain would be "yahoo.com",
208 * and any host or domain cookies for "yahoo.com" and its subdomains would be
209 * counted.
211 * @param aHost
212 * the host string to search for, e.g. "google.com". this should consist
213 * of only the host portion of a URI. see @add for a description of
214 * acceptable host strings.
216 * @return the number of cookies found.
218 unsigned long countCookiesFromHost(in AUTF8String aHost);
221 * Returns an array of cookies that exist within the base domain of
222 * 'aHost'. Thus, for a host "weather.yahoo.com", the base domain would be
223 * "yahoo.com", and any host or domain cookies for "yahoo.com" and its
224 * subdomains would be returned.
226 * @param aHost
227 * the host string to search for, e.g. "google.com". this should consist
228 * of only the host portion of a URI. see @add for a description of
229 * acceptable host strings.
230 * @param aOriginAttributes The originAttributes of cookies that would be
231 * retrived.
232 * @param aSorted (optional) if true the cookies will be sorted by creation
233 * time and path length as described in RFC 6265
235 * @return an array of nsICookie objects.
237 * @see countCookiesFromHost
239 [implicit_jscontext]
240 Array<nsICookie> getCookiesFromHost(in AUTF8String aHost,
241 in jsval aOriginAttributes,
242 [optional] in boolean aSorted);
244 [notxpcom]
245 nsresult getCookiesFromHostNative(in AUTF8String aHost,
246 in OriginAttributesPtr aOriginAttributes,
247 in boolean aSorted,
248 out Array<nsICookie> aCookies);
251 * Returns an array of all cookies whose origin attributes matches aPattern
253 * @param aPattern origin attribute pattern in JSON format
255 * @param aHost
256 * the host string to search for, e.g. "google.com". this should consist
257 * of only the host portion of a URI. see @add for a description of
258 * acceptable host strings. This attribute is optional. It will search
259 * all hosts if this attribute is not given.
260 * @param aSorted (optional) if true the cookies will be sorted by creation
261 * time and path length as described in RFC 6265
263 Array<nsICookie> getCookiesWithOriginAttributes(in AString aPattern,
264 [optional] in AUTF8String aHost,
265 [optional] in boolean aSorted);
268 * Remove all the cookies whose origin attributes matches aPattern
270 * @param aPattern origin attribute pattern in JSON format
272 void removeCookiesWithOriginAttributes(in AString aPattern,
273 [optional] in AUTF8String aHost);
276 * Remove all the cookies whose origin attributes matches aPattern and the
277 * host is exactly aHost (without subdomain matching).
279 * @param aHost the host to match
280 * @param aPattern origin attribute pattern in JSON format
282 void removeCookiesFromExactHost(in AUTF8String aHost, in AString aPattern);
285 * Removes all cookies that were created on or after aSinceWhen, and returns
286 * a Promise which will be resolved when the last such cookie has been
287 * removed.
289 * @param aSinceWhen the starting point in time after which no cookies should
290 * be created when the Promise returned from this method is resolved.
292 [implicit_jscontext]
293 Promise removeAllSince(in int64_t aSinceWhen);
296 * Retrieves all the cookies that were created on or after aSinceWhen, order
297 * by creation time */
298 Array<nsICookie> getCookiesSince(in int64_t aSinceWhen);
302 * Adds a list of exceptions to the third party cookie blocking exception
303 * list.
305 void addThirdPartyCookieBlockingExceptions(
306 in Array<nsIThirdPartyCookieExceptionEntry> aExcpetions);
309 * Removes a list of exceptions from the third party cookie blocking
310 * exception list.
312 void removeThirdPartyCookieBlockingExceptions(
313 in Array<nsIThirdPartyCookieExceptionEntry> aExceptions);
315 // Test getter to inspect remote exception list state.
316 Array<ACString> testGet3PCBExceptions();