diff --git a/extensions/cookie/nsPopupWindowManager.cpp b/extensions/cookie/nsPopupWindowManager.cpp index e4699e5411ef..237e36517475 100644 --- a/extensions/cookie/nsPopupWindowManager.cpp +++ b/extensions/cookie/nsPopupWindowManager.cpp @@ -54,9 +54,11 @@ */ #define POLICYSTRING "policy" +#define CUSTOMSTRING "usecustom" static const char *sPopupPrefRoot = "privacy.popups."; -static const char *sPopupPrefLeaf = POLICYSTRING; +static const char *sPopupPrefPolicyLeaf = POLICYSTRING; +static const char *sPopupPrefCustomLeaf = CUSTOMSTRING; static const char *sPermissionChangeNotification = PPM_CHANGE_NOTIFICATION; static const char *sXPCOMShutdownTopic = NS_XPCOM_SHUTDOWN_OBSERVER_ID; static const char *sPrefChangedTopic = NS_PREFBRANCH_PREFCHANGE_TOPIC_ID; @@ -66,7 +68,8 @@ static const char *sPrefChangedTopic = NS_PREFBRANCH_PREFCHANGE_TOPIC_ID; //***************************************************************************** nsPopupWindowManager::nsPopupWindowManager() : - mPopupPerm(eAllow) + mPolicy(eAllow), + mCustomPermissions(PR_FALSE) { NS_INIT_ISUPPORTS(); } @@ -93,6 +96,8 @@ nsPopupWindowManager::Init() // initialize our local copy of the pref Observe(NS_STATIC_CAST(nsIPopupWindowManager *, this), sPrefChangedTopic, NS_LITERAL_STRING(POLICYSTRING).get()); + Observe(NS_STATIC_CAST(nsIPopupWindowManager *, this), + sPrefChangedTopic, NS_LITERAL_STRING(CUSTOMSTRING).get()); return ObserveThings(); } return NS_ERROR_FAILURE; @@ -105,14 +110,14 @@ nsPopupWindowManager::Init() NS_IMETHODIMP nsPopupWindowManager::GetDefaultPermission(PRUint32 *aDefaultPermission) { - return eDisallow; + return eAllow; } NS_IMETHODIMP nsPopupWindowManager::SetDefaultPermission(PRUint32 aDefaultPermission) { - NS_ASSERTION(aDefaultPermission == eDisallow, "whitelist not supported"); - return aDefaultPermission == eDisallow ? NS_OK : NS_ERROR_FAILURE; + NS_ASSERTION(aDefaultPermission == eAllow, "whitelist not supported"); + return aDefaultPermission == eAllow ? NS_OK : NS_ERROR_FAILURE; } /* Note: since we don't support whitelists, Add(uri, true) is the same thing @@ -173,9 +178,9 @@ nsPopupWindowManager::TestPermission(nsIURI *aURI, PRUint32 *_retval) NS_ENSURE_ARG_POINTER(aURI); NS_ENSURE_ARG_POINTER(_retval); - *_retval = mPopupPerm; + *_retval = mPolicy; - if (mPopupPerm == eAllowConditionally) { + if (mPolicy == eAllow && mCustomPermissions) { if (mPermManager) { /* Because of a bug/quirk/something in the PermissionManager the value of blockDomain will be left unchanged if the URI @@ -188,8 +193,7 @@ nsPopupWindowManager::TestPermission(nsIURI *aURI, PRUint32 *_retval) nsCAutoString uri; aURI->GetPrePath(uri); mPermManager->TestForBlocking(uri, WINDOWPERMISSION, &blockDomain); - if (blockDomain) - *_retval = eDisallow; + *_retval = blockDomain ? eDisallow : eAllowConditionally; } } return NS_OK; @@ -228,16 +232,19 @@ nsPopupWindowManager::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) { if (nsCRT::strcmp(aTopic, sPrefChangedTopic) == 0 && - NS_LITERAL_STRING(POLICYSTRING).Equals(aData)) { + (NS_LITERAL_STRING(POLICYSTRING).Equals(aData) || + NS_LITERAL_STRING(CUSTOMSTRING).Equals(aData))) { // refresh our local copy of the "allow popups" pref - mPopupPerm = eAllow; + PRInt32 perm = eAllow; + PRBool custom = PR_FALSE; if (mPopupPrefBranch) { - PRInt32 perm = eAllow; - mPopupPrefBranch->GetIntPref(sPopupPrefLeaf, &perm); + mPopupPrefBranch->GetIntPref(sPopupPrefPolicyLeaf, &perm); + mPopupPrefBranch->GetBoolPref(sPopupPrefCustomLeaf, &custom); NS_ASSERTION(perm >= 0, "popup pref value out of range"); - mPopupPerm = NS_STATIC_CAST(PRUint32, perm); } + mPolicy = NS_STATIC_CAST(PRUint32, perm); + mCustomPermissions = custom; } else if (nsCRT::strcmp(aTopic, sXPCOMShutdownTopic) == 0) { // unhook cyclical references StopObservingThings(); @@ -262,8 +269,10 @@ nsPopupWindowManager::ObserveThings() if (NS_SUCCEEDED(rv)) { nsCOMPtr ibranch(do_QueryInterface(mPopupPrefBranch)); - if (ibranch) - rv = ibranch->AddObserver(sPopupPrefLeaf, this, PR_FALSE); + if (ibranch) { + ibranch->AddObserver(sPopupPrefPolicyLeaf, this, PR_FALSE); + rv = ibranch->AddObserver(sPopupPrefCustomLeaf, this, PR_FALSE); + } } return rv; @@ -274,8 +283,10 @@ nsresult nsPopupWindowManager::StopObservingThings() { nsCOMPtr ibranch(do_QueryInterface(mPopupPrefBranch)); - if (ibranch) - ibranch->RemoveObserver(sPopupPrefLeaf, this); + if (ibranch) { + ibranch->RemoveObserver(sPopupPrefPolicyLeaf, this); + ibranch->RemoveObserver(sPopupPrefCustomLeaf, this); + } if (mOS) mOS->RemoveObserver(this, sXPCOMShutdownTopic); diff --git a/extensions/cookie/nsPopupWindowManager.h b/extensions/cookie/nsPopupWindowManager.h index 038e3aff16cc..442634f5ea6b 100644 --- a/extensions/cookie/nsPopupWindowManager.h +++ b/extensions/cookie/nsPopupWindowManager.h @@ -64,7 +64,8 @@ private: nsresult NotifyObservers(); void DeInitialize(); - PRUint32 mPopupPerm; + PRUint32 mPolicy; + PRBool mCustomPermissions; nsCOMPtr mOS; nsCOMPtr mPermManager; nsCOMPtr mPopupPrefBranch; diff --git a/extensions/cookie/resources/content/cookieNavigatorOverlay.xul b/extensions/cookie/resources/content/cookieNavigatorOverlay.xul index a33585d104cc..3bc725135d31 100644 --- a/extensions/cookie/resources/content/cookieNavigatorOverlay.xul +++ b/extensions/cookie/resources/content/cookieNavigatorOverlay.xul @@ -131,7 +131,7 @@ try { var hide = pref.getBoolPref("dom.disable_open_during_load"); if (!hide) - hide = pref.getIntPref("privacy.popups.policy") != Components.interfaces.nsIPopupWindowManager.eAllowConditionally; + hide = pref.getIntPref("privacy.popups.policy") != Components.interfaces.nsIPopupWindowManager.eAllow || !pref.getBoolPref("privacy.popups.usecustom"); HidePopups(hide); } catch(e) { HidePopups(true); diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index cf940c60738c..5aff278d2c95 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -378,8 +378,9 @@ pref("javascript.allow.mailnews", false); pref("javascript.options.strict", false); pref("javascript.options.showInConsole", true); -// popups.policy values are in nsIPopupWindowManager.idl +// popups.policy 1=allow,2=reject pref("privacy.popups.policy", 1); +pref("privacy.popups.usecustom", false); // advanced prefs pref("advanced.always_load_images", true); diff --git a/xpfe/components/permissions/content/permissionsNavigatorOverlay.xul b/xpfe/components/permissions/content/permissionsNavigatorOverlay.xul index a33585d104cc..3bc725135d31 100644 --- a/xpfe/components/permissions/content/permissionsNavigatorOverlay.xul +++ b/xpfe/components/permissions/content/permissionsNavigatorOverlay.xul @@ -131,7 +131,7 @@ try { var hide = pref.getBoolPref("dom.disable_open_during_load"); if (!hide) - hide = pref.getIntPref("privacy.popups.policy") != Components.interfaces.nsIPopupWindowManager.eAllowConditionally; + hide = pref.getIntPref("privacy.popups.policy") != Components.interfaces.nsIPopupWindowManager.eAllow || !pref.getBoolPref("privacy.popups.usecustom"); HidePopups(hide); } catch(e) { HidePopups(true);