Bug 1517089 - Part 16: Implement QuotaManager::GetInfoFromValidatedPrincipalInfo; r=asuth

Differential Revision: https://phabricator.services.mozilla.com/D19213
This commit is contained in:
Jan Varga 2019-02-08 21:02:23 +01:00
Родитель b359db62fd
Коммит 383bad7c55
2 изменённых файлов: 44 добавлений и 3 удалений

Просмотреть файл

@ -5457,6 +5457,46 @@ bool QuotaManager::IsPrincipalInfoValid(const PrincipalInfo& aPrincipalInfo) {
return false;
}
// static
void QuotaManager::GetInfoFromValidatedPrincipalInfo(
const PrincipalInfo& aPrincipalInfo, nsACString* aSuffix,
nsACString* aGroup, nsACString* aOrigin) {
MOZ_ASSERT(IsPrincipalInfoValid(aPrincipalInfo));
switch (aPrincipalInfo.type()) {
case PrincipalInfo::TSystemPrincipalInfo: {
GetInfoForChrome(aSuffix, aGroup, aOrigin);
return;
}
case PrincipalInfo::TContentPrincipalInfo: {
const ContentPrincipalInfo& info =
aPrincipalInfo.get_ContentPrincipalInfo();
nsCString suffix;
info.attrs().CreateSuffix(suffix);
if (aSuffix) {
aSuffix->Assign(suffix);
}
if (aGroup) {
aGroup->Assign(info.baseDomain() + suffix);
}
if (aOrigin) {
aOrigin->Assign(info.originNoSuffix() + suffix);
}
return;
}
default: { break; }
}
MOZ_CRASH("Should never get here!");
}
// static
nsresult QuotaManager::GetInfoFromPrincipal(nsIPrincipal* aPrincipal,
nsACString* aSuffix,
@ -5531,9 +5571,6 @@ nsresult QuotaManager::GetInfoFromWindow(nsPIDOMWindowOuter* aWindow,
// static
void QuotaManager::GetInfoForChrome(nsACString* aSuffix, nsACString* aGroup,
nsACString* aOrigin) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(nsContentUtils::LegacyIsCallerChromeOrNativeCode());
if (aSuffix) {
aSuffix->Assign(EmptyCString());
}

Просмотреть файл

@ -336,6 +336,10 @@ class QuotaManager final : public BackgroundThreadObject {
static bool IsPrincipalInfoValid(const PrincipalInfo& aPrincipalInfo);
static void GetInfoFromValidatedPrincipalInfo(
const PrincipalInfo& aPrincipalInfo, nsACString* aSuffix,
nsACString* aGroup, nsACString* aOrigin);
static nsresult GetInfoFromPrincipal(nsIPrincipal* aPrincipal,
nsACString* aSuffix, nsACString* aGroup,
nsACString* aOrigin);