Bug 1494162 - Part 45: Lazy load Menu and MenuItem in TabBar. r=pbro
[gecko.git] / netwerk / cookie / nsICookieService.idl
blobf14683ef17faacf176d42179b5a24f6e63b40a40
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"
8 interface nsIURI;
9 interface nsIPrompt;
10 interface nsIChannel;
12 /**
13 * @see nsICookieService::runInTransaction
15 [scriptable, function, uuid(0fc41ffb-f1b7-42d9-9a42-8dc420c158c1)]
16 interface nsICookieTransactionCallback : nsISupports
18 void callback();
21 /**
22 * nsICookieService
24 * Provides methods for setting and getting cookies in the context of a
25 * page load. See nsICookieManager for methods to manipulate the cookie
26 * database directly. This separation of interface is mainly historical.
28 * This service broadcasts the notifications detailed below when the cookie
29 * list is changed, or a cookie is rejected.
31 * NOTE: observers of these notifications *must* not attempt to change profile
32 * or switch into or out of private browsing mode from within the
33 * observer. Doing so will cause undefined behavior. Mutating the cookie
34 * list (e.g. by calling methods on nsICookieService and friends) is
35 * allowed, but beware that there may be pending notifications you haven't
36 * seen yet -- for instance, a "batch-deleted" notification will likely be
37 * immediately followed by "added". You may check the state of the cookie
38 * list to determine if this is the case.
40 * topic : "cookie-changed"
41 * broadcast whenever the cookie list changes in some way. see
42 * explanation of data strings below.
43 * subject: see below.
44 * data : "deleted"
45 * a cookie was deleted. the subject is an nsICookie2 representing
46 * the deleted cookie.
47 * "added"
48 * a cookie was added. the subject is an nsICookie2 representing
49 * the added cookie.
50 * "changed"
51 * a cookie was changed. the subject is an nsICookie2 representing
52 * the new cookie. (note that host, path, and name are invariant
53 * for a given cookie; other parameters may change.)
54 * "batch-deleted"
55 * a set of cookies was purged (typically, because they have either
56 * expired or because the cookie list has grown too large). The subject
57 * is an nsIArray of nsICookie2's representing the deleted cookies.
58 * Note that the array could contain a single cookie.
59 * "cleared"
60 * the entire cookie list was cleared. the subject is null.
62 * topic : "cookie-rejected"
63 * broadcast whenever a cookie was rejected from being set as a
64 * result of user prefs.
65 * subject: an nsIURI interface pointer representing the URI that attempted
66 * to set the cookie.
67 * data : none.
69 * topic : "third-party-cookie-accepted"
70 * broadcast whenever a third party cookie was accepted
71 * subject: an nsIURI interface pointer representing the URI that attempted
72 * to set the cookie.
73 * data : the referrer, or "?" if unknown
75 * topic : "third-party-cookie-rejected"
76 * broadcast whenever a third party cookie was rejected
77 * subject: an nsIURI interface pointer representing the URI that attempted
78 * to set the cookie.
79 * data : the referrer, or "?" if unknown
81 [scriptable, uuid(1e94e283-2811-4f43-b947-d22b1549d824)]
82 interface nsICookieService : nsISupports
85 * Possible values for the "network.cookie.cookieBehavior" preference.
87 const uint32_t BEHAVIOR_ACCEPT = 0; // allow all cookies
88 const uint32_t BEHAVIOR_REJECT_FOREIGN = 1; // reject all third-party cookies
89 const uint32_t BEHAVIOR_REJECT = 2; // reject all cookies
90 const uint32_t BEHAVIOR_LIMIT_FOREIGN = 3; // reject third-party cookies unless the
91 // eTLD already has at least one cookie
92 const uint32_t BEHAVIOR_REJECT_TRACKER = 4; // reject trackers
93 // When adding a new cookie behavior, please increase this value!
94 const uint32_t BEHAVIOR_LAST = 4;
97 * Possible values for the "network.cookie.lifetimePolicy" preference.
99 const uint32_t ACCEPT_NORMALLY = 0; // accept normally
100 // Value = 1 is considered the same as 0 (See Bug 606655).
101 const uint32_t ACCEPT_SESSION = 2; // downgrade to session
102 // Value = 3 is considered the same as 0
105 * Get the complete cookie string associated with the URI.
107 * @param aURI
108 * The URI of the document for which cookies are being queried.
109 * file:// URIs (i.e. with an empty host) are allowed, but any other
110 * scheme must have a non-empty host. A trailing dot in the host
111 * is acceptable, and will be stripped. This argument must not be null.
112 * @param aChannel
113 * the channel used to load the document. this parameter should not
114 * be null, otherwise the cookies will not be returned if third-party
115 * cookies have been disabled by the user. (the channel is used
116 * to determine the originating URI of the document; if it is not
117 * provided, the cookies will be assumed third-party.)
119 * @return the resulting cookie string
121 string getCookieString(in nsIURI aURI, in nsIChannel aChannel);
124 * Get the complete cookie string associated with the URI.
126 * This function is NOT redundant with getCookieString, as the result
127 * will be different based on httponly (see bug 178993)
129 * @param aURI
130 * The URI of the document for which cookies are being queried.
131 * file:// URIs (i.e. with an empty host) are allowed, but any other
132 * scheme must have a non-empty host. A trailing dot in the host
133 * is acceptable, and will be stripped. This argument must not be null.
134 * @param aFirstURI
135 * the URI that the user originally typed in or clicked on to initiate
136 * the load of the document referenced by aURI.
137 * @param aChannel
138 * the channel used to load the document. this parameter should not
139 * be null, otherwise the cookies will not be returned if third-party
140 * cookies have been disabled by the user. (the channel is used
141 * to determine the originating URI of the document; if it is not
142 * provided, the cookies will be assumed third-party.)
144 * @return the resulting cookie string
146 string getCookieStringFromHttp(in nsIURI aURI, in nsIURI aFirstURI, in nsIChannel aChannel);
149 * Set the cookie string associated with the URI.
151 * @param aURI
152 * The URI of the document for which cookies are being queried.
153 * file:// URIs (i.e. with an empty host) are allowed, but any other
154 * scheme must have a non-empty host. A trailing dot in the host
155 * is acceptable, and will be stripped. This argument must not be null.
156 * @param aPrompt
157 * the prompt to use for all user-level cookie notifications. This is
158 * presently ignored and can be null. (Prompt information is determined
159 * from the channel if necessary.)
160 * @param aCookie
161 * the cookie string to set.
162 * @param aChannel
163 * the channel used to load the document. this parameter should not
164 * be null, otherwise the cookies will not be set if third-party
165 * cookies have been disabled by the user. (the channel is used
166 * to determine the originating URI of the document; if it is not
167 * provided, the cookies will be assumed third-party.)
169 void setCookieString(in nsIURI aURI, in nsIPrompt aPrompt, in string aCookie, in nsIChannel aChannel);
172 * Set the cookie string and expires associated with the URI.
174 * This function is NOT redundant with setCookieString, as the result
175 * will be different based on httponly (see bug 178993)
177 * @param aURI
178 * The URI of the document for which cookies are being queried.
179 * file:// URIs (i.e. with an empty host) are allowed, but any other
180 * scheme must have a non-empty host. A trailing dot in the host
181 * is acceptable, and will be stripped. This argument must not be null.
182 * @param aFirstURI
183 * the URI that the user originally typed in or clicked on to initiate
184 * the load of the document referenced by aURI.
185 * @param aPrompt
186 * the prompt to use for all user-level cookie notifications. This is
187 * presently ignored and can be null. (Prompt information is determined
188 * from the channel if necessary.)
189 * @param aCookie
190 * the cookie string to set.
191 * @param aServerTime
192 * the current time reported by the server, if available. This should
193 * be the string from the Date header in an HTTP response. If the
194 * string is empty or null, server time is assumed to be the current
195 * local time. If provided, it will be used to calculate the expiry
196 * time of the cookie relative to the server's local time.
197 * @param aChannel
198 * the channel used to load the document. this parameter should not
199 * be null, otherwise the cookies will not be set if third-party
200 * cookies have been disabled by the user. (the channel is used
201 * to determine the originating URI of the document; if it is not
202 * provided, the cookies will be assumed third-party.)
204 void setCookieStringFromHttp(in nsIURI aURI, in nsIURI aFirstURI, in nsIPrompt aPrompt, in string aCookie, in string aServerTime, in nsIChannel aChannel);
208 * Batch SQLite operations into one transaction. By default each call to
209 * CookieService that affects the underlying SQLite database (add, remove,
210 * setCookieString etc.) runs in a separate transaction. If you do this many
211 * times in a row, it's faster and suggested to wrap them all in a single
212 * transaction by setting all the operations into the callback parameter.
213 * Example: test scripts that need to construct a large cookie database.
214 * @param aCallback
215 * nsICookieTransactionCallback interface to call
216 * @throws NS_ERROR_FAILURE if aCallback() fails.
217 * @throws NS_ERROR_NOT_AVAILABLE if the connection is not established.
219 void runInTransaction(in nsICookieTransactionCallback aCallback);