mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1867997 - Add QuotaManager::GetGroupFromValidatedPrincipalInfo; r=dom-storage-reviewers,jari
The planned group initialization will need an infallible way to get group from PrincipalInfo, so this patch adds support for that. Differential Revision: https://phabricator.services.mozilla.com/D196821
This commit is contained in:
parent
a8506400af
commit
8517ddc5a8
@ -174,6 +174,32 @@ Result<PrincipalInfo, nsresult> PrincipalMetadataToPrincipalInfo(
|
||||
return std::move(principalInfo);
|
||||
}
|
||||
|
||||
nsAutoCString GetGroupFromValidatedPrincipalInfo(
|
||||
const PrincipalInfo& aPrincipalInfo) {
|
||||
MOZ_ASSERT(IsPrincipalInfoValid(aPrincipalInfo));
|
||||
|
||||
switch (aPrincipalInfo.type()) {
|
||||
case PrincipalInfo::TSystemPrincipalInfo: {
|
||||
return nsAutoCString{GetGroupForChrome()};
|
||||
}
|
||||
|
||||
case PrincipalInfo::TContentPrincipalInfo: {
|
||||
const ContentPrincipalInfo& info =
|
||||
aPrincipalInfo.get_ContentPrincipalInfo();
|
||||
|
||||
nsAutoCString suffix;
|
||||
|
||||
info.attrs().CreateSuffix(suffix);
|
||||
|
||||
return info.baseDomain() + suffix;
|
||||
}
|
||||
|
||||
default: {
|
||||
MOZ_CRASH("Should never get here!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoCString GetOriginFromValidatedPrincipalInfo(
|
||||
const PrincipalInfo& aPrincipalInfo) {
|
||||
MOZ_ASSERT(IsPrincipalInfoValid(aPrincipalInfo));
|
||||
@ -293,12 +319,14 @@ Result<nsAutoCString, nsresult> GetOriginFromWindow(
|
||||
|
||||
PrincipalMetadata GetInfoForChrome() {
|
||||
return {{},
|
||||
GetOriginForChrome(),
|
||||
GetGroupForChrome(),
|
||||
GetOriginForChrome(),
|
||||
GetOriginForChrome(),
|
||||
false};
|
||||
}
|
||||
|
||||
nsLiteralCString GetGroupForChrome() { return nsLiteralCString{kChromeOrigin}; }
|
||||
|
||||
nsLiteralCString GetOriginForChrome() {
|
||||
return nsLiteralCString{kChromeOrigin};
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ Result<PrincipalMetadata, nsresult> GetInfoFromValidatedPrincipalInfo(
|
||||
Result<mozilla::ipc::PrincipalInfo, nsresult> PrincipalMetadataToPrincipalInfo(
|
||||
const PrincipalMetadata& aPrincipalMetadata);
|
||||
|
||||
nsAutoCString GetGroupFromValidatedPrincipalInfo(
|
||||
const mozilla::ipc::PrincipalInfo& aPrincipalInfo);
|
||||
|
||||
nsAutoCString GetOriginFromValidatedPrincipalInfo(
|
||||
const mozilla::ipc::PrincipalInfo& aPrincipalInfo);
|
||||
|
||||
@ -57,6 +60,8 @@ Result<nsAutoCString, nsresult> GetOriginFromPrincipal(
|
||||
Result<nsAutoCString, nsresult> GetOriginFromWindow(
|
||||
nsPIDOMWindowOuter* aWindow);
|
||||
|
||||
nsLiteralCString GetGroupForChrome();
|
||||
|
||||
nsLiteralCString GetOriginForChrome();
|
||||
|
||||
PrincipalMetadata GetInfoForChrome();
|
||||
|
Loading…
Reference in New Issue
Block a user