зеркало из https://github.com/mozilla/pjs.git
22994 r=morse sr=dveditz sspitzer Add support for blocking cookies in mailnews by default. Used an overlay
to add this new checkbox that gets the value from disableCookieForMailNews pref
This commit is contained in:
Родитель
a9ca786d4f
Коммит
ffcb697f87
|
@ -63,6 +63,7 @@
|
|||
#define MAX_BYTES_PER_COOKIE 4096 /* must be at least 1 */
|
||||
|
||||
#define cookie_behaviorPref "network.cookie.cookieBehavior"
|
||||
#define cookie_disableCookieForMailNewsPref "network.cookie.disableCookieForMailNews"
|
||||
#define cookie_warningPref "network.cookie.warnAboutCookies"
|
||||
#define cookie_strictDomainsPref "network.cookie.strictDomains"
|
||||
#define cookie_lifetimePref "network.cookie.lifetimeOption"
|
||||
|
@ -107,6 +108,7 @@ typedef enum {
|
|||
|
||||
PRIVATE PRBool cookie_changed = PR_FALSE;
|
||||
PRIVATE PERMISSION_BehaviorEnum cookie_behavior = PERMISSION_Accept;
|
||||
PRIVATE PRBool cookie_disableCookieForMailNews = PR_TRUE; //default -- disable is true
|
||||
PRIVATE PRBool cookie_warning = PR_FALSE;
|
||||
PRIVATE COOKIE_LifetimeEnum cookie_lifetimeOpt = COOKIE_Normal;
|
||||
PRIVATE time_t cookie_lifetimeLimit = 90*24*60*60;
|
||||
|
@ -353,6 +355,11 @@ cookie_SetBehaviorPref(PERMISSION_BehaviorEnum x, nsIPref* prefs) {
|
|||
cookie_behavior = x;
|
||||
}
|
||||
|
||||
PRIVATE void
|
||||
cookie_SetDisableCookieForMailNewsPref(PRBool x) {
|
||||
cookie_disableCookieForMailNews = x;
|
||||
}
|
||||
|
||||
PRIVATE void
|
||||
cookie_SetWarningPref(PRBool x) {
|
||||
cookie_warning = x;
|
||||
|
@ -374,6 +381,11 @@ cookie_GetBehaviorPref() {
|
|||
return cookie_behavior;
|
||||
}
|
||||
|
||||
PRIVATE PRBool
|
||||
cookie_GetDisableCookieForMailNewsPref() {
|
||||
return cookie_disableCookieForMailNews;
|
||||
}
|
||||
|
||||
PRIVATE PRBool
|
||||
cookie_GetWarningPref() {
|
||||
return cookie_warning;
|
||||
|
@ -432,6 +444,18 @@ cookie_BehaviorPrefChanged(const char * newpref, void * data) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
MODULE_PRIVATE int PR_CALLBACK
|
||||
cookie_DisableCookieForMailNewsPrefChanged(const char * newpref, void * data) {
|
||||
PRBool x;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
if (!prefs || NS_FAILED(prefs->GetBoolPref(cookie_disableCookieForMailNewsPref, &x))) {
|
||||
x = PR_TRUE;
|
||||
}
|
||||
cookie_SetDisableCookieForMailNewsPref(x);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MODULE_PRIVATE int PR_CALLBACK
|
||||
cookie_WarningPrefChanged(const char * newpref, void * data) {
|
||||
PRBool x;
|
||||
|
@ -536,6 +560,13 @@ COOKIE_RegisterPrefCallbacks(void) {
|
|||
cookie_SetBehaviorPref((PERMISSION_BehaviorEnum)n, prefs);
|
||||
prefs->RegisterCallback(cookie_behaviorPref, cookie_BehaviorPrefChanged, nsnull);
|
||||
|
||||
// Initialize cookie_disableCookieForMailNewsPref
|
||||
if (NS_FAILED(prefs->GetBoolPref(cookie_disableCookieForMailNewsPref, &x))) {
|
||||
x = PR_TRUE; //default --> disable is true
|
||||
}
|
||||
cookie_SetDisableCookieForMailNewsPref(x);
|
||||
prefs->RegisterCallback(cookie_disableCookieForMailNewsPref, cookie_DisableCookieForMailNewsPrefChanged, nsnull);
|
||||
|
||||
// Initialize for cookie_warningPref
|
||||
if (NS_FAILED(prefs->GetBoolPref(cookie_warningPref, &x))) {
|
||||
x = PR_FALSE;
|
||||
|
@ -797,6 +828,27 @@ cookie_SameDomain(char * currentHost, char * firstHost) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
PRBool
|
||||
cookie_isFromMailNews(char *firstURL, nsIIOService* ioService) {
|
||||
|
||||
if (!firstURL)
|
||||
return PR_FALSE;
|
||||
|
||||
NS_ASSERTION(ioService, "IOService not available");
|
||||
if (!ioService)
|
||||
return PR_FALSE; // we cannot check the scheme of orignal uri
|
||||
|
||||
nsCAutoString schemeString;
|
||||
nsresult rv = ioService->ExtractScheme(nsDependentCString(firstURL), schemeString);
|
||||
if (NS_FAILED(rv)) //malformed uri
|
||||
return PR_FALSE;
|
||||
|
||||
return (schemeString.Equals(NS_LITERAL_CSTRING("imap")) ||
|
||||
schemeString.Equals(NS_LITERAL_CSTRING("news")) ||
|
||||
schemeString.Equals(NS_LITERAL_CSTRING("mailbox")));
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
cookie_isForeign (char * curURL, char * firstURL, nsIIOService* ioService) {
|
||||
if (!firstURL) {
|
||||
|
@ -1465,6 +1517,10 @@ COOKIE_SetCookieStringFromHttp(char * curURL, char * firstURL, nsIPrompt *aPromp
|
|||
return;
|
||||
}
|
||||
|
||||
/* check if a Mail/News message is setting the cookie */
|
||||
if (cookie_GetDisableCookieForMailNewsPref() && cookie_isFromMailNews(firstURL, ioService))
|
||||
return;
|
||||
|
||||
/* Determine when the cookie should expire. This is done by taking the difference between
|
||||
* the server time and the time the server wants the cookie to expire, and adding that
|
||||
* difference to the client time. This localizes the client time regardless of whether or
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<!DOCTYPE window SYSTEM "chrome://cookie/locale/pref-cookies.dtd">
|
||||
|
||||
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
<page id="cookiesPanel" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="init();"
|
||||
headertitle="&lHeader;">
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
|
||||
var panel = "chrome://cookie/content/pref-cookies.xul";
|
||||
var _elementIDs = ["networkCookieBehaviour", "networkWarnAboutCookies",
|
||||
"lifetimeEnabled", "lifetimeBehavior", "lifetimeDays"];
|
||||
|
||||
|
@ -65,6 +65,13 @@
|
|||
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 warnCheckbox = document.getElementById("networkWarnAboutCookies");
|
||||
warnCheckbox.disabled = (cookieBehavior.value == cookies_disabled);
|
||||
if (parent.hPrefWindow.getPrefIsLocked(warnCheckbox.getAttribute("prefstring")) )
|
||||
|
@ -111,7 +118,7 @@
|
|||
<radio value="0" label="&accAllCookiesRadio.label;"
|
||||
accesskey="&accAllCookiesRadio.accesskey;" oncommand="setDisables();"/>
|
||||
</radiogroup>
|
||||
<separator/>
|
||||
<separator id="networkCookieBehaviorSeparator"/>
|
||||
<vbox align="start">
|
||||
<checkbox id="networkWarnAboutCookies" label="&warnAboutCookies.label;" accesskey="&warnAboutCookies.accesskey;"
|
||||
prefstring="network.cookie.warnAboutCookies"/>
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
case "chrome://communicator/content/pref/pref-appearance.xul":
|
||||
_elementIDs.push("generalStartupMail");
|
||||
break;
|
||||
case "chrome://cookie/content/pref-cookies.xul":
|
||||
_elementIDs.push("networkDisableCookieForMailNews");
|
||||
break;
|
||||
}
|
||||
}
|
||||
]]>
|
||||
|
@ -39,6 +42,13 @@
|
|||
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;"
|
||||
pref="true" preftype="bool" prefstring="network.cookie.disableCookieForMailNews"
|
||||
prefattribute="checked" insertafter="networkCookieBehaviorSeparator"/>
|
||||
</page>
|
||||
|
||||
<!-- category tree entries for mail/news -->
|
||||
<treechildren id="panelChildren">
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
<!ENTITY enbJsCheckMailNews.label "Mail & Newsgroups">
|
||||
<!ENTITY enbJsCheckMailNews.accesskey "m">
|
||||
|
||||
<!ENTITY disableCookieForMailNews.label "Disable cookies in Mail & Newsgroups">
|
||||
<!ENTITY disableCookieForMailNews.accesskey "m">
|
||||
|
||||
<!ENTITY mail.label "Mail & Newsgroups">
|
||||
<!ENTITY mail.accesskey "m">
|
||||
<!ENTITY address.label "Addressing">
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<RDF:li resource="chrome://communicator/content/pref/preftree.xul"/>
|
||||
<RDF:li resource="chrome://communicator/content/pref/pref-appearance.xul"/>
|
||||
<RDF:li resource="chrome://communicator/content/pref/pref-scripts.xul"/>
|
||||
<RDF:li resource="chrome://cookie/content/pref-cookies.xul"/>
|
||||
<RDF:li resource="chrome://navigator/content/navigatorOverlay.xul"/>
|
||||
<RDF:li resource="chrome://messenger/content/messenger.xul"/>
|
||||
<RDF:li resource="chrome://messenger/content/mail3PaneWindowVertLayout.xul"/>
|
||||
|
@ -48,6 +49,11 @@
|
|||
<RDF:li>chrome://messenger/content/mailPrefsOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger cookie toggle pref -->
|
||||
<RDF:Seq about="chrome://cookie/content/pref-cookies.xul">
|
||||
<RDF:li>chrome://messenger/content/mailPrefsOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- messenger taskbar/tasks menu items -->
|
||||
<RDF:Seq about="chrome://editor/content/editorTasksOverlay.xul">
|
||||
<RDF:li>chrome://messenger/content/mailTasksOverlay.xul</RDF:li>
|
||||
|
|
|
@ -493,6 +493,7 @@ pref("network.online", true); //online/offline
|
|||
pref("network.accept_cookies", 0); // 0 = Always, 1 = warn, 2 = never
|
||||
pref("network.foreign_cookies", 0); // 0 = Accept, 1 = Don't accept
|
||||
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче