bug 130304, freeze interface for nsICookie and nsICookieManager, r/sr=darin,alecf, a=asa

This commit is contained in:
morse%netscape.com 2002-03-15 03:49:00 +00:00
Родитель 7422a60dda
Коммит 894670491d
12 изменённых файлов: 251 добавлений и 93 удалений

Просмотреть файл

@ -1,3 +0,0 @@
#
# This is a list of local files which get copied to the mozilla:dist directory
#

Просмотреть файл

@ -0,0 +1,49 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ----- BEGIN LICENSE BLOCK -----
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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 is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape Communications Corporation.
* Portions created by Netscape Communications Corporation are
* Copyright (C) 1998 Netscape Communications Corporation.
* All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the LGPL or the GPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ----- END LICENSE BLOCK ----- */
/*
* This is a "service" and not just an ordinary component. A consumer must talk
* to the service manager, not the component manager.
*/
#ifndef NSCCOOKIE_H
#define NSCCOOKIE_H
#include "nsICookie.h"
#define NS_COOKIE_CONTRACTID "@mozilla.org/cookie;1"
#endif

Просмотреть файл

@ -0,0 +1,49 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ----- BEGIN LICENSE BLOCK -----
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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 is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape Communications Corporation.
* Portions created by Netscape Communications Corporation are
* Copyright (C) 1998 Netscape Communications Corporation.
* All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the LGPL or the GPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ----- END LICENSE BLOCK ----- */
/*
* This is a "service" and not just an ordinary component. A consumer must talk
* to the service manager, not the component manager.
*/
#ifndef NSCCOOKIEMANAGER_H
#define NSCCOOKIEMANAGER_H
#include "nsICookieManager.h"
#define NS_COOKIEMANAGER_CONTRACTID "@mozilla.org/cookiemanager;1"
#endif

Просмотреть файл

@ -56,8 +56,8 @@ nsCookie::nsCookie
char * path,
PRBool isSecure,
PRUint64 expires,
nsCookieStatus_t status,
nsCookiePolicy_t policy) {
nsCookieStatus status,
nsCookiePolicy policy) {
cookieName = name;
cookieValue = value;
cookieIsDomain = isDomain;
@ -77,17 +77,17 @@ nsCookie::~nsCookie(void) {
nsCRT::free(cookiePath);
}
NS_IMETHODIMP nsCookie::GetName(char * *aName) {
NS_IMETHODIMP nsCookie::GetName(nsACString& aName) {
if (cookieName) {
*aName = (char *) nsMemory::Clone(cookieName, strlen(cookieName) + 1);
aName = cookieName;
return NS_OK;
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsCookie::GetValue(char * *aValue) {
NS_IMETHODIMP nsCookie::GetValue(nsACString& aValue) {
if (cookieValue) {
*aValue = (char *) nsMemory::Clone(cookieValue, strlen(cookieValue) + 1);
aValue = cookieValue;
return NS_OK;
}
return NS_ERROR_NULL_POINTER;
@ -98,17 +98,21 @@ NS_IMETHODIMP nsCookie::GetIsDomain(PRBool *aIsDomain) {
return NS_OK;
}
NS_IMETHODIMP nsCookie::GetHost(char * *aHost) {
NS_IMETHODIMP nsCookie::GetHost(nsACString& aHost) {
//NS_IMETHODIMP nsCookie::GetHost(nsAUTF8String& aHost) {
// using nsACString above instead of nsAUTF8String because the latter doesn't exist yet
if (cookieHost) {
*aHost = (char *) nsMemory::Clone(cookieHost, strlen(cookieHost) + 1);
aHost = cookieHost;
return NS_OK;
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsCookie::GetPath(char * *aPath) {
NS_IMETHODIMP nsCookie::GetPath(nsACString& aPath) {
//NS_IMETHODIMP nsCookie::GetPath(nsAUTF8String& aPath) {
// using nsACString above instead of nsAUTF8String because the latter doesn't exist yet
if (cookiePath) {
*aPath = (char *) nsMemory::Clone(cookiePath, strlen(cookiePath) + 1);
aPath = cookiePath;
return NS_OK;
}
return NS_ERROR_NULL_POINTER;
@ -124,12 +128,12 @@ NS_IMETHODIMP nsCookie::GetExpires(PRUint64 *aExpires) {
return NS_OK;
}
NS_IMETHODIMP nsCookie::GetStatus(nsCookieStatus_t *aStatus) {
NS_IMETHODIMP nsCookie::GetStatus(nsCookieStatus *aStatus) {
*aStatus = cookieStatus;
return NS_OK;
}
NS_IMETHODIMP nsCookie::GetPolicy(nsCookiePolicy_t *aPolicy) {
NS_IMETHODIMP nsCookie::GetPolicy(nsCookiePolicy *aPolicy) {
*aPolicy = cookiePolicy;
return NS_OK;
}

Просмотреть файл

@ -63,8 +63,8 @@ public:
char * path,
PRBool isSecure,
PRUint64 expires,
nsCookieStatus_t status,
nsCookiePolicy_t policy
nsCookieStatus status,
nsCookiePolicy policy
);
nsCookie();
virtual ~nsCookie(void);
@ -77,8 +77,11 @@ protected:
char * cookiePath;
PRBool cookieIsSecure;
PRUint64 cookieExpires;
nsCookieStatus_t cookieStatus;
nsCookiePolicy_t cookiePolicy;
nsCookieStatus cookieStatus;
nsCookiePolicy cookiePolicy;
};
// {E9FCB9A4-D376-458f-B720-E65E7DF593BC}
#define NS_COOKIE_CID { 0xe9fcb9a4,0xd376,0x458f,{0xb7,0x20,0xe6,0x5e,0x7d,0xf5,0x93,0xbc}}
#endif /* nsCookie_h__ */

Просмотреть файл

@ -73,8 +73,8 @@ class nsCookieEnumerator : public nsISimpleEnumerator
char * path;
PRBool isSecure;
PRUint64 expires;
nsCookieStatus_t status;
nsCookiePolicy_t policy;
nsCookieStatus status;
nsCookiePolicy policy;
nsresult rv = COOKIE_Enumerate
(mCookieCount++, &name, &value, &isDomain, &host, &path, &isSecure, &expires,
&status, &policy);
@ -139,7 +139,12 @@ NS_IMETHODIMP nsCookieManager::GetEnumerator(nsISimpleEnumerator * *entries)
}
NS_IMETHODIMP nsCookieManager::Remove
(const char* host, const char* name, const char* path, const PRBool permanent) {
::COOKIE_Remove(host, name, path, permanent);
(const nsACString& host, const nsACString& name, const nsACString& path, PRBool blocked) {
// (const nsAUTF8String& host, const nsACString& name, const nsAUTF8String& path, PRBool blocked) {
// using nsACString above instead of nsAUTF8String because the latter doesn't exist yet
::COOKIE_Remove(PromiseFlatCString(host).get(),
PromiseFlatCString(name).get(),
PromiseFlatCString(path).get(), blocked);
return NS_OK;
}

Просмотреть файл

@ -58,4 +58,7 @@ public:
};
// {AAAB6710-0F2C-11d5-A53B-0010A401EB10}
#define NS_COOKIEMANAGER_CID {0xaaab6710,0xf2c,0x11d5,{0xa5,0x3b,0x0,0x10,0xa4,0x1,0xeb,0x10}}
#endif /* nsCookieManager_h__ */

Просмотреть файл

@ -92,8 +92,8 @@ typedef struct _cookie_CookieStruct {
time_t lastAccessed;
PRBool isSecure;
PRBool isDomain; /* is it a domain instead of an absolute host? */
nsCookieStatus_t status;
nsCookiePolicy_t policy;
nsCookieStatus status;
nsCookiePolicy policy;
} cookie_CookieStruct;
typedef enum {
@ -826,7 +826,7 @@ cookie_isForeign (char * curURL, char * firstURL, nsIIOService* ioService) {
return retval;
}
nsCookieStatus_t
nsCookieStatus
cookie_GetStatus(char decision) {
switch (decision) {
case ' ':
@ -841,7 +841,7 @@ cookie_GetStatus(char decision) {
return nsICookie::STATUS_UNKNOWN;
}
nsCookiePolicy_t
nsCookiePolicy
cookie_GetPolicy(int policy) {
switch (policy) {
case P3P_NoPolicy:
@ -900,7 +900,7 @@ cookie_P3PUserPref(PRInt32 policy, PRBool foreign) {
/*
* returns STATUS_ACCEPT, STATUS_DOWNGRADE, STATUS_FLAG, or STATUS_REJECT based on user's preferences
*/
nsCookieStatus_t
nsCookieStatus
cookie_P3PDecision (char * curURL, char * firstURL, nsIIOService* ioService, nsIHttpChannel* aHttpChannel) {
return cookie_GetStatus(
cookie_P3PUserPref(
@ -987,7 +987,7 @@ cookie_Count(char * host) {
PRIVATE void
cookie_SetCookieString(char * curURL, nsIPrompt *aPrompter, const char * setCookieHeader,
time_t timeToExpire, nsIIOService* ioService,
nsIHttpChannel* aHttpChannel, nsCookieStatus_t status) {
nsIHttpChannel* aHttpChannel, nsCookieStatus status) {
cookie_CookieStruct * prev_cookie;
char *path_from_header=nsnull, *host_from_header=nsnull;
char *name_from_header=nsnull, *cookie_from_header=nsnull;
@ -1094,7 +1094,12 @@ cookie_SetCookieString(char * curURL, nsIPrompt *aPrompter, const char * setCook
int domain_length, cur_host_length;
/* allocate more than we need */
nsCAutoString domain(ptr+7);
nsCAutoString domain;
if (*(ptr+7) != '.') { // force domain name to start with a dot
domain = '.';
}
domain.Append(ptr+7);
domain.CompressWhitespace();
CKutil_StrAllocCopy(domain_from_header, domain.get());
@ -1416,7 +1421,7 @@ COOKIE_SetCookieStringFromHttp(char * curURL, char * firstURL, nsIPrompt *aPromp
time_t gmtCookieExpires=0, expires=0, sDate;
/* check to see if P3P pref is satisfied */
nsCookieStatus_t status = nsICookie::STATUS_UNKNOWN;
nsCookieStatus status = nsICookie::STATUS_UNKNOWN;
if (cookie_GetBehaviorPref() == PERMISSION_P3P) {
status = cookie_P3PDecision(curURL, firstURL, ioService, aHttpChannel);
if (status == nsICookie::STATUS_REJECTED) {
@ -1772,8 +1777,8 @@ COOKIE_Enumerate
char ** path,
PRBool * isSecure,
PRUint64 * expires,
nsCookieStatus_t * status,
nsCookiePolicy_t * policy) {
nsCookieStatus * status,
nsCookiePolicy * policy) {
if (count > COOKIE_Count()) {
return NS_ERROR_FAILURE;
}
@ -1800,7 +1805,7 @@ COOKIE_Enumerate
PUBLIC void
COOKIE_Remove
(const char* host, const char* name, const char* path, const PRBool permanent) {
(const char* host, const char* name, const char* path, const PRBool blocked) {
cookie_CookieStruct * cookie;
PRInt32 count = 0;
@ -1814,7 +1819,7 @@ COOKIE_Remove
if ((PL_strcmp(cookie->host, host) == 0) &&
(PL_strcmp(cookie->name, name) == 0) &&
(PL_strcmp(cookie->path, path) == 0)) {
if (permanent && cookie->host) {
if (blocked && cookie->host) {
char * hostname = nsnull;
char * hostnameAfterDot = cookie->host;
while (*hostnameAfterDot == '.') {

Просмотреть файл

@ -74,9 +74,9 @@ extern nsresult COOKIE_Enumerate
char ** path,
PRBool * isSecure,
PRUint64 * expires,
nsCookieStatus_t * status,
nsCookiePolicy_t * policy);
nsCookieStatus * status,
nsCookiePolicy * policy);
extern void COOKIE_Remove
(const char* host, const char* name, const char* path, const PRBool permanent);
(const char* host, const char* name, const char* path, const PRBool blocked);
#endif /* COOKIES_H */

Просмотреть файл

@ -21,61 +21,88 @@
#include "nsISupports.idl"
typedef long nsCookieStatus_t;
typedef long nsCookiePolicy_t;
/**
* An optional interface for embedding clients wishing to access an
* HTTP or javascript cookie object
*
* @status FROZEN
*/
typedef long nsCookieStatus;
typedef long nsCookiePolicy;
[scriptable, uuid(E9FCB9A4-D376-458f-B720-E65E7DF593BC)]
/**
This interface represents a HTTP or Javascript "cookie" object.
*/
interface nsICookie : nsISupports {
/* the name of the cookie */
readonly attribute string name;
/**
* the name of the cookie
*/
readonly attribute ACString name;
/* the cookie value */
readonly attribute string value;
/**
* the cookie value
*/
readonly attribute ACString value;
/* true if the cookie is a domain cookie, false otherwise */
/**
* true if the cookie is a domain cookie, false otherwise
*/
readonly attribute boolean isDomain;
/* the host (possibly fully qualified) of the cookie */
readonly attribute string host;
/**
* the host (possibly fully qualified) of the cookie
*/
readonly attribute AUTF8String host;
/* the path pertaining to the cookie */
readonly attribute string path;
/**
* the path pertaining to the cookie
*/
readonly attribute AUTF8String path;
/* true if the cookie was transmitted over ssl, false otherwise */
/**
* true if the cookie was transmitted over ssl, false otherwise
*/
readonly attribute boolean isSecure;
/* expiration time (local timezone) expressed as number of seconds since Jan 1, 1970 */
/**
* expiration time (local timezone) expressed as number of seconds since Jan 1, 1970
*/
readonly attribute PRUint64 expires;
/* P3P status -- accepted, downgraded, flagged, or rejected */
const nsCookieStatus_t STATUS_UNKNOWN=0;
const nsCookieStatus_t STATUS_ACCEPTED=1;
const nsCookieStatus_t STATUS_DOWNGRADED=2;
const nsCookieStatus_t STATUS_FLAGGED=3;
const nsCookieStatus_t STATUS_REJECTED=4;
/**
* P3P status of cookie. Values are
*
* STATUS_UNKNOWN -- cookie collected in a previous session and this info no longer available
* STATUS_ACCEPTED -- cookie was accepted as it
* STATUS_DOWNGRADED -- cookie was accepted but downgraded to a session cookie
* STATUS_FLAGGED -- cookie was accepted with a warning being issued to the user
* STATUS_REJECTED -- cookie was not accepted
*/
const nsCookieStatus STATUS_UNKNOWN=0;
const nsCookieStatus STATUS_ACCEPTED=1;
const nsCookieStatus STATUS_DOWNGRADED=2;
const nsCookieStatus STATUS_FLAGGED=3;
const nsCookieStatus STATUS_REJECTED=4;
readonly attribute nsCookieStatus_t status;
readonly attribute nsCookieStatus status;
/* Site's compact policy -- none, noConsent, implicitConsent, explicitConsent, noII */
const nsCookiePolicy_t POLICY_UNKNOWN=0;
const nsCookiePolicy_t POLICY_NONE=1;
const nsCookiePolicy_t POLICY_NO_CONSENT=2;
const nsCookiePolicy_t POLICY_IMPLICIT_CONSENT=3;
const nsCookiePolicy_t POLICY_EXPLICIT_CONSENT=4;
const nsCookiePolicy_t POLICY_NO_II=5;
readonly attribute nsCookiePolicy_t policy;
/**
* Site's compact policy. Values are
*
* POLICY_UNKNOWN -- cookie collected in a previous session and this info no longer available
* POLICY_NONE -- site did not send a compact policy along with the cookie
* POLICY_NO_CONSENT -- site collects identfiable information without user involvement
* POLICY_IMPLICIT_CONSENT -- site collects identifiable information unless user opts out
* POLICY_EXPLICIT_CONSENT -- site does not collect identifiable information unless user opts in
* POLICY_NO_II -- site does not collect identifiable information
*/
const nsCookiePolicy POLICY_UNKNOWN=0;
const nsCookiePolicy POLICY_NONE=1;
const nsCookiePolicy POLICY_NO_CONSENT=2;
const nsCookiePolicy POLICY_IMPLICIT_CONSENT=3;
const nsCookiePolicy POLICY_EXPLICIT_CONSENT=4;
const nsCookiePolicy POLICY_NO_II=5;
readonly attribute nsCookiePolicy policy;
};
%{ C++
// {E9FCB9A4-D376-458f-B720-E65E7DF593BC}
#define NS_COOKIE_CID \
{ 0xe9fcb9a4, 0xd376, 0x458f, { 0xb7, 0x20, 0xe6, 0x5e, 0x7d, 0xf5, 0x93, 0xbc } }
#define NS_COOKIE_CONTRACTID "@mozilla.org/cookie;1"
%}

Просмотреть файл

@ -34,28 +34,42 @@
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
This file contains an interface to the Cookie Manager.
* ***** END LICENSE BLOCK *****
*/
#include "nsISupports.idl"
#include "nsISimpleEnumerator.idl"
/**
* An optional interface for embedding clients wishing to access or
* remove the cookies that are in the cookie list
*
* @status FROZEN
*/
[scriptable, uuid(AAAB6710-0F2C-11d5-A53B-0010A401EB10)]
interface nsICookieManager : nsISupports
{
void removeAll();
readonly attribute nsISimpleEnumerator enumerator;
void remove(in string domain, in string name, in string path, [const] in boolean permanent);
};
%{ C++
// {AAAB6710-0F2C-11d5-A53B-0010A401EB10}
#define NS_COOKIEMANAGER_CID \
{ 0xaaab6710, 0xf2c, 0x11d5, { 0xa5, 0x3b, 0x0, 0x10, 0xa4, 0x1, 0xeb, 0x10 } }
#define NS_COOKIEMANAGER_CONTRACTID "@mozilla.org/cookiemanager;1"
%}
/**
* Called to remove all cookies from the cookie list
*/
void removeAll();
/**
* Called to enumerate through each cookie in the cookie list.
* The objects enumerated over are of type nsICookie
*/
readonly attribute nsISimpleEnumerator enumerator;
/**
* Called to remove an individual cookie from the cookie list
*
* @param aDomain The host or domain for which the cookie was set
* @param aName The name specified in the cookie
* @param aBlocked Indicates if cookies from this host should be permanently blocked
*
*/
void remove(in AUTF8String aDomain, in ACString aName, in AUTF8String aPath, in boolean aBlocked);
};

Просмотреть файл

@ -41,8 +41,10 @@
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsCookie.h"
#include "nsCCookie.h"
#include "nsPermission.h"
#include "nsCookieManager.h"
#include "nsCCookieManager.h"
#include "nsCookieService.h"
#include "nsImgManager.h"
#include "nsPermissionManager.h"