2002-01-31 03:29:19 +03:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
2004-04-19 02:01:16 +04:00
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
2002-01-31 03:29:19 +03:00
*
2004-04-19 02:01:16 +04:00
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
2002-01-31 03:29:19 +03:00
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
2004-04-19 02:01:16 +04:00
* The Initial Developer of the Original Code is
2002-01-31 03:29:19 +03:00
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
2004-04-19 02:01:16 +04:00
* use your version of this file under the terms of the MPL, indicate your
2002-01-31 03:29:19 +03:00
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
2004-04-19 02:01:16 +04:00
* the terms of any one of the MPL, the GPL or the LGPL.
2002-01-31 03:29:19 +03:00
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
2003-05-06 01:27:02 +04:00
interface nsIURI;
interface nsIPrompt;
interface nsIChannel;
2002-01-31 03:29:19 +03:00
2003-05-06 01:27:02 +04:00
/**
* nsICookieService
*
* Provides methods for setting and getting cookies in the context of a
* page load. See nsICookieManager for methods to manipulate the cookie
* database directly. This separation of interface is mainly historical.
2003-10-22 10:53:19 +04:00
*
2010-11-12 20:32:35 +03:00
* This service broadcasts the notifications detailed below when the cookie
* list is changed, or a cookie is rejected.
*
* NOTE: observers of these notifications *must* not attempt to change profile
* or switch into or out of private browsing mode from within the
* observer. Doing so will cause undefined behavior. Mutating the cookie
* list (e.g. by calling methods on nsICookieService and friends) is
* allowed, but beware that there may be pending notifications you haven't
* seen yet -- for instance, a "batch-deleted" notification will likely be
* immediately followed by "added". You may check the state of the cookie
* list to determine if this is the case.
2003-10-22 10:53:19 +04:00
*
* topic : "cookie-changed"
2009-12-16 01:21:28 +03:00
* broadcast whenever the cookie list changes in some way. see
* explanation of data strings below.
* subject: see below.
2003-10-22 10:53:19 +04:00
* data : "deleted"
2009-12-16 01:21:28 +03:00
* a cookie was deleted. the subject is an nsICookie2 representing
* the deleted cookie.
2003-10-22 10:53:19 +04:00
* "added"
2009-12-16 01:21:28 +03:00
* a cookie was added. the subject is an nsICookie2 representing
* the added cookie.
2003-10-22 10:53:19 +04:00
* "changed"
2009-12-16 01:21:28 +03:00
* a cookie was changed. the subject is an nsICookie2 representing
* the new cookie. (note that host, path, and name are invariant
* for a given cookie; other parameters may change.)
* "batch-deleted"
2010-11-02 10:06:54 +03:00
* a set of cookies was purged (typically, because they have either
* expired or because the cookie list has grown too large). The subject
* is an nsIArray of nsICookie2's representing the deleted cookies.
* Note that the array could contain a single cookie.
2003-10-22 10:53:19 +04:00
* "cleared"
* the entire cookie list was cleared. the subject is null.
2008-10-20 01:12:53 +04:00
* "reload"
* the entire cookie list should be reloaded. the subject is null.
2003-10-22 10:53:19 +04:00
*
* topic : "cookie-rejected"
* broadcast whenever a cookie was rejected from being set as a
* result of user prefs.
* subject: an nsIURI interface pointer representing the URI that attempted
* to set the cookie.
* data : none.
2003-05-06 01:27:02 +04:00
*/
2007-06-21 09:17:08 +04:00
[scriptable, uuid(2aaa897a-293c-4d2b-a657-8c9b7136996d)]
2002-01-31 03:29:19 +03:00
interface nsICookieService : nsISupports
{
/*
2003-05-06 01:27:02 +04:00
* Get the complete cookie string associated with the URI.
2002-01-31 03:29:19 +03:00
*
2003-05-06 01:27:02 +04:00
* @param aURI
2010-09-17 00:21:12 +04:00
* The URI of the document for which cookies are being queried.
* file:// URIs (i.e. with an empty host) are allowed, but any other
2010-01-12 21:29:20 +03:00
* scheme must have a non-empty host. A trailing dot in the host
2010-09-17 00:21:12 +04:00
* is acceptable, and will be stripped. This argument must not be null.
2003-05-06 01:27:02 +04:00
* @param aChannel
2009-12-15 03:24:44 +03:00
* the channel used to load the document. this parameter should not
* be null, otherwise the cookies will not be returned if third-party
* cookies have been disabled by the user. (the channel is used
* to determine the originating URI of the document; if it is not
* provided, the cookies will be assumed third-party.)
2003-05-06 01:27:02 +04:00
*
* @return the resulting cookie string
2002-01-31 03:29:19 +03:00
*/
2003-05-06 01:27:02 +04:00
string getCookieString(in nsIURI aURI, in nsIChannel aChannel);
2002-01-31 03:29:19 +03:00
/*
2003-05-06 01:27:02 +04:00
* Get the complete cookie string associated with the URI.
*
2007-03-14 20:22:01 +03:00
* This function is NOT redundant with getCookieString, as the result
* will be different based on httponly (see bug 178993)
2002-01-31 03:29:19 +03:00
*
2003-05-06 01:27:02 +04:00
* @param aURI
2010-09-17 00:21:12 +04:00
* The URI of the document for which cookies are being queried.
* file:// URIs (i.e. with an empty host) are allowed, but any other
2010-01-12 21:29:20 +03:00
* scheme must have a non-empty host. A trailing dot in the host
2010-09-17 00:21:12 +04:00
* is acceptable, and will be stripped. This argument must not be null.
2003-05-06 01:27:02 +04:00
* @param aFirstURI
* the URI that the user originally typed in or clicked on to initiate
* the load of the document referenced by aURI.
* @param aChannel
2009-12-15 03:24:44 +03:00
* the channel used to load the document. this parameter should not
* be null, otherwise the cookies will not be returned if third-party
* cookies have been disabled by the user. (the channel is used
* to determine the originating URI of the document; if it is not
* provided, the cookies will be assumed third-party.)
2003-05-06 01:27:02 +04:00
*
* @return the resulting cookie string
2002-01-31 03:29:19 +03:00
*/
2003-05-06 01:27:02 +04:00
string getCookieStringFromHttp(in nsIURI aURI, in nsIURI aFirstURI, in nsIChannel aChannel);
2002-01-31 03:29:19 +03:00
/*
2003-05-06 01:27:02 +04:00
* Set the cookie string associated with the URI.
*
* @param aURI
2010-09-17 00:21:12 +04:00
* The URI of the document for which cookies are being queried.
* file:// URIs (i.e. with an empty host) are allowed, but any other
2010-01-12 21:29:20 +03:00
* scheme must have a non-empty host. A trailing dot in the host
2010-09-17 00:21:12 +04:00
* is acceptable, and will be stripped. This argument must not be null.
2003-05-06 01:27:02 +04:00
* @param aPrompt
2010-09-17 00:21:12 +04:00
* the prompt to use for all user-level cookie notifications. This is
* presently ignored and can be null. (Prompt information is determined
* from the channel if necessary.)
2003-05-06 01:27:02 +04:00
* @param aCookie
* the cookie string to set.
* @param aChannel
2009-12-15 03:24:44 +03:00
* the channel used to load the document. this parameter should not
* be null, otherwise the cookies will not be set if third-party
* cookies have been disabled by the user. (the channel is used
* to determine the originating URI of the document; if it is not
* provided, the cookies will be assumed third-party.)
2002-01-31 03:29:19 +03:00
*/
2003-05-06 01:27:02 +04:00
void setCookieString(in nsIURI aURI, in nsIPrompt aPrompt, in string aCookie, in nsIChannel aChannel);
2002-01-31 03:29:19 +03:00
/*
2003-05-06 01:27:02 +04:00
* Set the cookie string and expires associated with the URI.
2002-01-31 03:29:19 +03:00
*
2007-03-14 20:22:01 +03:00
* This function is NOT redundant with setCookieString, as the result
* will be different based on httponly (see bug 178993)
2003-05-06 01:27:02 +04:00
*
* @param aURI
2010-09-17 00:21:12 +04:00
* The URI of the document for which cookies are being queried.
* file:// URIs (i.e. with an empty host) are allowed, but any other
2010-01-12 21:29:20 +03:00
* scheme must have a non-empty host. A trailing dot in the host
2010-09-17 00:21:12 +04:00
* is acceptable, and will be stripped. This argument must not be null.
2003-05-06 01:27:02 +04:00
* @param aFirstURI
* the URI that the user originally typed in or clicked on to initiate
* the load of the document referenced by aURI.
* @param aPrompt
2010-09-17 00:21:12 +04:00
* the prompt to use for all user-level cookie notifications. This is
* presently ignored and can be null. (Prompt information is determined
* from the channel if necessary.)
2003-05-06 01:27:02 +04:00
* @param aCookie
* the cookie string to set.
* @param aServerTime
2010-09-17 00:21:12 +04:00
* the current time reported by the server, if available. This should
* be the string from the Date header in an HTTP response. If the
* string is empty or null, server time is assumed to be the current
* local time. If provided, it will be used to calculate the expiry
* time of the cookie relative to the server's local time.
2003-05-06 01:27:02 +04:00
* @param aChannel
2009-12-15 03:24:44 +03:00
* the channel used to load the document. this parameter should not
* be null, otherwise the cookies will not be set if third-party
* cookies have been disabled by the user. (the channel is used
* to determine the originating URI of the document; if it is not
* provided, the cookies will be assumed third-party.)
2002-01-31 03:29:19 +03:00
*/
2003-05-06 01:27:02 +04:00
void setCookieStringFromHttp(in nsIURI aURI, in nsIURI aFirstURI, in nsIPrompt aPrompt, in string aCookie, in string aServerTime, in nsIChannel aChannel);
2002-01-31 03:29:19 +03:00
};