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"
12 class OriginAttributes
;
13 } // mozilla namespace
16 [ptr] native OriginAttributesPtr
(mozilla
::OriginAttributes
);
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
28 * Called to remove all cookies from the cookie list
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
;
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
;
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
);
56 static uint32_t GetCookieBehavior
(bool aIsPrivate
);
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.
75 void remove
(in AUTF8String aHost
,
78 in jsval aOriginAttributes
);
81 nsresult removeNative
(in AUTF8String aHost
,
84 in OriginAttributesPtr aOriginAttributes
,
85 in nsIDPtr aOperationID
);
88 * Add a cookie. nsICookieService is the normal way to do this. This
89 * method is something of a backdoor.
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).
101 * path within the domain for which the cookie is valid
107 * true if the cookie should only be sent over a secure connection.
109 * true if the cookie should only be sent to, and can only be
110 * modified by, an http connection.
112 * true if the cookie should exist for the current session only.
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.
121 * the SameSite attribute.
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.
128 void add
(in AUTF8String aHost
,
129 in AUTF8String aPath
,
131 in AUTF8String aValue
,
132 in boolean aIsSecure
,
133 in boolean aIsHttpOnly
,
134 in boolean aIsSession
,
136 in jsval aOriginAttributes
,
137 in int32_t aSameSite
,
138 in nsICookie_schemeType aSchemeMap
,
139 [optional] in boolean aIsPartitioned
);
142 nsresult addNative
(in AUTF8String aHost
,
143 in AUTF8String aPath
,
145 in AUTF8String aValue
,
146 in boolean aIsSecure
,
147 in boolean aIsHttpOnly
,
148 in boolean aIsSession
,
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.
160 * the cookie's host to look for
162 * the cookie's path to look for
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
172 boolean cookieExists
(in AUTF8String aHost
,
173 in AUTF8String aPath
,
175 in jsval aOriginAttributes
);
178 nsresult cookieExistsNative
(in AUTF8String aHost
,
179 in AUTF8String aPath
,
181 in OriginAttributesPtr aOriginAttributes
,
182 out boolean aExists
);
185 * Get a specific cookie by host, path, name and OriginAttributes.
188 * the cookie's host to look for
190 * the cookie's path to look for
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.
199 nsresult getCookieNative
(in AUTF8String aHost
,
200 in AUTF8String aPath
,
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
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.
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
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
240 Array
<nsICookie
> getCookiesFromHost
(in AUTF8String aHost
,
241 in jsval aOriginAttributes
,
242 [optional] in boolean aSorted
);
245 nsresult getCookiesFromHostNative
(in AUTF8String aHost
,
246 in OriginAttributesPtr aOriginAttributes
,
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
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
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.
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
305 void addThirdPartyCookieBlockingExceptions
(
306 in Array
<nsIThirdPartyCookieExceptionEntry
> aExcpetions
);
309 * Removes a list of exceptions from the third party cookie blocking
312 void removeThirdPartyCookieBlockingExceptions
(
313 in Array
<nsIThirdPartyCookieExceptionEntry
> aExceptions
);
315 // Test getter to inspect remote exception list state.
316 Array
<ACString
> testGet3PCBExceptions
();