mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 777072 - 4/7 - Update nsPermission to use appId/isInBrowserElement. r=sicking
This commit is contained in:
parent
13f8b46e72
commit
a2e5fe652d
@ -10,6 +10,8 @@
|
||||
NS_IMPL_ISUPPORTS1(nsPermission, nsIPermission)
|
||||
|
||||
nsPermission::nsPermission(const nsACString &aHost,
|
||||
uint32_t aAppId,
|
||||
bool aIsInBrowserElement,
|
||||
const nsACString &aType,
|
||||
uint32_t aCapability,
|
||||
uint32_t aExpireType,
|
||||
@ -19,10 +21,8 @@ nsPermission::nsPermission(const nsACString &aHost,
|
||||
, mCapability(aCapability)
|
||||
, mExpireType(aExpireType)
|
||||
, mExpireTime(aExpireTime)
|
||||
{
|
||||
}
|
||||
|
||||
nsPermission::~nsPermission()
|
||||
, mAppId(aAppId)
|
||||
, mIsInBrowserElement(aIsInBrowserElement)
|
||||
{
|
||||
}
|
||||
|
||||
@ -33,6 +33,20 @@ nsPermission::GetHost(nsACString &aHost)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermission::GetAppId(uint32_t* aAppId)
|
||||
{
|
||||
*aAppId = mAppId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermission::GetIsInBrowserElement(bool* aIsInBrowserElement)
|
||||
{
|
||||
*aIsInBrowserElement = mIsInBrowserElement;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermission::GetType(nsACString &aType)
|
||||
{
|
||||
|
@ -19,19 +19,23 @@ public:
|
||||
NS_DECL_NSIPERMISSION
|
||||
|
||||
nsPermission(const nsACString &aHost,
|
||||
const nsACString &aType,
|
||||
uint32_t aAppId,
|
||||
bool aIsInBrowserElement,
|
||||
const nsACString &aType,
|
||||
uint32_t aCapability,
|
||||
uint32_t aExpireType,
|
||||
int64_t aExpireTime);
|
||||
|
||||
virtual ~nsPermission();
|
||||
|
||||
virtual ~nsPermission() {};
|
||||
|
||||
protected:
|
||||
nsCString mHost;
|
||||
nsCString mType;
|
||||
uint32_t mCapability;
|
||||
uint32_t mExpireType;
|
||||
int64_t mExpireTime;
|
||||
uint32_t mAppId;
|
||||
bool mIsInBrowserElement;
|
||||
};
|
||||
|
||||
#endif // nsPermission_h__
|
||||
|
@ -635,6 +635,8 @@ nsPermissionManager::AddInternal(nsIPrincipal* aPrincipal,
|
||||
|
||||
if (aNotifyOperation == eNotify) {
|
||||
NotifyObserversWithPermission(host,
|
||||
entry->GetKey()->mAppId,
|
||||
entry->GetKey()->mIsInBrowserElement,
|
||||
mTypeArray[typeIndex],
|
||||
aPermission,
|
||||
aExpireType,
|
||||
@ -661,6 +663,8 @@ nsPermissionManager::AddInternal(nsIPrincipal* aPrincipal,
|
||||
|
||||
if (aNotifyOperation == eNotify) {
|
||||
NotifyObserversWithPermission(host,
|
||||
entry->GetKey()->mAppId,
|
||||
entry->GetKey()->mIsInBrowserElement,
|
||||
mTypeArray[typeIndex],
|
||||
oldPermissionEntry.mPermission,
|
||||
oldPermissionEntry.mExpireType,
|
||||
@ -681,6 +685,8 @@ nsPermissionManager::AddInternal(nsIPrincipal* aPrincipal,
|
||||
|
||||
if (aNotifyOperation == eNotify) {
|
||||
NotifyObserversWithPermission(host,
|
||||
entry->GetKey()->mAppId,
|
||||
entry->GetKey()->mIsInBrowserElement,
|
||||
mTypeArray[typeIndex],
|
||||
aPermission,
|
||||
aExpireType,
|
||||
@ -982,6 +988,8 @@ AddPermissionsToList(nsPermissionManager::PermissionHashKey* entry, void *arg)
|
||||
nsPermissionManager::PermissionEntry& permEntry = entry->GetPermissions()[i];
|
||||
|
||||
nsPermission *perm = new nsPermission(entry->GetKey()->mHost,
|
||||
entry->GetKey()->mAppId,
|
||||
entry->GetKey()->mIsInBrowserElement,
|
||||
data->types->ElementAt(permEntry.mType),
|
||||
permEntry.mPermission,
|
||||
permEntry.mExpireType,
|
||||
@ -1070,6 +1078,8 @@ nsPermissionManager::GetTypeIndex(const char *aType,
|
||||
// set into an nsIPermission.
|
||||
void
|
||||
nsPermissionManager::NotifyObserversWithPermission(const nsACString &aHost,
|
||||
uint32_t aAppId,
|
||||
bool aIsInBrowserElement,
|
||||
const nsCString &aType,
|
||||
uint32_t aPermission,
|
||||
uint32_t aExpireType,
|
||||
@ -1077,7 +1087,8 @@ nsPermissionManager::NotifyObserversWithPermission(const nsACString &aHost,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
nsCOMPtr<nsIPermission> permission =
|
||||
new nsPermission(aHost, aType, aPermission, aExpireType, aExpireTime);
|
||||
new nsPermission(aHost, aAppId, aIsInBrowserElement, aType, aPermission,
|
||||
aExpireType, aExpireTime);
|
||||
if (permission)
|
||||
NotifyObservers(permission, aData);
|
||||
}
|
||||
|
@ -210,6 +210,8 @@ private:
|
||||
nsresult Import();
|
||||
nsresult Read();
|
||||
void NotifyObserversWithPermission(const nsACString &aHost,
|
||||
uint32_t aAppId,
|
||||
bool aIsInBrowserElement,
|
||||
const nsCString &aType,
|
||||
uint32_t aPermission,
|
||||
uint32_t aExpireType,
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(5036f0f6-f77b-4168-9d57-a1c0dd66cf02)]
|
||||
[scriptable, uuid(cfb08e46-193c-4be7-a467-d7775fb2a31e)]
|
||||
/**
|
||||
* This interface defines a "permission" object,
|
||||
* used to specify allowed/blocked objects from
|
||||
@ -20,6 +20,16 @@ interface nsIPermission : nsISupports
|
||||
*/
|
||||
readonly attribute AUTF8String host;
|
||||
|
||||
/**
|
||||
* The id of the app for which the permission is set.
|
||||
*/
|
||||
readonly attribute unsigned long appId;
|
||||
|
||||
/**
|
||||
* Whether the permission has been set to a page inside a browser element.
|
||||
*/
|
||||
readonly attribute boolean isInBrowserElement;
|
||||
|
||||
/**
|
||||
* a case-sensitive ASCII string, indicating the type of permission
|
||||
* (e.g., "cookie", "image", etc).
|
||||
|
Loading…
Reference in New Issue
Block a user