зеркало из https://github.com/mozilla/gecko-dev.git
switching to the new, final(!?) popup window management preferences organisation. bug 166442 r=jag,jst
This commit is contained in:
Родитель
600a663b4a
Коммит
52f1d992ef
|
@ -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<nsIPrefBranchInternal> 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<nsIPrefBranchInternal> 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);
|
||||
|
|
|
@ -64,7 +64,8 @@ private:
|
|||
nsresult NotifyObservers();
|
||||
void DeInitialize();
|
||||
|
||||
PRUint32 mPopupPerm;
|
||||
PRUint32 mPolicy;
|
||||
PRBool mCustomPermissions;
|
||||
nsCOMPtr<nsIObserverService> mOS;
|
||||
nsCOMPtr<nsIPermissionManager> mPermManager;
|
||||
nsCOMPtr<nsIPrefBranch> mPopupPrefBranch;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче