Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / netwerk / cookie / nsICookieService.idl
blobc69453f6faa8cdb1f5f4dd4649373a97c172353c
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 nsIChannel;
10 webidl Document;
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 COOKIES_BATCH_DELETED notification will likely be
37 * immediately followed by COOKIE_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: The cookie notification. See nsICookieNotification for details.
44 * data : none. For possible actions see nsICookieNotification_Action.
46 * topic : "cookie-rejected"
47 * broadcast whenever a cookie was rejected from being set as a
48 * result of user prefs.
49 * subject: an nsIURI interface pointer representing the URI that attempted
50 * to set the cookie.
51 * data : none.
53 [scriptable, uuid(1e94e283-2811-4f43-b947-d22b1549d824)]
54 interface nsICookieService : nsISupports
57 * Possible values for the "network.cookie.cookieBehavior" preference.
59 const uint32_t BEHAVIOR_ACCEPT = 0; // allow all cookies
60 const uint32_t BEHAVIOR_REJECT_FOREIGN = 1; // reject all third-party cookies
61 const uint32_t BEHAVIOR_REJECT = 2; // reject all cookies
62 const uint32_t BEHAVIOR_LIMIT_FOREIGN = 3; // reject third-party cookies unless the
63 // eTLD already has at least one cookie
64 const uint32_t BEHAVIOR_REJECT_TRACKER = 4; // reject trackers
65 const uint32_t BEHAVIOR_REJECT_TRACKER_AND_PARTITION_FOREIGN = 5; // reject trackers, partition third-party cookies
66 // When adding a new cookie behavior, please increase this value!
67 const uint32_t BEHAVIOR_LAST = 5;
70 * Get the complete cookie string associated with the document's principal.
71 * This method is meant to be used for `document.cookie` only. Any security
72 * check about storage-access permission and cookie behavior must be done by
73 * the caller.
75 * @param aDocument
76 * The document.
78 * @return the resulting cookie string
80 ACString getCookieStringFromDocument(in Document aDocument);
83 * Get the complete cookie string associated with the URI.
85 * This function is NOT redundant with getCookieString, as the result
86 * will be different based on httponly (see bug 178993)
88 * @param aURI
89 * The URI of the document for which cookies are being queried.
90 * file:// URIs (i.e. with an empty host) are allowed, but any other
91 * scheme must have a non-empty host. A trailing dot in the host
92 * is acceptable, and will be stripped. This argument must not be null.
93 * @param aChannel
94 * the channel used to load the document.
96 * @return the resulting cookie string
98 ACString getCookieStringFromHttp(in nsIURI aURI, in nsIChannel aChannel);
101 * Set the cookie string associated with a Document. This method is meant to
102 * be used for `document.cookie` only. Any security check about
103 * storage-access permission and cookie behavior must be done by the caller.
105 * @param aDocument
106 * The document.
107 * @param aCookie
108 * the cookie string to set.
110 void setCookieStringFromDocument(in Document aDocument, in ACString aCookie);
113 * Set the cookie string and expires associated with the URI.
115 * This function is NOT redundant with setCookieString, as the result
116 * will be different based on httponly (see bug 178993)
118 * @param aURI
119 * The URI of the document for which cookies are being queried.
120 * file:// URIs (i.e. with an empty host) are allowed, but any other
121 * scheme must have a non-empty host. A trailing dot in the host
122 * is acceptable, and will be stripped. This argument must not be null.
123 * @param aCookie
124 * the cookie string to set.
125 * @param aChannel
126 * the channel used to load the document.
128 void setCookieStringFromHttp(in nsIURI aURI, in ACString aCookie,
129 in nsIChannel aChannel);
132 * Batch SQLite operations into one transaction. By default each call to
133 * CookieService that affects the underlying SQLite database (add, remove,
134 * setCookieString etc.) runs in a separate transaction. If you do this many
135 * times in a row, it's faster and suggested to wrap them all in a single
136 * transaction by setting all the operations into the callback parameter.
137 * Example: test scripts that need to construct a large cookie database.
138 * @param aCallback
139 * nsICookieTransactionCallback interface to call
140 * @throws NS_ERROR_FAILURE if aCallback() fails.
141 * @throws NS_ERROR_NOT_AVAILABLE if the connection is not established.
143 void runInTransaction(in nsICookieTransactionCallback aCallback);