michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsICookieManager.idl" michael@0: michael@0: interface nsICookie2; michael@0: interface nsIFile; michael@0: michael@0: /** michael@0: * Additions to the frozen nsICookieManager michael@0: */ michael@0: michael@0: [scriptable, uuid(daf0caa7-b431-4b4d-ba51-08c179bb9dfe)] michael@0: interface nsICookieManager2 : nsICookieManager michael@0: { michael@0: /** michael@0: * Add a cookie. nsICookieService is the normal way to do this. This michael@0: * method is something of a backdoor. michael@0: * michael@0: * @param aHost michael@0: * the host or domain for which the cookie is set. presence of a michael@0: * leading dot indicates a domain cookie; otherwise, the cookie michael@0: * is treated as a non-domain cookie (see RFC2109). The host string michael@0: * will be normalized to ASCII or ACE; any trailing dot will be michael@0: * stripped. To be a domain cookie, the host must have at least two michael@0: * subdomain parts (e.g. '.foo.com', not '.com'), otherwise an michael@0: * exception will be thrown. An empty string is acceptable michael@0: * (e.g. file:// URI's). michael@0: * @param aPath michael@0: * path within the domain for which the cookie is valid michael@0: * @param aName michael@0: * cookie name michael@0: * @param aValue michael@0: * cookie data michael@0: * @param aIsSecure michael@0: * true if the cookie should only be sent over a secure connection. michael@0: * @param aIsHttpOnly michael@0: * true if the cookie should only be sent to, and can only be michael@0: * modified by, an http connection. michael@0: * @param aIsSession michael@0: * true if the cookie should exist for the current session only. michael@0: * see aExpiry. michael@0: * @param aExpiry michael@0: * expiration date, in seconds since midnight (00:00:00), January 1, michael@0: * 1970 UTC. note that expiry time will also be honored for session cookies; michael@0: * in this way, the more restrictive of the two will take effect. michael@0: */ michael@0: void add(in AUTF8String aHost, michael@0: in AUTF8String aPath, michael@0: in ACString aName, michael@0: in ACString aValue, michael@0: in boolean aIsSecure, michael@0: in boolean aIsHttpOnly, michael@0: in boolean aIsSession, michael@0: in int64_t aExpiry); michael@0: michael@0: /** michael@0: * Find whether a given cookie already exists. michael@0: * michael@0: * @param aCookie michael@0: * the cookie to look for michael@0: * michael@0: * @return true if a cookie was found which matches the host, path, and name michael@0: * fields of aCookie michael@0: */ michael@0: boolean cookieExists(in nsICookie2 aCookie); michael@0: michael@0: /** michael@0: * Count how many cookies exist within the base domain of 'aHost'. michael@0: * Thus, for a host "weather.yahoo.com", the base domain would be "yahoo.com", michael@0: * and any host or domain cookies for "yahoo.com" and its subdomains would be michael@0: * counted. michael@0: * michael@0: * @param aHost michael@0: * the host string to search for, e.g. "google.com". this should consist michael@0: * of only the host portion of a URI. see @add for a description of michael@0: * acceptable host strings. michael@0: * michael@0: * @return the number of cookies found. michael@0: */ michael@0: unsigned long countCookiesFromHost(in AUTF8String aHost); michael@0: michael@0: /** michael@0: * Returns an enumerator of cookies that exist within the base domain of michael@0: * 'aHost'. Thus, for a host "weather.yahoo.com", the base domain would be michael@0: * "yahoo.com", and any host or domain cookies for "yahoo.com" and its michael@0: * subdomains would be returned. michael@0: * michael@0: * @param aHost michael@0: * the host string to search for, e.g. "google.com". this should consist michael@0: * of only the host portion of a URI. see @add for a description of michael@0: * acceptable host strings. michael@0: * michael@0: * @return an nsISimpleEnumerator of nsICookie2 objects. michael@0: * michael@0: * @see countCookiesFromHost michael@0: */ michael@0: nsISimpleEnumerator getCookiesFromHost(in AUTF8String aHost); michael@0: michael@0: /** michael@0: * Import an old-style cookie file. Imported cookies will be added to the michael@0: * existing database. If the database contains any cookies the same as those michael@0: * being imported (i.e. domain, name, and path match), they will be replaced. michael@0: * michael@0: * @param aCookieFile the file to import, usually cookies.txt michael@0: */ michael@0: void importCookies(in nsIFile aCookieFile); michael@0: michael@0: /** michael@0: * Returns an enumerator of all cookies that are related to a specific app. michael@0: * michael@0: * If the onlyBrowserELement parameter is set to true, only cookies part of michael@0: * a browser element inside the app will be returned. If set to false, all michael@0: * cookies will be returned, regardless of their browserElement flag. michael@0: * michael@0: * This method assumes that appId is a valid app id. It should not be a michael@0: * special value like UNKNOWN_APP_ID or NO_APP_ID. michael@0: */ michael@0: nsISimpleEnumerator getCookiesForApp(in unsigned long appId, in boolean onlyBrowserElement); michael@0: michael@0: /** michael@0: * Remove all the cookies associated with the app with the id aAppId. michael@0: * michael@0: * If onlyBrowserElement is set to true, the method will only remove the michael@0: * cookies marked as part of a browser element inside the app. michael@0: * michael@0: * Special app id values are not allowed (NO_APP_ID or UNKNOWN_APP_ID for example). michael@0: */ michael@0: void removeCookiesForApp(in unsigned long appId, in boolean onlyBrowserElement); michael@0: };