зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1536454
- Part 2 - Add modificationTime attribute to nsIPermission.idl. r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D26943 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
cdd6d741fd
Коммит
f296ce765f
|
@ -16,12 +16,13 @@ NS_IMPL_ISUPPORTS_CI(nsPermission, nsIPermission)
|
|||
|
||||
nsPermission::nsPermission(nsIPrincipal* aPrincipal, const nsACString& aType,
|
||||
uint32_t aCapability, uint32_t aExpireType,
|
||||
int64_t aExpireTime)
|
||||
int64_t aExpireTime, int64_t aModificationTime)
|
||||
: mPrincipal(aPrincipal),
|
||||
mType(aType),
|
||||
mCapability(aCapability),
|
||||
mExpireType(aExpireType),
|
||||
mExpireTime(aExpireTime) {}
|
||||
mExpireTime(aExpireTime),
|
||||
mModificationTime(aModificationTime) {}
|
||||
|
||||
already_AddRefed<nsIPrincipal> nsPermission::ClonePrincipalForPermission(
|
||||
nsIPrincipal* aPrincipal) {
|
||||
|
@ -42,11 +43,9 @@ already_AddRefed<nsIPrincipal> nsPermission::ClonePrincipalForPermission(
|
|||
return mozilla::BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||
}
|
||||
|
||||
already_AddRefed<nsPermission> nsPermission::Create(nsIPrincipal* aPrincipal,
|
||||
const nsACString& aType,
|
||||
uint32_t aCapability,
|
||||
uint32_t aExpireType,
|
||||
int64_t aExpireTime) {
|
||||
already_AddRefed<nsPermission> nsPermission::Create(
|
||||
nsIPrincipal* aPrincipal, const nsACString& aType, uint32_t aCapability,
|
||||
uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime) {
|
||||
NS_ENSURE_TRUE(aPrincipal, nullptr);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal =
|
||||
|
@ -54,7 +53,8 @@ already_AddRefed<nsPermission> nsPermission::Create(nsIPrincipal* aPrincipal,
|
|||
NS_ENSURE_TRUE(principal, nullptr);
|
||||
|
||||
RefPtr<nsPermission> permission =
|
||||
new nsPermission(principal, aType, aCapability, aExpireType, aExpireTime);
|
||||
new nsPermission(principal, aType, aCapability, aExpireType, aExpireTime,
|
||||
aModificationTime);
|
||||
return permission.forget();
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,12 @@ nsPermission::GetExpireTime(int64_t* aExpireTime) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermission::GetModificationTime(int64_t* aModificationTime) {
|
||||
*aModificationTime = mModificationTime;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPermission::Matches(nsIPrincipal* aPrincipal, bool aExactHost,
|
||||
bool* aMatches) {
|
||||
|
|
|
@ -17,11 +17,9 @@ class nsPermission : public nsIPermission {
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPERMISSION
|
||||
|
||||
static already_AddRefed<nsPermission> Create(nsIPrincipal* aPrincipal,
|
||||
const nsACString& aType,
|
||||
uint32_t aCapability,
|
||||
uint32_t aExpireType,
|
||||
int64_t aExpireTime);
|
||||
static already_AddRefed<nsPermission> Create(
|
||||
nsIPrincipal* aPrincipal, const nsACString& aType, uint32_t aCapability,
|
||||
uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime);
|
||||
|
||||
// This method creates a new nsIPrincipal with a stripped OriginAttributes (no
|
||||
// userContextId, and no FirstPartyDomain) and a codebase equal to the origin
|
||||
|
@ -31,7 +29,8 @@ class nsPermission : public nsIPermission {
|
|||
|
||||
protected:
|
||||
nsPermission(nsIPrincipal* aPrincipal, const nsACString& aType,
|
||||
uint32_t aCapability, uint32_t aExpireType, int64_t aExpireTime);
|
||||
uint32_t aCapability, uint32_t aExpireType, int64_t aExpireTime,
|
||||
int64_t aModificationTime);
|
||||
|
||||
virtual ~nsPermission(){};
|
||||
|
||||
|
@ -40,6 +39,7 @@ class nsPermission : public nsIPermission {
|
|||
uint32_t mCapability;
|
||||
uint32_t mExpireType;
|
||||
int64_t mExpireTime;
|
||||
int64_t mModificationTime;
|
||||
};
|
||||
|
||||
#endif // nsPermission_h__
|
||||
|
|
|
@ -1875,7 +1875,7 @@ nsresult nsPermissionManager::AddInternal(
|
|||
if (aNotifyOperation == eNotify) {
|
||||
NotifyObserversWithPermission(aPrincipal, mTypeArray[typeIndex],
|
||||
aPermission, aExpireType, aExpireTime,
|
||||
u"added");
|
||||
aModificationTime, u"added");
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -1913,7 +1913,7 @@ nsresult nsPermissionManager::AddInternal(
|
|||
NotifyObserversWithPermission(
|
||||
aPrincipal, mTypeArray[typeIndex], oldPermissionEntry.mPermission,
|
||||
oldPermissionEntry.mExpireType, oldPermissionEntry.mExpireTime,
|
||||
u"deleted");
|
||||
oldPermissionEntry.mModificationTime, u"deleted");
|
||||
}
|
||||
|
||||
// If there are no more permissions stored for that entry, clear it.
|
||||
|
@ -1970,7 +1970,7 @@ nsresult nsPermissionManager::AddInternal(
|
|||
if (aNotifyOperation == eNotify) {
|
||||
NotifyObserversWithPermission(aPrincipal, mTypeArray[typeIndex],
|
||||
aPermission, aExpireType, aExpireTime,
|
||||
u"changed");
|
||||
aModificationTime, u"changed");
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -2019,7 +2019,7 @@ nsresult nsPermissionManager::AddInternal(
|
|||
if (aNotifyOperation == eNotify) {
|
||||
NotifyObserversWithPermission(aPrincipal, mTypeArray[typeIndex],
|
||||
aPermission, aExpireType, aExpireTime,
|
||||
u"changed");
|
||||
aModificationTime, u"changed");
|
||||
}
|
||||
|
||||
} break;
|
||||
|
@ -2362,9 +2362,9 @@ nsPermissionManager::GetPermissionObject(nsIPrincipal* aPrincipal,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PermissionEntry& perm = entry->GetPermissions()[idx];
|
||||
nsCOMPtr<nsIPermission> r =
|
||||
nsPermission::Create(principal, mTypeArray[perm.mType], perm.mPermission,
|
||||
perm.mExpireType, perm.mExpireTime);
|
||||
nsCOMPtr<nsIPermission> r = nsPermission::Create(
|
||||
principal, mTypeArray[perm.mType], perm.mPermission, perm.mExpireType,
|
||||
perm.mExpireTime, perm.mModificationTime);
|
||||
if (NS_WARN_IF(!r)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2609,7 +2609,8 @@ NS_IMETHODIMP nsPermissionManager::GetAllWithTypePrefix(
|
|||
|
||||
RefPtr<nsIPermission> permission = nsPermission::Create(
|
||||
principal, mTypeArray[permEntry.mType], permEntry.mPermission,
|
||||
permEntry.mExpireType, permEntry.mExpireTime);
|
||||
permEntry.mExpireType, permEntry.mExpireTime,
|
||||
permEntry.mModificationTime);
|
||||
if (NS_WARN_IF(!permission)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2655,7 +2656,8 @@ nsPermissionManager::GetAllForPrincipal(nsIPrincipal* aPrincipal,
|
|||
|
||||
nsCOMPtr<nsIPermission> permission = nsPermission::Create(
|
||||
aPrincipal, mTypeArray[permEntry.mType], permEntry.mPermission,
|
||||
permEntry.mExpireType, permEntry.mExpireTime);
|
||||
permEntry.mExpireType, permEntry.mExpireTime,
|
||||
permEntry.mModificationTime);
|
||||
if (NS_WARN_IF(!permission)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2769,9 +2771,11 @@ nsresult nsPermissionManager::RemoveAllFromMemory() {
|
|||
// set into an nsIPermission.
|
||||
void nsPermissionManager::NotifyObserversWithPermission(
|
||||
nsIPrincipal* aPrincipal, const nsACString& aType, uint32_t aPermission,
|
||||
uint32_t aExpireType, int64_t aExpireTime, const char16_t* aData) {
|
||||
nsCOMPtr<nsIPermission> permission = nsPermission::Create(
|
||||
aPrincipal, aType, aPermission, aExpireType, aExpireTime);
|
||||
uint32_t aExpireType, int64_t aExpireTime, int64_t aModificationTime,
|
||||
const char16_t* aData) {
|
||||
nsCOMPtr<nsIPermission> permission =
|
||||
nsPermission::Create(aPrincipal, aType, aPermission, aExpireType,
|
||||
aExpireTime, aModificationTime);
|
||||
if (permission) NotifyObservers(permission, aData);
|
||||
}
|
||||
|
||||
|
|
|
@ -473,6 +473,7 @@ class nsPermissionManager final : public nsIPermissionManager,
|
|||
const nsACString& aType,
|
||||
uint32_t aPermission, uint32_t aExpireType,
|
||||
int64_t aExpireTime,
|
||||
int64_t aModificationTime,
|
||||
const char16_t* aData);
|
||||
void NotifyObservers(nsIPermission* aPermission, const char16_t* aData);
|
||||
|
||||
|
|
|
@ -50,6 +50,12 @@ interface nsIPermission : nsISupports
|
|||
*/
|
||||
readonly attribute int64_t expireTime;
|
||||
|
||||
/**
|
||||
* The last modification time of the permission (milliseconds since Jan 1 1970
|
||||
* 0:00:00).
|
||||
*/
|
||||
readonly attribute int64_t modificationTime;
|
||||
|
||||
/**
|
||||
* Test whether a principal would be affected by this permission.
|
||||
*
|
||||
|
|
|
@ -144,7 +144,7 @@ CookieSettings::CookiePermission(nsIPrincipal* aPrincipal,
|
|||
// race conditions.
|
||||
|
||||
nsCOMPtr<nsIPermission> permission = nsPermission::Create(
|
||||
aPrincipal, NS_LITERAL_CSTRING("cookie"), *aCookiePermission, 0, 0);
|
||||
aPrincipal, NS_LITERAL_CSTRING("cookie"), *aCookiePermission, 0, 0, 0);
|
||||
if (permission) {
|
||||
mCookiePermissions.AppendElement(permission);
|
||||
}
|
||||
|
@ -198,8 +198,9 @@ void CookieSettings::Serialize(CookieSettingsArgs& aData) {
|
|||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPermission> permission = nsPermission::Create(
|
||||
principal, NS_LITERAL_CSTRING("cookie"), data.cookiePermission(), 0, 0);
|
||||
nsCOMPtr<nsIPermission> permission =
|
||||
nsPermission::Create(principal, NS_LITERAL_CSTRING("cookie"),
|
||||
data.cookiePermission(), 0, 0, 0);
|
||||
if (NS_WARN_IF(!permission)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -232,8 +233,9 @@ void CookieSettings::Merge(const CookieSettingsArgs& aData) {
|
|||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPermission> permission = nsPermission::Create(
|
||||
principal, NS_LITERAL_CSTRING("cookie"), data.cookiePermission(), 0, 0);
|
||||
nsCOMPtr<nsIPermission> permission =
|
||||
nsPermission::Create(principal, NS_LITERAL_CSTRING("cookie"),
|
||||
data.cookiePermission(), 0, 0, 0);
|
||||
if (NS_WARN_IF(!permission)) {
|
||||
continue;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче