зеркало из https://github.com/mozilla/gecko-dev.git
Bug 209475: Make nsIPermissionManager more flexible for extensions.
Changes nsIPermissionManager.idl to accept type strings rather than integers; this allows consumers to register unique types more easily, without fear of conflicting with an already-existing one. Also fixes some bounds-checking fu (sr=bz on irc for those additional portions). patch by mvl; r=dwitte, sr=bz.
This commit is contained in:
Родитель
41a72493a2
Коммит
ee64b32c3e
|
@ -149,9 +149,9 @@ const int kDisableAllCookies = 2;
|
|||
permEnum->GetNext(getter_AddRefs(curr));
|
||||
nsCOMPtr<nsIPermission> currPerm(do_QueryInterface(curr));
|
||||
if ( currPerm ) {
|
||||
PRUint32 type = nsIPermissionManager::COOKIE_TYPE;
|
||||
currPerm->GetType(&type);
|
||||
if ( type == nsIPermissionManager::COOKIE_TYPE )
|
||||
nsCAutoString type;
|
||||
currPerm->GetType(type);
|
||||
if ( type.Equals(NS_LITERAL_CSTRING("cookie")) )
|
||||
mCachedPermissions->AppendElement(curr);
|
||||
}
|
||||
permEnum->HasMoreElements(&hasMoreElements);
|
||||
|
@ -204,7 +204,7 @@ const int kDisableAllCookies = 2;
|
|||
if ( perm ) {
|
||||
nsCAutoString host;
|
||||
perm->GetHost(host);
|
||||
mManager->Remove(host, nsIPermissionManager::COOKIE_TYPE); // could this api _be_ any worse? Come on!
|
||||
mManager->Remove(host, "cookie"); // could this api _be_ any worse? Come on!
|
||||
|
||||
mCachedPermissions->RemoveElementAt(row);
|
||||
}
|
||||
|
|
|
@ -124,9 +124,9 @@
|
|||
permEnum->GetNext(getter_AddRefs(curr));
|
||||
nsCOMPtr<nsIPermission> currPerm(do_QueryInterface(curr));
|
||||
if ( currPerm ) {
|
||||
PRUint32 type = nsIPermissionManager::POPUP_TYPE;
|
||||
currPerm->GetType(&type);
|
||||
if ( type == nsIPermissionManager::POPUP_TYPE )
|
||||
nsCAutoString type;
|
||||
currPerm->GetType(type);
|
||||
if ( type.Equals(NS_LITERAL_CSTRING("popup")) )
|
||||
inPermissions->AppendElement(curr);
|
||||
}
|
||||
permEnum->HasMoreElements(&hasMoreElements);
|
||||
|
@ -187,7 +187,7 @@
|
|||
if ( perm ) {
|
||||
nsCAutoString host;
|
||||
perm->GetHost(host);
|
||||
mManager->Remove(host, nsIPermissionManager::POPUP_TYPE); // could this api _be_ any worse? Come on!
|
||||
mManager->Remove(host, "popup"); // could this api _be_ any worse? Come on!
|
||||
|
||||
mCachedPermissions->RemoveElementAt(row);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@
|
|||
nsCOMPtr<nsIURI> newURI;
|
||||
NS_NewURI(getter_AddRefs(newURI), siteURL);
|
||||
if ( newURI ) {
|
||||
mManager->Add(newURI, nsIPermissionManager::POPUP_TYPE, nsIPermissionManager::ALLOW_ACTION);
|
||||
mManager->Add(newURI, "popup", nsIPermissionManager::ALLOW_ACTION);
|
||||
mCachedPermissions->Clear();
|
||||
[self populatePermissionCache:mCachedPermissions];
|
||||
|
||||
|
|
|
@ -2448,7 +2448,7 @@ static NSArray* sToolbarDefaults = nil;
|
|||
nsCOMPtr<nsIURI> uri = do_QueryInterface(genUri);
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> pm ( do_GetService(NS_PERMISSIONMANAGER_CONTRACTID) );
|
||||
pm->Add(uri, nsIPermissionManager::POPUP_TYPE, nsIPermissionManager::ALLOW_ACTION);
|
||||
pm->Add(uri, "popup", nsIPermissionManager::ALLOW_ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2470,7 +2470,7 @@ static NSArray* sToolbarDefaults = nil;
|
|||
for ( PRUint32 i = 0; i < count; ++i ) {
|
||||
nsCOMPtr<nsISupports> genUri = dont_AddRef(blockedSites->ElementAt(i));
|
||||
nsCOMPtr<nsIURI> uri = do_QueryInterface(genUri);
|
||||
pm->Add(uri, nsIPermissionManager::POPUP_TYPE, nsIPermissionManager::ALLOW_ACTION);
|
||||
pm->Add(uri, "popup", nsIPermissionManager::ALLOW_ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ nsCookiePermission::TestPermission(nsIURI *aURI,
|
|||
|
||||
PRUint32 listPermission = nsIPermissionManager::UNKNOWN_ACTION;
|
||||
if (mPermissionManager) {
|
||||
mPermissionManager->TestPermission(aURI, nsIPermissionManager::COOKIE_TYPE, &listPermission);
|
||||
mPermissionManager->TestPermission(aURI, "cookie", &listPermission);
|
||||
}
|
||||
|
||||
if (listPermission == nsIPermissionManager::UNKNOWN_ACTION) {
|
||||
|
@ -111,7 +111,7 @@ nsCookiePermission::TestPermission(nsIURI *aURI,
|
|||
|
||||
if (rememberDecision && mPermissionManager) {
|
||||
// Remember this decision
|
||||
mPermissionManager->Add(aURI, nsIPermissionManager::COOKIE_TYPE,
|
||||
mPermissionManager->Add(aURI, "cookie",
|
||||
*aPermission ? nsIPermissionManager::ALLOW_ACTION : nsIPermissionManager::DENY_ACTION);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1178,9 +1178,7 @@ nsCookieService::Remove(const nsACString &aHost,
|
|||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
permissionManager->Add(uri,
|
||||
nsIPermissionManager::COOKIE_TYPE,
|
||||
nsIPermissionManager::DENY_ACTION);
|
||||
permissionManager->Add(uri, "cookie", nsIPermissionManager::DENY_ACTION);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,10 +37,13 @@ interface nsIPermission : nsISupports
|
|||
readonly attribute AUTF8String host;
|
||||
|
||||
/**
|
||||
* The type of permission (e.g., cookie, image, etc)
|
||||
* (see nsIPermissionManager.idl for allowed values)
|
||||
* a case-sensitive ASCII string, indicating the type of permission
|
||||
* (e.g., "cookie", "image", etc).
|
||||
* This string is specified by the consumer when adding a permission
|
||||
* via nsIPermissionManager.
|
||||
* @see nsIPermissionManager
|
||||
*/
|
||||
readonly attribute PRUint32 type;
|
||||
readonly attribute ACString type;
|
||||
|
||||
/**
|
||||
* The permission (see nsIPermissionManager.idl for allowed values)
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
|
||||
/**
|
||||
* This file contains an interface to the Permission Manager,
|
||||
* used for blocking objects (cookies, images etc) from
|
||||
* used-defined sites
|
||||
* used to persistenly store permissions for different object types (cookies,
|
||||
* images etc) on a site-by-site basis.
|
||||
*
|
||||
* This service broadcasts a PERM_CHANGE_NOTIFICATION notification
|
||||
* when any permission changes. You can add yourself as an observer.
|
||||
|
@ -55,37 +55,48 @@ interface nsIObserver;
|
|||
interface nsIPermissionManager : nsISupports
|
||||
{
|
||||
/**
|
||||
* Allowed return values from the testPermission method
|
||||
* Predefined return values for the testPermission method and for
|
||||
* the permission param of the add method
|
||||
*/
|
||||
const PRUint32 UNKNOWN_ACTION = 0;
|
||||
const PRUint32 ALLOW_ACTION = 1;
|
||||
const PRUint32 DENY_ACTION = 2;
|
||||
|
||||
/**
|
||||
* These values are the different types of permissions supported
|
||||
*/
|
||||
const PRUint32 COOKIE_TYPE = 0;
|
||||
const PRUint32 IMAGE_TYPE = 1;
|
||||
const PRUint32 POPUP_TYPE = 2;
|
||||
|
||||
/**
|
||||
* Add permission information for a given URI and permission type.
|
||||
* @param uri is the website to add the permission for
|
||||
* @param permission is one of the enumerated permission actions above
|
||||
* @param type is one of the enumerated permission types above
|
||||
* Add permission information for a given URI and permission type. This
|
||||
* operation will cause the type string to be registered if it does not
|
||||
* currently exist.
|
||||
*
|
||||
* @param uri the uri to add the permission for
|
||||
* @param type a case-sensitive ASCII string, identifying the consumer.
|
||||
* Consumers should choose this string to be unique, with
|
||||
* respect to other consumers. The number of unique type
|
||||
* indentifiers may be limited.
|
||||
* @param permission an integer from 1 to 15, representing the desired
|
||||
* action (e.g. allow or deny). The interpretation of
|
||||
* this number is up to the consumer, and may represent
|
||||
* different actions for different types. Consumers may
|
||||
* use one of the enumerated permission actions defined
|
||||
* above. 0 is reserved for UNKNOWN_ACTION, and shouldn't
|
||||
* be used.
|
||||
* @throws NS_ERROR_FAILURE if there is no more room for adding
|
||||
* a new type
|
||||
*/
|
||||
void add(in nsIURI uri,
|
||||
in PRUint32 type,
|
||||
in string type,
|
||||
in PRUint32 permission);
|
||||
|
||||
/**
|
||||
* Remove permission information for a given URI and permission type.
|
||||
* Note that this method takes a host string, not an nsIURI.
|
||||
* @param host is the host to remove the permission for
|
||||
* @param type is one of the enumerated permission types above
|
||||
*
|
||||
* @param host the host to remove the permission for
|
||||
* @param type a case-sensitive ASCII string, identifying the consumer.
|
||||
* The type must have been previously registered using the
|
||||
* add() method.
|
||||
*/
|
||||
void remove(in AUTF8String host,
|
||||
in PRUint32 type);
|
||||
in string type);
|
||||
|
||||
/**
|
||||
* Clear permission information for all websites.
|
||||
|
@ -94,12 +105,13 @@ interface nsIPermissionManager : nsISupports
|
|||
|
||||
/**
|
||||
* Test whether a website has permission to perform the given action.
|
||||
* @param uri the website to be tested
|
||||
* @param type one of the enumerated types above
|
||||
* @return one of the enumerated permission actions above
|
||||
* @param uri the uri to be tested
|
||||
* @param type a case-sensitive ASCII string, identifying the consumer
|
||||
* @param return see add(), param permission. returns UNKNOWN_ACTION when
|
||||
* there is no stored permission for this uri and / or type.
|
||||
*/
|
||||
PRUint32 testPermission(in nsIURI uri,
|
||||
in PRUint32 type);
|
||||
in string type);
|
||||
|
||||
/**
|
||||
* Allows enumeration of all stored permissions
|
||||
|
|
|
@ -270,11 +270,11 @@ nsImgManager::TestPermission(nsIURI *aCurrentURI,
|
|||
|
||||
if (mPermissionManager) {
|
||||
PRUint32 temp;
|
||||
mPermissionManager->TestPermission(aCurrentURI, nsIPermissionManager::IMAGE_TYPE, &temp);
|
||||
mPermissionManager->TestPermission(aCurrentURI, "image", &temp);
|
||||
// Blacklist for now
|
||||
*aPermission = (temp != nsIPermissionManager::DENY_ACTION);
|
||||
} else {
|
||||
// no premission manager, return ok
|
||||
// no permission manager, return ok
|
||||
*aPermission = PR_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
NS_IMPL_ISUPPORTS1(nsPermission, nsIPermission)
|
||||
|
||||
nsPermission::nsPermission(const nsACString &aHost,
|
||||
PRUint32 aType,
|
||||
const nsACString &aType,
|
||||
PRUint32 aCapability)
|
||||
: mHost(aHost)
|
||||
, mType(aType)
|
||||
|
@ -63,9 +63,9 @@ nsPermission::GetHost(nsACString &aHost)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermission::GetType(PRUint32 *aType)
|
||||
nsPermission::GetType(nsACString &aType)
|
||||
{
|
||||
*aType = mType;
|
||||
aType = mType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,12 +51,12 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPERMISSION
|
||||
|
||||
nsPermission(const nsACString &aHost, PRUint32 aType, PRUint32 aCapability);
|
||||
nsPermission(const nsACString &aHost, const nsACString &aType, PRUint32 aCapability);
|
||||
virtual ~nsPermission();
|
||||
|
||||
protected:
|
||||
nsCString mHost;
|
||||
PRUint32 mType;
|
||||
nsCString mType;
|
||||
PRUint32 mCapability;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Michiel van Leeuwen (mvl@exedo.nl)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -79,26 +79,6 @@ nsHostEntry::nsHostEntry(const nsHostEntry& toCopy)
|
|||
mHost = ArenaStrDup(toCopy.mHost, gHostArena);
|
||||
}
|
||||
|
||||
inline void
|
||||
nsHostEntry::SetPermission(PRUint32 aType, PRUint32 aPermission)
|
||||
{
|
||||
mPermissions[aType] = (PRUint8)aPermission;
|
||||
}
|
||||
|
||||
inline PRUint32
|
||||
nsHostEntry::GetPermission(PRUint32 aType) const
|
||||
{
|
||||
return (PRUint32)mPermissions[aType];
|
||||
}
|
||||
|
||||
inline PRBool
|
||||
nsHostEntry::PermissionsAreEmpty() const
|
||||
{
|
||||
// Cast to PRUint32, to make this faster. Only 2 checks instead of 8
|
||||
return (*NS_REINTERPRET_CAST(const PRUint32*, &mPermissions[0])==0 &&
|
||||
*NS_REINTERPRET_CAST(const PRUint32*, &mPermissions[4])==0 );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsPermissionEnumerator : public nsISimpleEnumerator
|
||||
|
@ -106,12 +86,16 @@ class nsPermissionEnumerator : public nsISimpleEnumerator
|
|||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsPermissionEnumerator(const nsTHashtable<nsHostEntry> *aHostTable, const char* *aHostList, const PRUint32 aHostCount)
|
||||
nsPermissionEnumerator(const nsTHashtable<nsHostEntry> *aHostTable,
|
||||
const char* *aHostList,
|
||||
const PRUint32 aHostCount,
|
||||
const char* *aTypeArray)
|
||||
: mHostCount(aHostCount),
|
||||
mHostIndex(0),
|
||||
mTypeIndex(0),
|
||||
mHostTable(aHostTable),
|
||||
mHostList(aHostList)
|
||||
mHostList(aHostList),
|
||||
mTypeArray(aTypeArray)
|
||||
{
|
||||
Prefetch();
|
||||
}
|
||||
|
@ -150,6 +134,7 @@ class nsPermissionEnumerator : public nsISimpleEnumerator
|
|||
const nsTHashtable<nsHostEntry> *mHostTable;
|
||||
const char* *mHostList;
|
||||
nsCOMPtr<nsIPermission> mNextPermission;
|
||||
const char* *mTypeArray;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPermissionEnumerator, nsISimpleEnumerator)
|
||||
|
@ -171,7 +156,9 @@ nsPermissionEnumerator::Prefetch()
|
|||
// see if we've found it
|
||||
permission = entry->GetPermission(mTypeIndex);
|
||||
if (permission != nsIPermissionManager::UNKNOWN_ACTION) {
|
||||
mNextPermission = new nsPermission(entry->GetHost(), mTypeIndex, permission);
|
||||
mNextPermission = new nsPermission(entry->GetHost(),
|
||||
nsDependentCString(mTypeArray[mTypeIndex]),
|
||||
permission);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,6 +186,7 @@ nsPermissionManager::nsPermissionManager()
|
|||
|
||||
nsPermissionManager::~nsPermissionManager()
|
||||
{
|
||||
RemoveTypeStrings();
|
||||
RemoveAllFromMemory();
|
||||
}
|
||||
|
||||
|
@ -216,6 +204,9 @@ nsresult nsPermissionManager::Init()
|
|||
rv = mPermissionsFile->AppendNative(NS_LITERAL_CSTRING(kPermissionsFileName));
|
||||
}
|
||||
|
||||
// Clear the array of type strings
|
||||
memset(mTypeArray, nsnull, sizeof(mTypeArray));
|
||||
|
||||
// Ignore an error. That is not a problem. No cookperm.txt usually.
|
||||
Read();
|
||||
|
||||
|
@ -229,9 +220,9 @@ nsresult nsPermissionManager::Init()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermissionManager::Add(nsIURI *aURI,
|
||||
PRUint32 aType,
|
||||
PRUint32 aPermission)
|
||||
nsPermissionManager::Add(nsIURI *aURI,
|
||||
const char *aType,
|
||||
PRUint32 aPermission)
|
||||
{
|
||||
NS_ASSERTION(aURI, "could not get uri");
|
||||
nsresult rv;
|
||||
|
@ -243,7 +234,11 @@ nsPermissionManager::Add(nsIURI *aURI,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = AddInternal(hostPort, aType, aPermission);
|
||||
PRInt32 typeIndex = GetTypeIndex(aType, PR_TRUE);
|
||||
if (typeIndex == -1 || aPermission >= NUMBER_OF_PERMISSIONS)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = AddInternal(hostPort, typeIndex, aPermission);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Notify permission manager dialog to update its display
|
||||
|
@ -257,16 +252,13 @@ nsPermissionManager::Add(nsIURI *aURI,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//Only add to memory, don't save. That's up to the caller.
|
||||
// This only adds a permission to memory (it doesn't save to disk), and doesn't
|
||||
// bounds check aTypeIndex or aPermission. These are up to the caller.
|
||||
nsresult
|
||||
nsPermissionManager::AddInternal(const nsAFlatCString &aHost,
|
||||
PRUint32 aType,
|
||||
PRInt32 aTypeIndex,
|
||||
PRUint32 aPermission)
|
||||
{
|
||||
if (aType > NUMBER_OF_TYPES) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!gHostArena) {
|
||||
gHostArena = new PLArenaPool;
|
||||
if (!gHostArena)
|
||||
|
@ -282,22 +274,23 @@ nsPermissionManager::AddInternal(const nsAFlatCString &aHost,
|
|||
if (entry->PermissionsAreEmpty()) {
|
||||
++mHostCount;
|
||||
}
|
||||
entry->SetPermission(aType, aPermission);
|
||||
entry->SetPermission(aTypeIndex, aPermission);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermissionManager::Remove(const nsACString &aHost,
|
||||
PRUint32 aType)
|
||||
const char *aType)
|
||||
{
|
||||
if (aType > NUMBER_OF_TYPES) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
PRInt32 typeIndex = GetTypeIndex(aType, PR_FALSE);
|
||||
// If type == -1, the type isn't known,
|
||||
// so just return NS_OK
|
||||
if (typeIndex == -1) return NS_OK;
|
||||
|
||||
nsHostEntry* entry = mHostTable.GetEntry(PromiseFlatCString(aHost).get());
|
||||
if (entry) {
|
||||
entry->SetPermission(aType, nsIPermissionManager::UNKNOWN_ACTION);
|
||||
entry->SetPermission(typeIndex, nsIPermissionManager::UNKNOWN_ACTION);
|
||||
|
||||
// If no more types are present, remove the entry
|
||||
if (entry->PermissionsAreEmpty()) {
|
||||
|
@ -322,9 +315,9 @@ nsPermissionManager::RemoveAll()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermissionManager::TestPermission(nsIURI *aURI,
|
||||
PRUint32 aType,
|
||||
PRUint32 *aPermission)
|
||||
nsPermissionManager::TestPermission(nsIURI *aURI,
|
||||
const char *aType,
|
||||
PRUint32 *aPermission)
|
||||
{
|
||||
NS_ASSERTION(aURI, "could not get uri");
|
||||
NS_ASSERTION(aPermission, "no permission pointer");
|
||||
|
@ -339,15 +332,16 @@ nsPermissionManager::TestPermission(nsIURI *aURI,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aType > NUMBER_OF_TYPES) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
PRInt32 typeIndex = GetTypeIndex(aType, PR_FALSE);
|
||||
// If type == -1, the type isn't known,
|
||||
// so just return NS_OK
|
||||
if (typeIndex == -1) return NS_OK;
|
||||
|
||||
PRUint32 offset = 0;
|
||||
do {
|
||||
nsHostEntry *entry = mHostTable.GetEntry(hostPort.get() + offset);
|
||||
if (entry) {
|
||||
*aPermission = entry->GetPermission(aType);
|
||||
*aPermission = entry->GetPermission(typeIndex);
|
||||
if (*aPermission != nsIPermissionManager::UNKNOWN_ACTION)
|
||||
break;
|
||||
}
|
||||
|
@ -392,7 +386,7 @@ NS_IMETHODIMP nsPermissionManager::GetEnumerator(nsISimpleEnumerator **aEnum)
|
|||
const char** hostListCopy = hostList;
|
||||
mHostTable.EnumerateEntries(AddHostToList, &hostListCopy);
|
||||
|
||||
nsPermissionEnumerator* permissionEnum = new nsPermissionEnumerator(&mHostTable, hostList, mHostCount);
|
||||
nsPermissionEnumerator* permissionEnum = new nsPermissionEnumerator(&mHostTable, hostList, mHostCount, NS_CONST_CAST(const char**, mTypeArray));
|
||||
if (!permissionEnum) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -416,7 +410,9 @@ NS_IMETHODIMP nsPermissionManager::Observe(nsISupports *aSubject, const char *aT
|
|||
// was accepted). If this condition ever changes, the permission
|
||||
// file would need to be updated here.
|
||||
|
||||
RemoveTypeStrings();
|
||||
RemoveAllFromMemory();
|
||||
|
||||
if (!nsCRT::strcmp(someData, NS_LITERAL_STRING("shutdown-cleanse").get()))
|
||||
if (mPermissionsFile) {
|
||||
mPermissionsFile->Remove(PR_FALSE);
|
||||
|
@ -455,6 +451,50 @@ nsPermissionManager::RemoveAllFromMemory()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsPermissionManager::RemoveTypeStrings()
|
||||
{
|
||||
for (PRUint32 i = NUMBER_OF_TYPES; i--; ) {
|
||||
if (mTypeArray[i]) {
|
||||
PL_strfree(mTypeArray[i]);
|
||||
mTypeArray[i] = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns -1 on failure
|
||||
PRInt32
|
||||
nsPermissionManager::GetTypeIndex(const char *aType,
|
||||
PRBool aAdd)
|
||||
{
|
||||
PRInt32 firstEmpty = -1;
|
||||
|
||||
for (PRUint32 i = 0; i < NUMBER_OF_TYPES; ++i) {
|
||||
if (!mTypeArray[i]) {
|
||||
if (firstEmpty == -1)
|
||||
// Don't break, the type might be later in the array
|
||||
firstEmpty = i;
|
||||
} else if (!strcmp(aType, mTypeArray[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
if (!aAdd || firstEmpty == -1)
|
||||
// Not found, but that is ok - we were just looking.
|
||||
// Or, no free spots left - error.
|
||||
return -1;
|
||||
|
||||
// This type was not registered before.
|
||||
// Can't use ToNewCString here, other strings in the array are allocated
|
||||
// with PL_strdup too, and they all need to be freed the same way
|
||||
mTypeArray[firstEmpty] = PL_strdup(aType);
|
||||
if (!mTypeArray[firstEmpty])
|
||||
return -1;
|
||||
|
||||
return firstEmpty;
|
||||
}
|
||||
|
||||
|
||||
// broadcast a notification that a permission has changed
|
||||
nsresult
|
||||
nsPermissionManager::NotifyObservers(const nsACString &aHost)
|
||||
|
@ -472,6 +512,13 @@ nsPermissionManager::NotifyObservers(const nsACString &aHost)
|
|||
// When a consumer wants it back, that is up to the consumer, not this backend
|
||||
// For cookies, it is now done with a persist in the dialog xul file.
|
||||
|
||||
static const char kTab = '\t';
|
||||
static const char kNew = '\n';
|
||||
static const char kTrue = 'T';
|
||||
static const char kFalse = 'F';
|
||||
static const char kFirstLetter = 'a';
|
||||
static const char kTypeSign = '%';
|
||||
|
||||
nsresult
|
||||
nsPermissionManager::Read()
|
||||
{
|
||||
|
@ -491,6 +538,8 @@ nsPermissionManager::Read()
|
|||
/* format is:
|
||||
* host \t number permission \t number permission ... \n
|
||||
* if this format isn't respected we move onto the next line in the file.
|
||||
* permission is T or F for accept or deny, otherwise a lowercase letter,
|
||||
* with a=0, b=1 etc
|
||||
*/
|
||||
|
||||
nsAutoString bufferUnicode;
|
||||
|
@ -503,6 +552,24 @@ nsPermissionManager::Read()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (buffer.First() == kTypeSign) {
|
||||
// A permission string line
|
||||
|
||||
PRInt32 stringIndex;
|
||||
|
||||
if ((stringIndex = buffer.FindChar(kTab) + 1) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PRUint32 type;
|
||||
if (!PR_sscanf(buffer.get() + 1, "%u", &type) || type >= NUMBER_OF_TYPES) {
|
||||
continue;
|
||||
}
|
||||
mTypeArray[type] = PL_strdup(buffer.get() + stringIndex);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
PRInt32 hostIndex, permissionIndex;
|
||||
PRUint32 nextPermissionIndex = 0;
|
||||
hostIndex = 0;
|
||||
|
@ -525,13 +592,13 @@ nsPermissionManager::Read()
|
|||
if (nextPermissionIndex == buffer.Length()+1) {
|
||||
break;
|
||||
}
|
||||
if ((nextPermissionIndex = buffer.FindChar('\t', permissionIndex)+1) == 0) {
|
||||
if ((nextPermissionIndex = buffer.FindChar(kTab, permissionIndex) + 1) == 0) {
|
||||
nextPermissionIndex = buffer.Length()+1;
|
||||
}
|
||||
const nsASingleFragmentCString &permissionString = Substring(buffer, permissionIndex, nextPermissionIndex - permissionIndex - 1);
|
||||
permissionIndex = nextPermissionIndex;
|
||||
|
||||
PRUint32 type = 0;
|
||||
PRInt32 type = 0;
|
||||
PRUint32 index = 0;
|
||||
|
||||
if (permissionString.IsEmpty()) {
|
||||
|
@ -546,8 +613,18 @@ nsPermissionManager::Read()
|
|||
if (index >= permissionString.Length()) {
|
||||
continue; // bad format for this permission entry
|
||||
}
|
||||
PRUint32 permission = (permissionString.CharAt(index) == 'T') ? nsIPermissionManager::ALLOW_ACTION : nsIPermissionManager::DENY_ACTION;
|
||||
PRUint32 permission;
|
||||
if (permissionString.CharAt(index) == kTrue)
|
||||
permission = nsIPermissionManager::ALLOW_ACTION;
|
||||
else if (permissionString.CharAt(index) == kFalse)
|
||||
permission = nsIPermissionManager::DENY_ACTION;
|
||||
else
|
||||
permission = permissionString.CharAt(index) - kFirstLetter;
|
||||
|
||||
// |permission| is unsigned, so no need to check for < 0
|
||||
if (permission >= NUMBER_OF_PERMISSIONS)
|
||||
continue;
|
||||
|
||||
// Ignore @@@ as host. Old style checkbox status
|
||||
if (!permissionString.IsEmpty() && !host.Equals(NS_LITERAL_CSTRING("@@@@"))) {
|
||||
rv = AddInternal(host, type, permission);
|
||||
|
@ -559,6 +636,11 @@ nsPermissionManager::Read()
|
|||
|
||||
mChangedList = PR_FALSE;
|
||||
|
||||
// For backwards compatibility, add those types when not yet set.
|
||||
if (!mTypeArray[0]) mTypeArray[0] = PL_strdup("cookie");
|
||||
if (!mTypeArray[1]) mTypeArray[1] = PL_strdup("image");
|
||||
if (!mTypeArray[2]) mTypeArray[2] = PL_strdup("popup");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -579,6 +661,7 @@ AddEntryToList(nsHostEntry *entry, void *arg)
|
|||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsPermissionManager::Write()
|
||||
{
|
||||
|
@ -608,13 +691,28 @@ nsPermissionManager::Write()
|
|||
|
||||
bufferedOutputStream->Write(kHeader, sizeof(kHeader) - 1, &rv);
|
||||
|
||||
// Write the type strings.
|
||||
// Format: % index \t typestring \n
|
||||
// (% sign is to distinguish type string lines from permission lines)
|
||||
|
||||
for (PRUint32 i = 0; i < NUMBER_OF_TYPES; ++i) {
|
||||
if (mTypeArray[i]) {
|
||||
bufferedOutputStream->Write(&kTypeSign, 1, &rv);
|
||||
|
||||
char typeNumber[3];
|
||||
PRUint32 len = PR_snprintf(typeNumber, sizeof(typeNumber), "%u", i);
|
||||
bufferedOutputStream->Write(typeNumber, len, &rv);
|
||||
|
||||
bufferedOutputStream->Write(&kTab, 1, &rv);
|
||||
bufferedOutputStream->Write(mTypeArray[i], strlen(mTypeArray[i]), &rv);
|
||||
bufferedOutputStream->Write(&kNew, 1, &rv);
|
||||
}
|
||||
}
|
||||
bufferedOutputStream->Write(&kNew, 1, &rv);
|
||||
|
||||
/* format shall be:
|
||||
* host \t permission \t permission ... \n
|
||||
*/
|
||||
static const char kTab[] = "\t";
|
||||
static const char kNew[] = "\n";
|
||||
static const char kTrue[] = "T";
|
||||
static const char kFalse[] = "F";
|
||||
|
||||
// create a new host list
|
||||
nsHostEntry* *hostList = new nsHostEntry*[mHostCount];
|
||||
|
@ -635,20 +733,24 @@ nsPermissionManager::Write()
|
|||
|
||||
PRUint32 permission = entry->GetPermission(type);
|
||||
if (permission) {
|
||||
bufferedOutputStream->Write(kTab, sizeof(kTab) - 1, &rv);
|
||||
bufferedOutputStream->Write(&kTab, 1, &rv);
|
||||
|
||||
char typeString[5];
|
||||
PRUint32 len = PR_snprintf(typeString, sizeof(typeString), "%u", type);
|
||||
PRUint32 len = PR_snprintf(typeString, sizeof(typeString), "%d", type);
|
||||
bufferedOutputStream->Write(typeString, len, &rv);
|
||||
|
||||
if (permission == nsIPermissionManager::ALLOW_ACTION) {
|
||||
bufferedOutputStream->Write(kTrue, sizeof(kTrue) - 1, &rv);
|
||||
bufferedOutputStream->Write(&kTrue, 1, &rv);
|
||||
} else if (permission == nsIPermissionManager::DENY_ACTION) {
|
||||
bufferedOutputStream->Write(kFalse, sizeof(kFalse) - 1, &rv);
|
||||
bufferedOutputStream->Write(&kFalse, 1, &rv);
|
||||
} else {
|
||||
char permString[2];
|
||||
PR_snprintf(permString, sizeof(permString), "%c", kFirstLetter + permission);
|
||||
bufferedOutputStream->Write(permString, 1, &rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
bufferedOutputStream->Write(kNew, sizeof(kNew) - 1, &rv);
|
||||
bufferedOutputStream->Write(&kNew, 1, &rv);
|
||||
}
|
||||
|
||||
delete[] hostList;
|
||||
|
|
|
@ -52,10 +52,15 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This allow us 8 types of permissions, with 256 values for each
|
||||
// permission. (Some types might want to prompt, block 3rd party etc)
|
||||
// permission (some types might want to prompt, block 3rd party etc).
|
||||
// Note that nsIPermissionManager.idl only allows 16 values for permission,
|
||||
// and that nsPermissionManager::Write() can only deal with 26 values of
|
||||
// permission safely. (We allow space for 256 here, since it's faster to
|
||||
// deal with bytes than with bits).
|
||||
// Note: When changing NUMBER_OF_TYPES, also update PermissionsAreEmpty()
|
||||
// This should be a multiple of 4, to make PermissionsAreEmpty() fast
|
||||
#define NUMBER_OF_TYPES (8)
|
||||
#define NUMBER_OF_TYPES (8)
|
||||
#define NUMBER_OF_PERMISSIONS (16)
|
||||
|
||||
class nsHostEntry : public PLDHashEntryHdr
|
||||
{
|
||||
|
@ -107,9 +112,22 @@ public:
|
|||
}
|
||||
|
||||
// Callers must do boundary checks
|
||||
void SetPermission(PRUint32 aType, PRUint32 aPermission);
|
||||
PRUint32 GetPermission(PRUint32 aType) const;
|
||||
PRBool PermissionsAreEmpty() const;
|
||||
void SetPermission(PRInt32 aTypeIndex, PRUint32 aPermission)
|
||||
{
|
||||
mPermissions[aTypeIndex] = (PRUint8)aPermission;
|
||||
}
|
||||
|
||||
PRUint32 GetPermission(PRInt32 aTypeIndex) const
|
||||
{
|
||||
return (PRUint32)mPermissions[aTypeIndex];
|
||||
}
|
||||
|
||||
PRBool PermissionsAreEmpty() const
|
||||
{
|
||||
// Cast to PRUint32, to make this faster. Only 2 checks instead of 8
|
||||
return (*NS_REINTERPRET_CAST(const PRUint32*, &mPermissions[0])==0 &&
|
||||
*NS_REINTERPRET_CAST(const PRUint32*, &mPermissions[4])==0 );
|
||||
}
|
||||
|
||||
private:
|
||||
const char *mHost;
|
||||
|
@ -141,20 +159,25 @@ public:
|
|||
private:
|
||||
|
||||
nsresult AddInternal(const nsAFlatCString &aHost,
|
||||
PRUint32 aType,
|
||||
PRInt32 aTypeIndex,
|
||||
PRUint32 aPermission);
|
||||
PRInt32 GetTypeIndex(const char *aTypeString,
|
||||
PRBool aAdd);
|
||||
|
||||
nsresult Read();
|
||||
nsresult Write();
|
||||
nsresult NotifyObservers(const nsACString &aHost);
|
||||
nsresult RemoveAllFromMemory();
|
||||
void RemoveTypeStrings();
|
||||
|
||||
nsCOMPtr<nsIObserverService> mObserverService;
|
||||
nsCOMPtr<nsIFile> mPermissionsFile;
|
||||
PRBool mChangedList;
|
||||
nsTHashtable<nsHostEntry> mHostTable;
|
||||
PRUint32 mHostCount;
|
||||
|
||||
|
||||
// An array to store the strings identifying the different types.
|
||||
char *mTypeArray[NUMBER_OF_TYPES];
|
||||
};
|
||||
|
||||
// {4F6B5E00-0C36-11d5-A535-0010A401EB10}
|
||||
|
|
|
@ -127,9 +127,7 @@ nsPopupWindowManager::TestPermission(nsIURI *aURI, PRUint32 *aPermission)
|
|||
PRUint32 permit;
|
||||
|
||||
if (mPermissionManager) {
|
||||
rv = mPermissionManager->TestPermission(aURI,
|
||||
nsIPermissionManager::POPUP_TYPE,
|
||||
&permit);
|
||||
rv = mPermissionManager->TestPermission(aURI, "popup", &permit);
|
||||
|
||||
// Share some constants between interfaces?
|
||||
if (permit == nsIPermissionManager::ALLOW_ACTION) {
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
uri = ioService.newURI(gContextMenu.imageURL, null, null);
|
||||
return permissionmanager.testPermission(uri, nsIPermissionManager.IMAGE_TYPE) != nsIPermissionManager.DENY_ACTION;
|
||||
return permissionmanager.testPermission(uri, "image") != nsIPermissionManager.DENY_ACTION;
|
||||
},
|
||||
|
||||
// Determine if "imageBlocker.enabled" pref is set
|
||||
|
@ -78,9 +78,7 @@
|
|||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
uri = ioService.newURI(gContextMenu.imageURL, null, null);
|
||||
permissionmanager.add(uri,
|
||||
nsIPermissionManager.IMAGE_TYPE,
|
||||
nsIPermissionManager.DENY_ACTION);
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
|
||||
},
|
||||
|
||||
// Unblock image from loading in the future.
|
||||
|
@ -95,9 +93,7 @@
|
|||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
uri = ioService.newURI(gContextMenu.imageURL, null, null);
|
||||
permissionmanager.add(uri,
|
||||
nsIPermissionManager.IMAGE_TYPE,
|
||||
nsIPermissionManager.ALLOW_ACTION);
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.ALLOW_ACTION);
|
||||
},
|
||||
|
||||
initImageBlocking : function () {
|
||||
|
|
|
@ -70,13 +70,11 @@
|
|||
// determine current state (blocked or unblocked) and hide appropriate menu item
|
||||
var blocked = nsIPermissionManager.UNKNOWN_ACTION;
|
||||
|
||||
blocked =
|
||||
permissionmanager.testPermission(uri, nsIPermissionManager.COOKIE_TYPE);
|
||||
blocked = permissionmanager.testPermission(uri, "cookie");
|
||||
enableElement("AllowCookies", blocked != nsIPermissionManager.ALLOW_ACTION);
|
||||
enableElement("BlockCookies", blocked != nsIPermissionManager.DENY_ACTION);
|
||||
|
||||
blocked =
|
||||
permissionmanager.testPermission(uri, nsIPermissionManager.IMAGE_TYPE);
|
||||
blocked = permissionmanager.testPermission(uri, "image");
|
||||
enableElement("AllowImages", blocked != nsIPermissionManager.ALLOW_ACTION);
|
||||
enableElement("BlockImages", blocked != nsIPermissionManager.DENY_ACTION);
|
||||
|
||||
|
@ -106,7 +104,7 @@
|
|||
var blocked = nsIPermissionManager.UNKNOWN_ACTION;
|
||||
var policy = pref.getBoolPref("dom.disable_open_during_load");
|
||||
|
||||
blocked = permissionmanager.testPermission(getBrowser().currentURI, nsIPermissionManager.POPUP_TYPE);
|
||||
blocked = permissionmanager.testPermission(getBrowser().currentURI, "popup");
|
||||
|
||||
document.getElementById("AboutPopups").hidden = policy;
|
||||
document.getElementById("ManagePopups").hidden = !policy;
|
||||
|
@ -138,22 +136,22 @@
|
|||
var uri = getBrowser().currentURI;
|
||||
switch (action) {
|
||||
case "cookieAllow":
|
||||
permissionmanager.add(uri, nsIPermissionManager.COOKIE_TYPE, nsIPermissionManager.ALLOW_ACTION);
|
||||
permissionmanager.add(uri, "cookie", nsIPermissionManager.ALLOW_ACTION);
|
||||
element = document.getElementById("AllowCookies");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "cookieBlock":
|
||||
permissionmanager.add(uri, nsIPermissionManager.COOKIE_TYPE, nsIPermissionManager.DENY_ACTION);
|
||||
permissionmanager.add(uri, "cookie", nsIPermissionManager.DENY_ACTION);
|
||||
element = document.getElementById("BlockCookies");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "imageAllow":
|
||||
permissionmanager.add(uri, nsIPermissionManager.IMAGE_TYPE, nsIPermissionManager.ALLOW_ACTION);
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.ALLOW_ACTION);
|
||||
element = document.getElementById("AllowImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "imageBlock":
|
||||
permissionmanager.add(uri, nsIPermissionManager.IMAGE_TYPE, nsIPermissionManager.DENY_ACTION);
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
|
||||
element = document.getElementById("BlockImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
var _elementIDs = ["popupPolicy","playSound","playSoundUrl","displayIcon","removeBlacklist","prefillWhitelist"];
|
||||
|
||||
const nsIPermissionManager = Components.interfaces.nsIPermissionManager
|
||||
const popupType = nsIPermissionManager.POPUP_TYPE;
|
||||
const popupType = "popup";
|
||||
|
||||
var gPolicyCheckbox;
|
||||
var gSoundCheckbox;
|
||||
|
|
|
@ -38,9 +38,9 @@ var deletedPermissions = [];
|
|||
|
||||
// differentiate between cookies, images, and popups
|
||||
const nsIPermissionManager = Components.interfaces.nsIPermissionManager;
|
||||
const cookieType = nsIPermissionManager.COOKIE_TYPE;
|
||||
const imageType = nsIPermissionManager.IMAGE_TYPE;
|
||||
const popupType = nsIPermissionManager.POPUP_TYPE;
|
||||
const cookieType = "cookie";
|
||||
const imageType = "image";
|
||||
const popupType = "popup";
|
||||
|
||||
var dialogType = cookieType;
|
||||
if (window.arguments[0] == "imageManager")
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
uri = ioService.newURI(gContextMenu.imageURL, null, null);
|
||||
return permissionmanager.testPermission(uri, nsIPermissionManager.IMAGE_TYPE) != nsIPermissionManager.DENY_ACTION;
|
||||
return permissionmanager.testPermission(uri, "image") != nsIPermissionManager.DENY_ACTION;
|
||||
},
|
||||
|
||||
// Determine if "imageBlocker.enabled" pref is set
|
||||
|
@ -78,9 +78,7 @@
|
|||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
uri = ioService.newURI(gContextMenu.imageURL, null, null);
|
||||
permissionmanager.add(uri,
|
||||
nsIPermissionManager.IMAGE_TYPE,
|
||||
nsIPermissionManager.DENY_ACTION);
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
|
||||
},
|
||||
|
||||
// Unblock image from loading in the future.
|
||||
|
@ -95,9 +93,7 @@
|
|||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
uri = ioService.newURI(gContextMenu.imageURL, null, null);
|
||||
permissionmanager.add(uri,
|
||||
nsIPermissionManager.IMAGE_TYPE,
|
||||
nsIPermissionManager.ALLOW_ACTION);
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.ALLOW_ACTION);
|
||||
},
|
||||
|
||||
initImageBlocking : function () {
|
||||
|
|
|
@ -70,13 +70,11 @@
|
|||
// determine current state (blocked or unblocked) and hide appropriate menu item
|
||||
var blocked = nsIPermissionManager.UNKNOWN_ACTION;
|
||||
|
||||
blocked =
|
||||
permissionmanager.testPermission(uri, nsIPermissionManager.COOKIE_TYPE);
|
||||
blocked = permissionmanager.testPermission(uri, "cookie");
|
||||
enableElement("AllowCookies", blocked != nsIPermissionManager.ALLOW_ACTION);
|
||||
enableElement("BlockCookies", blocked != nsIPermissionManager.DENY_ACTION);
|
||||
|
||||
blocked =
|
||||
permissionmanager.testPermission(uri, nsIPermissionManager.IMAGE_TYPE);
|
||||
blocked = permissionmanager.testPermission(uri, "image");
|
||||
enableElement("AllowImages", blocked != nsIPermissionManager.ALLOW_ACTION);
|
||||
enableElement("BlockImages", blocked != nsIPermissionManager.DENY_ACTION);
|
||||
|
||||
|
@ -106,7 +104,7 @@
|
|||
var blocked = nsIPermissionManager.UNKNOWN_ACTION;
|
||||
var policy = pref.getBoolPref("dom.disable_open_during_load");
|
||||
|
||||
blocked = permissionmanager.testPermission(getBrowser().currentURI, nsIPermissionManager.POPUP_TYPE);
|
||||
blocked = permissionmanager.testPermission(getBrowser().currentURI, "popup");
|
||||
|
||||
document.getElementById("AboutPopups").hidden = policy;
|
||||
document.getElementById("ManagePopups").hidden = !policy;
|
||||
|
@ -138,22 +136,22 @@
|
|||
var uri = getBrowser().currentURI;
|
||||
switch (action) {
|
||||
case "cookieAllow":
|
||||
permissionmanager.add(uri, nsIPermissionManager.COOKIE_TYPE, nsIPermissionManager.ALLOW_ACTION);
|
||||
permissionmanager.add(uri, "cookie", nsIPermissionManager.ALLOW_ACTION);
|
||||
element = document.getElementById("AllowCookies");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "cookieBlock":
|
||||
permissionmanager.add(uri, nsIPermissionManager.COOKIE_TYPE, nsIPermissionManager.DENY_ACTION);
|
||||
permissionmanager.add(uri, "cookie", nsIPermissionManager.DENY_ACTION);
|
||||
element = document.getElementById("BlockCookies");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "imageAllow":
|
||||
permissionmanager.add(uri, nsIPermissionManager.IMAGE_TYPE, nsIPermissionManager.ALLOW_ACTION);
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.ALLOW_ACTION);
|
||||
element = document.getElementById("AllowImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
case "imageBlock":
|
||||
permissionmanager.add(uri, nsIPermissionManager.IMAGE_TYPE, nsIPermissionManager.DENY_ACTION);
|
||||
permissionmanager.add(uri, "image", nsIPermissionManager.DENY_ACTION);
|
||||
element = document.getElementById("BlockImages");
|
||||
alert(element.getAttribute("msg"));
|
||||
break;
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
var _elementIDs = ["popupPolicy","playSound","playSoundUrl","displayIcon","removeBlacklist","prefillWhitelist"];
|
||||
|
||||
const nsIPermissionManager = Components.interfaces.nsIPermissionManager
|
||||
const popupType = nsIPermissionManager.POPUP_TYPE;
|
||||
const popupType = "popup";
|
||||
|
||||
var gPolicyCheckbox;
|
||||
var gSoundCheckbox;
|
||||
|
|
Загрузка…
Ссылка в новой задаче