зеркало из https://github.com/mozilla/pjs.git
Bug 238931: remove the magic number 8 (kill ALLOW_SESSION_ONLY const), r=dwitte, sr=darin, a1.7=asa, fix dwitte's folly by implementing the session perm value on nsICookiePermission
This commit is contained in:
Родитель
e1d52014de
Коммит
1c888c7563
|
@ -61,12 +61,6 @@
|
|||
************************ nsCookiePermission ********************
|
||||
****************************************************************/
|
||||
|
||||
// additional values for nsCookieAccess, which are for internal use only
|
||||
// (and thus do not belong in the public nsICookiePermission API). these
|
||||
// private values could be defined as a separate set of constants, but
|
||||
// have been chosen to extend nsCookieAccess for convenience.
|
||||
static const nsCookieAccess ACCESS_SESSION = 8;
|
||||
|
||||
// values for mCookiesLifetimePolicy
|
||||
// 0 == accept normally
|
||||
// 1 == ask before accepting
|
||||
|
@ -290,10 +284,9 @@ nsCookiePermission::CanAccess(nsIURI *aURI,
|
|||
case nsIPermissionManager::DENY_ACTION: // ACCESS_DENY
|
||||
break;
|
||||
|
||||
// for types not publicly available, we need to convert the value
|
||||
// into an understandable one. ACCESS_SESSION means the cookie can be
|
||||
// accepted; the session downgrade will occur in CanSetCookie().
|
||||
case ACCESS_SESSION:
|
||||
// ACCESS_SESSION means the cookie can be accepted; the session
|
||||
// downgrade will occur in CanSetCookie().
|
||||
case nsICookiePermission::ACCESS_SESSION:
|
||||
*aResult = ACCESS_ALLOW;
|
||||
break;
|
||||
|
||||
|
@ -321,7 +314,7 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI,
|
|||
PRUint32 perm;
|
||||
mPermMgr->TestPermission(aURI, kPermissionType, &perm);
|
||||
switch (perm) {
|
||||
case ACCESS_SESSION:
|
||||
case nsICookiePermission::ACCESS_SESSION:
|
||||
*aIsSession = PR_TRUE;
|
||||
|
||||
case nsIPermissionManager::ALLOW_ACTION: // ACCESS_ALLOW
|
||||
|
@ -429,7 +422,7 @@ nsCookiePermission::CanSetCookie(nsIURI *aURI,
|
|||
mPermMgr->Add(aURI, kPermissionType, (PRUint32) nsIPermissionManager::ALLOW_ACTION);
|
||||
break;
|
||||
case nsICookiePromptService::ACCEPT_SESSION_COOKIE:
|
||||
mPermMgr->Add(aURI, kPermissionType, ACCESS_SESSION);
|
||||
mPermMgr->Add(aURI, kPermissionType, nsICookiePermission::ACCESS_SESSION);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -35,12 +35,9 @@
|
|||
// both are necessary. popupmanager is just a special case
|
||||
// of permissionmanager but does extra work on add/remove
|
||||
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
|
||||
const nsICookiePermission = Components.interfaces.nsICookiePermission;
|
||||
var permissionmanager;
|
||||
var popupmanager;
|
||||
|
||||
// XXX this needs to be defined publicly
|
||||
// see bug 225857 comment 7
|
||||
const ALLOW_SESSION_ONLY = 8;
|
||||
|
||||
// determine which items we need to hide or disable from the task menu
|
||||
function CheckForVisibility()
|
||||
|
@ -62,7 +59,7 @@
|
|||
var uri = getBrowser().currentURI;
|
||||
setRadioButton("UseCookiesDefault", uri, nsIPermissionManager.UNKNOWN_ACTION, "cookie");
|
||||
setRadioButton("AllowCookies", uri, nsIPermissionManager.ALLOW_ACTION, "cookie");
|
||||
setRadioButton("AllowSessionCookies", uri, ALLOW_SESSION_ONLY, "cookie");
|
||||
setRadioButton("AllowSessionCookies", uri, nsICookiePermission.ACCESS_SESSION, "cookie");
|
||||
setRadioButton("BlockCookies", uri, nsIPermissionManager.DENY_ACTION, "cookie");
|
||||
setRadioButton("UseImagesDefault", uri, nsIPermissionManager.UNKNOWN_ACTION, "image");
|
||||
setRadioButton("AllowImages", uri, nsIPermissionManager.ALLOW_ACTION, "image");
|
||||
|
@ -124,9 +121,9 @@
|
|||
element = document.getElementById("AllowCookies");
|
||||
break;
|
||||
case "cookieSession":
|
||||
if (permissionmanager.testPermission(uri, "cookie") == ALLOW_SESSION_ONLY)
|
||||
if (permissionmanager.testPermission(uri, "cookie") == nsICookiePermission.ACCESS_SESSION)
|
||||
return;
|
||||
permissionmanager.add(uri, "cookie", ALLOW_SESSION_ONLY);
|
||||
permissionmanager.add(uri, "cookie", nsICookiePermission.ACCESS_SESSION);
|
||||
element = document.getElementById("AllowSessionCookies");
|
||||
break;
|
||||
case "cookieDefault":
|
||||
|
|
|
@ -39,13 +39,11 @@ var deletedPermissions = [];
|
|||
|
||||
// differentiate between cookies, images, and popups
|
||||
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
|
||||
const nsICookiePermission = Components.interfaces.nsICookiePermission;
|
||||
const cookieType = "cookie";
|
||||
const imageType = "image";
|
||||
const popupType = "popup";
|
||||
|
||||
// XXX this needs to be defined publicly
|
||||
// see bug 225857 comment 7
|
||||
const ALLOW_SESSION_ONLY = 8;
|
||||
|
||||
var dialogType = cookieType;
|
||||
if (window.arguments[0] == "imageManager")
|
||||
|
@ -531,7 +529,7 @@ function loadPermissions() {
|
|||
case nsIPermissionManager.DENY_ACTION:
|
||||
capability = cannotStr;
|
||||
break;
|
||||
case ALLOW_SESSION_ONLY:
|
||||
case nsICookiePermission.ACCESS_SESSION:
|
||||
// we should only hit this for cookies
|
||||
capability = canSessionStr;
|
||||
break;
|
||||
|
|
|
@ -160,7 +160,7 @@
|
|||
<button id="btnBlock" label="&blockSite.label;" disabled="true"
|
||||
oncommand="setCookiePermissions(nsIPermissionManager.DENY_ACTION);"/>
|
||||
<button id="btnSession" label="&allowSiteSession.label;" disabled="true"
|
||||
oncommand="setCookiePermissions(ALLOW_SESSION_ONLY);"/>
|
||||
oncommand="setCookiePermissions(nsICookiePermission.ACCESS_SESSION);"/>
|
||||
<button id="btnAllow" label="&allowSite.label;" disabled="true"
|
||||
oncommand="setCookiePermissions(nsIPermissionManager.ALLOW_ACTION);"/>
|
||||
</hbox>
|
||||
|
|
|
@ -55,6 +55,14 @@ interface nsICookiePermission : nsISupports
|
|||
const nsCookieAccess ACCESS_ALLOW = 1;
|
||||
const nsCookieAccess ACCESS_DENY = 2;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const nsCookieAccess ACCESS_SESSION = 8;
|
||||
|
||||
/**
|
||||
* setAccess
|
||||
*
|
||||
|
@ -83,7 +91,8 @@ interface nsICookiePermission : nsISupports
|
|||
* @param aChannel
|
||||
* the channel corresponding to aURI
|
||||
*
|
||||
* @return nsCookieAccess value
|
||||
* @return one of the following nsCookieAccess values:
|
||||
* ACCESS_DEFAULT, ACCESS_ALLOW, or ACCESS_DENY
|
||||
*/
|
||||
nsCookieAccess canAccess(in nsIURI aURI,
|
||||
in nsIURI aFirstURI,
|
||||
|
|
|
@ -39,13 +39,11 @@ var deletedPermissions = [];
|
|||
|
||||
// differentiate between cookies, images, and popups
|
||||
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
|
||||
const nsICookiePermission = Components.interfaces.nsICookiePermission;
|
||||
const cookieType = "cookie";
|
||||
const imageType = "image";
|
||||
const popupType = "popup";
|
||||
|
||||
// XXX this needs to be defined publicly
|
||||
// see bug 225857 comment 7
|
||||
const ALLOW_SESSION_ONLY = 8;
|
||||
|
||||
var dialogType = cookieType;
|
||||
if (window.arguments[0] == "imageManager")
|
||||
|
@ -531,7 +529,7 @@ function loadPermissions() {
|
|||
case nsIPermissionManager.DENY_ACTION:
|
||||
capability = cannotStr;
|
||||
break;
|
||||
case ALLOW_SESSION_ONLY:
|
||||
case nsICookiePermission.ACCESS_SESSION:
|
||||
// we should only hit this for cookies
|
||||
capability = canSessionStr;
|
||||
break;
|
||||
|
|
|
@ -160,7 +160,7 @@
|
|||
<button id="btnBlock" label="&blockSite.label;" disabled="true"
|
||||
oncommand="setCookiePermissions(nsIPermissionManager.DENY_ACTION);"/>
|
||||
<button id="btnSession" label="&allowSiteSession.label;" disabled="true"
|
||||
oncommand="setCookiePermissions(ALLOW_SESSION_ONLY);"/>
|
||||
oncommand="setCookiePermissions(nsICookiePermission.ACCESS_SESSION);"/>
|
||||
<button id="btnAllow" label="&allowSite.label;" disabled="true"
|
||||
oncommand="setCookiePermissions(nsIPermissionManager.ALLOW_ACTION);"/>
|
||||
</hbox>
|
||||
|
|
|
@ -35,12 +35,9 @@
|
|||
// both are necessary. popupmanager is just a special case
|
||||
// of permissionmanager but does extra work on add/remove
|
||||
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
|
||||
const nsICookiePermission = Components.interfaces.nsICookiePermission;
|
||||
var permissionmanager;
|
||||
var popupmanager;
|
||||
|
||||
// XXX this needs to be defined publicly
|
||||
// see bug 225857 comment 7
|
||||
const ALLOW_SESSION_ONLY = 8;
|
||||
|
||||
// determine which items we need to hide or disable from the task menu
|
||||
function CheckForVisibility()
|
||||
|
@ -62,7 +59,7 @@
|
|||
var uri = getBrowser().currentURI;
|
||||
setRadioButton("UseCookiesDefault", uri, nsIPermissionManager.UNKNOWN_ACTION, "cookie");
|
||||
setRadioButton("AllowCookies", uri, nsIPermissionManager.ALLOW_ACTION, "cookie");
|
||||
setRadioButton("AllowSessionCookies", uri, ALLOW_SESSION_ONLY, "cookie");
|
||||
setRadioButton("AllowSessionCookies", uri, nsICookiePermission.ACCESS_SESSION, "cookie");
|
||||
setRadioButton("BlockCookies", uri, nsIPermissionManager.DENY_ACTION, "cookie");
|
||||
setRadioButton("UseImagesDefault", uri, nsIPermissionManager.UNKNOWN_ACTION, "image");
|
||||
setRadioButton("AllowImages", uri, nsIPermissionManager.ALLOW_ACTION, "image");
|
||||
|
@ -124,9 +121,9 @@
|
|||
element = document.getElementById("AllowCookies");
|
||||
break;
|
||||
case "cookieSession":
|
||||
if (permissionmanager.testPermission(uri, "cookie") == ALLOW_SESSION_ONLY)
|
||||
if (permissionmanager.testPermission(uri, "cookie") == nsICookiePermission.ACCESS_SESSION)
|
||||
return;
|
||||
permissionmanager.add(uri, "cookie", ALLOW_SESSION_ONLY);
|
||||
permissionmanager.add(uri, "cookie", nsICookiePermission.ACCESS_SESSION);
|
||||
element = document.getElementById("AllowSessionCookies");
|
||||
break;
|
||||
case "cookieDefault":
|
||||
|
|
Загрузка…
Ссылка в новой задаче