Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Attributes
nsCookiePermission Class Reference

#include <nsCookiePermission.h>

Inheritance diagram for nsCookiePermission:
Inheritance graph
[legend]
Collaboration diagram for nsCookiePermission:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSICOOKIEPERMISSION
NS_DECL_NSIOBSERVER 
nsCookiePermission ()
virtual ~nsCookiePermission ()
nsresult Init ()
void PrefChanged (nsIPrefBranch *, const char *)
void setAccess (in nsIURI aURI, in nsCookieAccess aAccess)
 setAccess
nsCookieAccess canAccess (in nsIURI aURI, in nsIURI aFirstURI, in nsIChannel aChannel)
 canAccess
boolean canSetCookie (in nsIURI aURI, in nsIChannel aChannel, in nsICookie2 aCookie, inout boolean aIsSession, inout PRInt64 aExpiry)
 canSetCookie
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

const nsCookieAccess ACCESS_DEFAULT = 0
 nsCookieAccess values
const nsCookieAccess ACCESS_ALLOW = 1
const nsCookieAccess ACCESS_DENY = 2
const nsCookieAccess ACCESS_SESSION = 8
 additional values for nsCookieAccess, which are not directly used by any methods on this interface, but are nevertheless convenient to define here.

Private Attributes

nsCOMPtr< nsIPermissionManagermPermMgr
nsInt64 mCookiesLifetimeSec
PRUint8 mCookiesLifetimePolicy
PRPackedBool mCookiesAlwaysAcceptSession

Detailed Description

Definition at line 50 of file nsCookiePermission.h.


Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_NSICOOKIEPERMISSION NS_DECL_NSIOBSERVER nsCookiePermission::nsCookiePermission ( ) [inline]

Definition at line 58 of file nsCookiePermission.h.

    : mCookiesLifetimeSec(LL_MAXINT)
    , mCookiesLifetimePolicy(0) // ACCEPT_NORMALLY
    , mCookiesAlwaysAcceptSession(PR_FALSE)
#ifdef MOZ_MAIL_NEWS
    , mCookiesDisabledForMailNews(PR_TRUE)
#endif
    {}
virtual nsCookiePermission::~nsCookiePermission ( ) [inline, virtual]

Definition at line 66 of file nsCookiePermission.h.

{}

Member Function Documentation

nsCookieAccess nsICookiePermission::canAccess ( in nsIURI  aURI,
in nsIURI  aFirstURI,
in nsIChannel  aChannel 
) [inherited]

canAccess

this method is called to test whether or not the given URI/channel may access the cookie database, either to set or get cookies.

Parameters:
aURIthe URI trying to access cookies
aFirstURIthe URI initiated by the user that resulted in aURI being loaded
aChannelthe channel corresponding to aURI
Returns:
one of the following nsCookieAccess values: ACCESS_DEFAULT, ACCESS_ALLOW, or ACCESS_DENY
boolean nsICookiePermission::canSetCookie ( in nsIURI  aURI,
in nsIChannel  aChannel,
in nsICookie2  aCookie,
inout boolean  aIsSession,
inout PRInt64  aExpiry 
) [inherited]

canSetCookie

this method is called to test whether or not the given URI/channel may set a specific cookie. this method is always preceded by a call to canAccess. it may modify the isSession and expiry attributes of the cookie via the aIsSession and aExpiry parameters, in order to limit or extend the lifetime of the cookie. this is useful, for instance, to downgrade a cookie to session-only if it fails to meet certain criteria.

Parameters:
aURIthe URI trying to set the cookie
aChannelthe corresponding to aURI
aCookiethe cookie being added to the cookie database
aIsSessionwhen canSetCookie is invoked, this is the current isSession attribute of the cookie. canSetCookie may leave this value unchanged to preserve this attribute of the cookie.
aExpirywhen canSetCookie is invoked, this is the current expiry time of the cookie. canSetCookie may leave this value unchanged to preserve this attribute of the cookie.
Returns:
true if the cookie can be set.
void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
void nsCookiePermission::PrefChanged ( nsIPrefBranch aPrefBranch,
const char *  aPref 
)

Definition at line 166 of file nsCookiePermission.cpp.

{
  PRBool val;

#define PREF_CHANGED(_P) (!aPref || !strcmp(aPref, _P))

  if (PREF_CHANGED(kCookiesLifetimePolicy) &&
      NS_SUCCEEDED(aPrefBranch->GetIntPref(kCookiesLifetimePolicy, &val)))
    mCookiesLifetimePolicy = val;

  if (PREF_CHANGED(kCookiesLifetimeDays) &&
      NS_SUCCEEDED(aPrefBranch->GetIntPref(kCookiesLifetimeDays, &val)))
    // save cookie lifetime in seconds instead of days
    mCookiesLifetimeSec = val * 24 * 60 * 60;

  if (PREF_CHANGED(kCookiesAlwaysAcceptSession) &&
      NS_SUCCEEDED(aPrefBranch->GetBoolPref(kCookiesAlwaysAcceptSession, &val)))
    mCookiesAlwaysAcceptSession = val;

#ifdef MOZ_MAIL_NEWS
  if (PREF_CHANGED(kCookiesDisabledForMailNews) &&
      NS_SUCCEEDED(aPrefBranch->GetBoolPref(kCookiesDisabledForMailNews, &val)))
    mCookiesDisabledForMailNews = val;
#endif
}
void nsICookiePermission::setAccess ( in nsIURI  aURI,
in nsCookieAccess  aAccess 
) [inherited]

setAccess

this method is called to block cookie access for the given URI. this may result in other URIs being blocked as well (e.g., URIs which share the same host name).

Parameters:
aURIthe URI to block
aAccessthe new cookie access for the URI.

Member Data Documentation

Definition at line 55 of file nsICookiePermission.idl.

nsCookieAccess values

Definition at line 54 of file nsICookiePermission.idl.

Definition at line 56 of file nsICookiePermission.idl.

additional values for nsCookieAccess, which are not directly used by any methods on this interface, but are nevertheless convenient to define here.

these may be relocated somewhere else if we ever consider freezing this interface.

Definition at line 64 of file nsICookiePermission.idl.

Definition at line 76 of file nsCookiePermission.h.

Definition at line 75 of file nsCookiePermission.h.

Definition at line 74 of file nsCookiePermission.h.

Definition at line 72 of file nsCookiePermission.h.


The documentation for this class was generated from the following files: