bug 233339 - rewrite CanSetCookie to reflect what dialogs now do, r=dwitte, sr=darin

This commit is contained in:
mconnor%myrealbox.com 2004-03-10 06:47:49 +00:00
Родитель 819efeac2a
Коммит a3a27f4e08
7 изменённых файлов: 182 добавлений и 150 удалений

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

@ -67,16 +67,30 @@
// have been chosen to extend nsCookieAccess for convenience.
static const nsCookieAccess ACCESS_SESSION = 8;
// values for mCookiesLifetimePolicy
// 0 == accept normally
// 1 == ask before accepting
// 2 == downgrade to session
// 3 == limit lifetime to N days
static const PRUint32 ACCEPT_NORMALLY = 0;
static const PRUint32 ASK_BEFORE_ACCEPT = 1;
static const PRUint32 ACCEPT_SESSION = 2;
static const PRUint32 ACCEPT_FOR_N_DAYS = 3;
static const PRBool kDefaultPolicy = PR_TRUE;
static const char kCookiesAskPermission[] = "network.cookie.warnAboutCookies";
#ifdef MOZ_PHOENIX
static const char kCookiesLifetimeEnabled[] = "network.cookie.enableForCurrentSessionOnly";
#else
static const char kCookiesLifetimeEnabled[] = "network.cookie.lifetime.enabled";
static const char kCookiesLifetimeCurrentSession[] = "network.cookie.lifetime.behavior";
static const char kCookiesLifetimePolicy[] = "network.cookie.lifetimePolicy";
static const char kCookiesLifetimeDays[] = "network.cookie.lifetime.days";
static const char kCookiesAlwaysAcceptSession[] = "network.cookie.alwaysAcceptSessionCookies";
#ifdef MOZ_MAIL_NEWS
static const char kCookiesDisabledForMailNews[] = "network.cookie.disableCookieForMailNews";
#endif
static const char kCookiesPrefsMigrated[] = "network.cookie.prefsMigrated";
// obsolete pref names for migration
static const char kCookiesLifetimeEnabled[] = "network.cookie.lifetime.enabled";
static const char kCookiesLifetimeBehavior[] = "network.cookie.lifetime.behavior";
static const char kCookiesAskPermission[] = "network.cookie.warnAboutCookies";
static const char kPermissionType[] = "cookie";
// XXX these casts and constructs are horrible, but our nsInt64/nsTime
@ -84,7 +98,7 @@ static const char kPermissionType[] = "cookie";
#define USEC_PER_SEC (nsInt64(1000000))
#define NOW_IN_SECONDS (nsInt64(PR_Now()) / USEC_PER_SEC)
#ifndef MOZ_PHOENIX
#ifdef MOZ_MAIL_NEWS
// returns PR_TRUE if URI appears to be the URI of a mailnews protocol
static PRBool
IsFromMailNews(nsIURI *aURI)
@ -140,14 +154,40 @@ nsCookiePermission::Init()
nsCOMPtr<nsIPrefBranchInternal> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefBranch) {
prefBranch->AddObserver(kCookiesAskPermission, this, PR_FALSE);
prefBranch->AddObserver(kCookiesLifetimeEnabled, this, PR_FALSE);
#ifndef MOZ_PHOENIX
prefBranch->AddObserver(kCookiesLifetimeCurrentSession, this, PR_FALSE);
prefBranch->AddObserver(kCookiesLifetimePolicy, this, PR_FALSE);
prefBranch->AddObserver(kCookiesLifetimeDays, this, PR_FALSE);
prefBranch->AddObserver(kCookiesAlwaysAcceptSession, this, PR_FALSE);
#ifdef MOZ_MAIL_NEWS
prefBranch->AddObserver(kCookiesDisabledForMailNews, this, PR_FALSE);
#endif
PrefChanged(prefBranch, nsnull);
// migration code for original cookie prefs
PRBool migrated;
rv = prefBranch->GetBoolPref(kCookiesPrefsMigrated, &migrated);
if (NS_FAILED(rv) || !migrated) {
PRBool warnAboutCookies = PR_FALSE;
prefBranch->GetBoolPref(kCookiesAskPermission, &warnAboutCookies);
// if the user is using ask before accepting, we'll use that
if (warnAboutCookies)
prefBranch->SetIntPref(kCookiesLifetimePolicy, ASK_BEFORE_ACCEPT);
PRBool lifetimeEnabled = PR_FALSE;
prefBranch->GetBoolPref(kCookiesLifetimeEnabled, &lifetimeEnabled);
// if they're limiting lifetime and not using the prompts, use the
// appropriate limited lifetime pref
if (lifetimeEnabled && !warnAboutCookies) {
PRInt32 lifetimeBehavior;
prefBranch->GetIntPref(kCookiesLifetimeBehavior, &lifetimeBehavior);
if (lifetimeBehavior)
prefBranch->SetIntPref(kCookiesLifetimePolicy, ACCEPT_FOR_N_DAYS);
else
prefBranch->SetIntPref(kCookiesLifetimePolicy, ACCEPT_SESSION);
}
prefBranch->SetBoolPref(kCookiesPrefsMigrated, PR_TRUE);
}
}
return NS_OK;
@ -161,24 +201,20 @@ nsCookiePermission::PrefChanged(nsIPrefBranch *aPrefBranch,
#define PREF_CHANGED(_P) (!aPref || !strcmp(aPref, _P))
if (PREF_CHANGED(kCookiesAskPermission) &&
NS_SUCCEEDED(aPrefBranch->GetBoolPref(kCookiesAskPermission, &val)))
mCookiesAskPermission = val;
if (PREF_CHANGED(kCookiesLifetimeEnabled) &&
NS_SUCCEEDED(aPrefBranch->GetBoolPref(kCookiesLifetimeEnabled, &val)))
mCookiesLifetimeEnabled = val;
#ifndef MOZ_PHOENIX
if (PREF_CHANGED(kCookiesLifetimeCurrentSession) &&
NS_SUCCEEDED(aPrefBranch->GetIntPref(kCookiesLifetimeCurrentSession, &val)))
mCookiesLifetimeCurrentSession = (val == 0);
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;
@ -203,7 +239,7 @@ nsCookiePermission::CanAccess(nsIURI *aURI,
nsIChannel *aChannel,
nsCookieAccess *aResult)
{
#ifndef MOZ_PHOENIX
#ifdef MOZ_MAIL_NEWS
// disable cookies in mailnews if user's prefs say so
if (mCookiesDisabledForMailNews) {
//
@ -242,7 +278,7 @@ nsCookiePermission::CanAccess(nsIURI *aURI,
return NS_OK;
}
}
#endif // MOZ_PHOENIX
#endif // MOZ_MAIL_NEWS
// finally, check with permission manager...
nsresult rv = mPermMgr->TestPermission(aURI, kPermissionType, (PRUint32 *) aResult);
@ -282,7 +318,6 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI,
*aResult = kDefaultPolicy;
nsresult rv;
PRUint32 perm;
mPermMgr->TestPermission(aURI, kPermissionType, &perm);
switch (perm) {
@ -301,33 +336,27 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI,
// the permission manager has nothing to say about this cookie -
// so, we apply the default prefs to it.
NS_ASSERTION(perm == nsIPermissionManager::UNKNOWN_ACTION, "unknown permission");
// check cookie lifetime pref, and limit lifetime if required.
// we only want to do this if the cookie isn't going to be expired anyway.
nsInt64 delta;
if (!*aIsSession) {
nsInt64 currentTime = NOW_IN_SECONDS;
delta = nsInt64(*aExpiry) - currentTime;
if (mCookiesLifetimeEnabled && delta > nsInt64(0)) {
#ifdef MOZ_PHOENIX
// limit lifetime to session
*aIsSession = PR_TRUE;
#else
if (mCookiesLifetimeCurrentSession) {
// limit lifetime to session
*aIsSession = PR_TRUE;
} else if (delta > mCookiesLifetimeSec) {
// limit lifetime to specified time
delta = mCookiesLifetimeSec;
*aExpiry = currentTime + mCookiesLifetimeSec;
}
#endif
}
// now we need to figure out what type of accept policy we're dealing with
// if we accept cookies normally, just bail and return
if (mCookiesLifetimePolicy == ACCEPT_NORMALLY) {
*aResult = PR_TRUE;
return NS_OK;
}
// declare this here since it'll be used in all of the remaining cases
nsInt64 currentTime = NOW_IN_SECONDS;
nsInt64 delta = nsInt64(*aExpiry) - currentTime;
// check whether the user wants to be prompted
if (mCookiesAskPermission) {
if (mCookiesLifetimePolicy == ASK_BEFORE_ACCEPT) {
// if it's a session cookie and the user wants to accept these
// without asking, just accept the cookie and return
if (*aIsSession && mCookiesAlwaysAcceptSession) {
*aResult = PR_TRUE;
return NS_OK;
}
// default to rejecting, in case the prompting process fails
*aResult = PR_FALSE;
@ -352,6 +381,7 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI,
// we don't cache the cookiePromptService - it's not used often, so not
// worth the memory.
nsresult rv;
nsCOMPtr<nsICookiePromptService> cookiePromptService =
do_GetService(NS_COOKIEPROMPTSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
@ -405,6 +435,18 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI,
break;
}
}
} else {
// we're not prompting, so we must be limiting the lifetime somehow
// if it's a session cookie, we do nothing
if (!*aIsSession && delta > nsInt64(0)) {
if (mCookiesLifetimePolicy == ACCEPT_SESSION) {
// limit lifetime to session
*aIsSession = PR_TRUE;
} else if (delta > mCookiesLifetimeSec) {
// limit lifetime to specified time
*aExpiry = currentTime + mCookiesLifetimeSec;
}
}
}
}

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

@ -56,12 +56,11 @@ public:
NS_DECL_NSIOBSERVER
nsCookiePermission()
: mCookiesAskPermission(PR_FALSE)
, mCookiesLifetimeEnabled(PR_FALSE)
#ifndef MOZ_PHOENIX
: mCookiesLifetimeSec(LL_MAXINT)
, mCookiesLifetimePolicy(LL_MAXINT)
, mCookiesAlwaysAcceptSession(PR_FALSE)
#ifdef MOZ_MAIL_NEWS
, mCookiesDisabledForMailNews(PR_TRUE)
, mCookiesLifetimeCurrentSession(PR_FALSE)
, mCookiesLifetimeSec(LL_MAXINT)
#endif
{}
virtual ~nsCookiePermission() {}
@ -72,13 +71,11 @@ public:
private:
nsCOMPtr<nsIPermissionManager> mPermMgr;
PRPackedBool mCookiesAskPermission;
PRPackedBool mCookiesLifetimeEnabled; // cookie lifetime limit enabled
// (for phoenix, this implies limited to session)
#ifndef MOZ_PHOENIX
PRPackedBool mCookiesDisabledForMailNews;
PRPackedBool mCookiesLifetimeCurrentSession; // limit cookie lifetime to current session
nsInt64 mCookiesLifetimeSec; // lifetime limit specified in seconds
PRUint8 mCookiesLifetimePolicy; // pref for how long cookies are stored
PRPackedBool mCookiesAlwaysAcceptSession; // don't prompt for session cookies
#ifdef MOZ_MAIL_NEWS
PRPackedBool mCookiesDisabledForMailNews;
#endif
};

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

@ -35,8 +35,8 @@
<script type="application/x-javascript">
<![CDATA[
var panel = "chrome://cookie/content/pref-cookies.xul";
var _elementIDs = ["networkCookieBehaviour", "networkWarnAboutCookies",
"lifetimeEnabled", "lifetimeBehavior", "lifetimeDays"];
var _elementIDs = ["networkCookieBehavior", "networkCookieLifetime",
"alwaysAcceptSession", "lifetimeDays"];
function init()
{
@ -48,52 +48,44 @@
var p3pRadioButton = document.getElementById("p3pRadioButton");
p3pRadioButton.removeAttribute("hidden");
}
}
const cookies_disabled = "2";
const cookies_no_third_party = "1";
const cookies_p3p = "3";
const cookies_enabled = "0";
const accept_normally = "0";
const accept_session = "2";
const accept_for_n_days = "3";
const ask_before_accepting = "1";
function setDisables(setFocus)
{
var cookieBehavior = document.getElementById("networkCookieBehaviour");
var cookieBehavior = document.getElementById("networkCookieBehavior");
var p3pButton = document.getElementById("p3pDialog");
p3pButton.disabled = (cookieBehavior.value != cookies_p3p);
if (parent.hPrefWindow.getPrefIsLocked(p3pButton.getAttribute("prefstring")) )
p3pButton.disabled = true;
// if mailnews is installed then we will have networkCookieBehaviorForMailNews checkbox
if (document.getElementById('networkDisableCookieForMailNews'))
{
var networkDisableCookieForMailNews = document.getElementById("networkDisableCookieForMailNews");
networkDisableCookieForMailNews.disabled = cookieBehavior.value == cookies_disabled;
var cookieLifetime = document.getElementById("networkCookieLifetime");
var lifetimeDays = document.getElementById("lifetimeDays");
var alwaysAcceptSession = document.getElementById("alwaysAcceptSession");
if (cookieLifetime.value == ask_before_accepting) {
lifetimeDays.disabled = true;
alwaysAcceptSession.disabled = false;
} else if (cookieLifetime.value == accept_for_n_days) {
lifetimeDays.disabled = false;
alwaysAcceptSession.disabled = true;
} else {
lifetimeDays.disabled = true;
alwaysAcceptSession.disabled = true;
}
var warnCheckbox = document.getElementById("networkWarnAboutCookies");
warnCheckbox.disabled = (cookieBehavior.value == cookies_disabled);
if (parent.hPrefWindow.getPrefIsLocked(warnCheckbox.getAttribute("prefstring")) )
warnCheckbox.disabled = true;
var lifetimeCheckbox = document.getElementById("lifetimeEnabled");
lifetimeCheckbox.disabled = (cookieBehavior.value == cookies_disabled);
if (parent.hPrefWindow.getPrefIsLocked(lifetimeCheckbox.getAttribute("prefstring")) )
lifetimeCheckbox.disabled = true;
var lifetimeEnabled = document.getElementById("lifetimeEnabled");
var lifetimeBehavior = document.getElementById("lifetimeBehavior");
var lifetimeDays = document.getElementById("lifetimeDays");
lifetimeBehavior.disabled = (cookieBehavior.value == cookies_disabled) ||
!lifetimeEnabled.checked;
if (parent.hPrefWindow.getPrefIsLocked(lifetimeBehavior.getAttribute("prefstring")) )
lifetimeBehavior.disabled = true;
lifetimeDays.disabled = (cookieBehavior.value == cookies_disabled) ||
!lifetimeEnabled.checked ||
(lifetimeBehavior.value != 1);
if (parent.hPrefWindow.getPrefIsLocked(alwaysAcceptSession.getAttribute("prefstring")) )
alwaysAcceptSession.disabled = true;
if (parent.hPrefWindow.getPrefIsLocked(lifetimeDays.getAttribute("prefstring")) )
lifetimeDays.disabled = true;
@ -103,8 +95,9 @@
]]>
</script>
<description>&cookieDetails;</description>
<radiogroup id="networkCookieBehaviour"
<groupbox id="networkCookieAcceptPolicy">
<caption label="&cookiePolicy.label;"/>
<radiogroup id="networkCookieBehavior"
prefstring="network.cookie.cookieBehavior">
<radio value="2" label="&disableCookies.label;"
accesskey="&disableCookies.accesskey;" oncommand="setDisables(false);"/>
@ -120,32 +113,36 @@
<radio value="0" label="&accAllCookiesRadio.label;"
accesskey="&accAllCookiesRadio.accesskey;" oncommand="setDisables(false);"/>
</radiogroup>
<separator id="networkCookieBehaviorSeparator"/>
<vbox align="start">
<checkbox id="networkWarnAboutCookies" label="&warnAboutCookies.label;" accesskey="&warnAboutCookies.accesskey;"
prefstring="network.cookie.warnAboutCookies"/>
<checkbox id="lifetimeEnabled" label="&limitLifetime.label;" accesskey="&limitLifetime.accesskey;"
prefstring="network.cookie.lifetime.enabled"
oncommand="setDisables(false);"/>
<hbox class="indent">
<radiogroup id="lifetimeBehavior" prefstring="network.cookie.lifetime.behavior">
<radio value="0" label="&current.label;"
accesskey="&current.accesskey;"
oncommand="setDisables(false);"/>
<hbox>
<radio value="1" accesskey="&days.accesskey;"
oncommand="setDisables(true);"/>
<textbox id="lifetimeDays" pref="true" size="4"
preftype="int" prefstring="network.cookie.lifetime.days"/>
<description>&days.label;</description>
</hbox>
</radiogroup>
</groupbox>
<groupbox id="networkCookieLifetimePolicy">
<caption label="&cookieLifetimePolicy.label;"/>
<radiogroup id="networkCookieLifetime"
prefstring="network.cookie.lifetimePolicy">
<radio value="0" label="&acceptNormally.label;" accesskey="&acceptNormally.accesskey;" oncommand="setDisables(false);"/>
<radio value="2" label="&acceptForSession.label;" accesskey="&acceptForSession.accesskey;" oncommand="setDisables(false);"/>
<hbox align="center">
<radio value="3" accesskey="&acceptforNDays.accesskey;" label="&acceptforNDays.label;"
oncommand="setDisables(true);"/>
<textbox id="lifetimeDays" pref="true" size="4"
preftype="int" prefstring="network.cookie.lifetime.days"/>
<label value="&days.label;" for="lifetimeDays"/>
</hbox>
</vbox>
<separator/>
<hbox pack="end">
<button label="&viewCookies.label;" accesskey="&viewCookies.accesskey;" oncommand="viewCookies();"
<hbox>
<radio value="1" label="&warnAboutCookies.label;"
accesskey="&warnAboutCookies.accesskey;" oncommand="setDisables(false);"/>
<checkbox id="alwaysAcceptSession" label="&forCurrentSession.label;"
accesskey="&forCurrentSession.accesskey;"
prefstring="network.cookie.alwaysAcceptSessionCookies"/>
</hbox>
</radiogroup>
</groupbox>
<groupbox id="manageCookiesAndSites">
<caption label="&manageCookies.label;"/>
<description>&manageCookiesDescription.label;</description>
<hbox pack="end">
<button label="&viewCookies.label;" accesskey="&viewCookies.accesskey;" oncommand="viewCookies();"
id="viewCookieButton"
prefstring="pref.advanced.cookies.disable_button.view_cookies"/>
</hbox>
</hbox>
</groupbox>
</page>

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

@ -4,31 +4,40 @@
<!ENTITY cookiePolicy.label "Cookie Acceptance Policy">
<!ENTITY accAllCookiesRadio.label "Enable all cookies">
<!ENTITY accAllCookiesRadio.label "Allow all cookies">
<!ENTITY accAllCookiesRadio.accesskey "c">
<!ENTITY accOrgCookiesRadio.label "Enable cookies for the originating web site only">
<!ENTITY accOrgCookiesRadio.label "Allow cookies for the originating web site only">
<!ENTITY accOrgCookiesRadio.accesskey "o">
<!ENTITY accP3PCookiesRadio.label "Enable cookies based on privacy settings">
<!ENTITY accP3PCookiesRadio.label "Allow cookies based on privacy settings">
<!ENTITY accP3PCookiesRadio.accesskey "p">
<!ENTITY disableCookies.label "Disable cookies">
<!ENTITY disableCookies.accesskey "D">
<!ENTITY disableCookies.label "Block cookies">
<!ENTITY disableCookies.accesskey "B">
<!ENTITY warnAboutCookies.label "Ask me before storing a cookie">
<!ENTITY cookieLifetimePolicy.label "Cookie Lifetime Policy">
<!ENTITY acceptNormally.label "Accept cookies normally">
<!ENTITY acceptNormally.accesskey "n">
<!ENTITY acceptForSession.label "Accept for current session only">
<!ENTITY acceptForSession.accesskey "s">
<!ENTITY acceptforNDays.label "Accept cookies for">
<!ENTITY acceptforNDays.accesskey "f">
<!ENTITY days.label "days">
<!ENTITY warnAboutCookies.label "Ask for each cookie">
<!ENTITY warnAboutCookies.accesskey "A">
<!ENTITY forCurrentSession.label "except for session cookies">
<!ENTITY forCurrentSession.accesskey "e">
<!ENTITY cookieDetails "Cookies are small pieces of information that some web sites ask to store on (and later retrieve from) your computer.">
<!ENTITY manageCookies.label "Manage Cookies and Sites">
<!ENTITY manageCookiesDescription.label "Allows you to view and manage stored cookies and per-site settings for accepting and rejecting cookies. Per-site settings will override the settings above.">
<!ENTITY viewCookies.label "Manage Stored Cookies">
<!ENTITY viewCookies.label "Cookie Manager">
<!ENTITY viewCookies.accesskey "M">
<!ENTITY viewP3P.label "View">
<!ENTITY viewP3P.accesskey "V">
<!ENTITY limitLifetime.label "Limit maximum lifetime of cookies to:">
<!ENTITY limitLifetime.accesskey "L">
<!ENTITY current.label "current session">
<!ENTITY current.accesskey "r">
<!ENTITY days.label "days">
<!ENTITY days.accesskey "y">

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

@ -21,9 +21,6 @@
case "chrome://communicator/content/pref/pref-appearance.xul":
_elementIDs.push("generalStartupMail");
break;
case "chrome://cookie/content/pref-cookies.xul":
_elementIDs.push("networkDisableCookieForMailNews");
break;
case "chrome://cookie/content/pref-images.xul":
_elementIDs.push("networkImageDisableImagesInMailNews");
break;
@ -54,13 +51,6 @@
pref="true" preftype="bool" prefstring="general.startup.mail"
prefattribute="checked"/>
</groupbox>
<!--- cookie toggle for mail/news -->
<page id="cookiesPanel">
<checkbox id="networkDisableCookieForMailNews"
label="&disableCookieForMailNews.label;" accesskey="&disableCookieForMailNews.accesskey;"
preftype="bool" prefstring="network.cookie.disableCookieForMailNews"
insertafter="networkCookieBehaviorSeparator"/>
</page>
<!--- image toggle for mail/news -->
<groupbox id="imagesArea">
<checkbox id="networkImageDisableImagesInMailNews"

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

@ -4,9 +4,6 @@
<!ENTITY enbPluginCheckMailNews.label "Mail &amp; Newsgroups">
<!ENTITY enbPluginCheckMailNews.accesskey "p">
<!ENTITY disableCookieForMailNews.label "Disable cookies in Mail &amp; Newsgroups">
<!ENTITY disableCookieForMailNews.accesskey "m">
<!ENTITY disableImageInMailNews.label "Do not load remote images in Mail &amp; Newsgroup messages">
<!ENTITY disableImageInMailNews.accesskey "i">

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

@ -591,9 +591,9 @@ pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1");
pref("network.online", true); //online/offline
pref("network.cookie.cookieBehavior", 3); // 0-Accept, 1-dontAcceptForeign, 2-dontUse, 3-p3p
pref("network.cookie.disableCookieForMailNews", true); // disable all cookies for mail
pref("network.cookie.warnAboutCookies", false);
pref("network.cookie.lifetime.enabled", false);
pref("network.cookie.lifetime.behavior", 0);
pref("network.cookie.lifetimePolicy", 0); // accept normally, 1-askBeforeAccepting, 2-acceptForSession,3-acceptForNDays
pref("network.cookie.alwaysAcceptSessionCookies", false);
pref("network.cookie.prefsMigrated", false);
pref("network.cookie.lifetime.days", 90);
// The following default value is for p3p medium mode.