diff --git a/extensions/cookie/nsPermission.cpp b/extensions/cookie/nsPermission.cpp index cd2a8ed139c..b1bd2775e8a 100644 --- a/extensions/cookie/nsPermission.cpp +++ b/extensions/cookie/nsPermission.cpp @@ -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) { diff --git a/extensions/cookie/nsPermission.h b/extensions/cookie/nsPermission.h index 7eeeca7660e..65e661413a5 100644 --- a/extensions/cookie/nsPermission.h +++ b/extensions/cookie/nsPermission.h @@ -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__ diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index 21f633b77c1..18f111e121b 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -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 permission = - new nsPermission(aHost, aType, aPermission, aExpireType, aExpireTime); + new nsPermission(aHost, aAppId, aIsInBrowserElement, aType, aPermission, + aExpireType, aExpireTime); if (permission) NotifyObservers(permission, aData); } diff --git a/extensions/cookie/nsPermissionManager.h b/extensions/cookie/nsPermissionManager.h index cd4c40be899..fe0ebc6d1ef 100644 --- a/extensions/cookie/nsPermissionManager.h +++ b/extensions/cookie/nsPermissionManager.h @@ -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, diff --git a/netwerk/base/public/nsIPermission.idl b/netwerk/base/public/nsIPermission.idl index 9cacc56a14b..4500679905a 100644 --- a/netwerk/base/public/nsIPermission.idl +++ b/netwerk/base/public/nsIPermission.idl @@ -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).