diff --git a/caps/BasePrincipal.cpp b/caps/BasePrincipal.cpp index f32d628d0838..43d3c95f1a5c 100644 --- a/caps/BasePrincipal.cpp +++ b/caps/BasePrincipal.cpp @@ -106,21 +106,7 @@ BasePrincipal::GetOriginNoSuffix(nsACString& aOrigin) { NS_IMETHODIMP BasePrincipal::GetSiteOrigin(nsACString& aSiteOrigin) { MOZ_ASSERT(mInitialized); - - nsresult rv = GetSiteOriginNoSuffix(aSiteOrigin); - NS_ENSURE_SUCCESS(rv, rv); - - nsAutoCString suffix; - rv = GetOriginSuffix(suffix); - NS_ENSURE_SUCCESS(rv, rv); - aSiteOrigin.Append(suffix); - return NS_OK; -} - -NS_IMETHODIMP -BasePrincipal::GetSiteOriginNoSuffix(nsACString& aSiteOrigin) { - MOZ_ASSERT(mInitialized); - return GetOriginNoSuffix(aSiteOrigin); + return GetOrigin(aSiteOrigin); } // Returns the inner Json::value of the serialized principal diff --git a/caps/BasePrincipal.h b/caps/BasePrincipal.h index 8b414ad3e69e..450cd55f2adb 100644 --- a/caps/BasePrincipal.h +++ b/caps/BasePrincipal.h @@ -156,8 +156,7 @@ class BasePrincipal : public nsJSPrincipals { bool* aIsInIsolatedMozBrowserElement) final; NS_IMETHOD GetUserContextId(uint32_t* aUserContextId) final; NS_IMETHOD GetPrivateBrowsingId(uint32_t* aPrivateBrowsingId) final; - NS_IMETHOD GetSiteOrigin(nsACString& aSiteOrigin) final; - NS_IMETHOD GetSiteOriginNoSuffix(nsACString& aSiteOrigin) override; + NS_IMETHOD GetSiteOrigin(nsACString& aOrigin) override; NS_IMETHOD IsThirdPartyURI(nsIURI* uri, bool* aRes) override; NS_IMETHOD IsThirdPartyPrincipal(nsIPrincipal* uri, bool* aRes) override; NS_IMETHOD IsThirdPartyChannel(nsIChannel* aChannel, bool* aRes) override; diff --git a/caps/ContentPrincipal.cpp b/caps/ContentPrincipal.cpp index f8d6f03b5f53..e10379d32a83 100644 --- a/caps/ContentPrincipal.cpp +++ b/caps/ContentPrincipal.cpp @@ -440,7 +440,7 @@ ContentPrincipal::GetBaseDomain(nsACString& aBaseDomain) { } NS_IMETHODIMP -ContentPrincipal::GetSiteOriginNoSuffix(nsACString& aSiteOrigin) { +ContentPrincipal::GetSiteOrigin(nsACString& aSiteOrigin) { // Handle some special URIs first. nsAutoCString baseDomain; bool handled; @@ -450,7 +450,7 @@ ContentPrincipal::GetSiteOriginNoSuffix(nsACString& aSiteOrigin) { if (handled) { // This is a special URI ("file:", "about:", "view-source:", etc). Just // return the origin. - return GetSiteOriginNoSuffix(aSiteOrigin); + return GetOrigin(aSiteOrigin); } // For everything else, we ask the TLD service. Note that, unlike in @@ -491,7 +491,15 @@ ContentPrincipal::GetSiteOriginNoSuffix(nsACString& aSiteOrigin) { rv = GenerateOriginNoSuffixFromURI(siteUri, aSiteOrigin); MOZ_ASSERT(NS_SUCCEEDED(rv), "failed to create siteOriginNoSuffix"); - return rv; + NS_ENSURE_SUCCESS(rv, rv); + + nsAutoCString suffix; + rv = GetOriginSuffix(suffix); + MOZ_ASSERT(NS_SUCCEEDED(rv), "failed to create suffix"); + NS_ENSURE_SUCCESS(rv, rv); + + aSiteOrigin.Append(suffix); + return NS_OK; } nsresult ContentPrincipal::GetSiteIdentifier(SiteIdentifier& aSite) { diff --git a/caps/ContentPrincipal.h b/caps/ContentPrincipal.h index 2c7aac3c0b7e..ec4fc7cedacd 100644 --- a/caps/ContentPrincipal.h +++ b/caps/ContentPrincipal.h @@ -30,7 +30,7 @@ class ContentPrincipal final : public BasePrincipal { NS_IMETHOD SetDomain(nsIURI* aDomain) override; NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override; NS_IMETHOD GetAddonId(nsAString& aAddonId) override; - NS_IMETHOD GetSiteOriginNoSuffix(nsACString& aSiteOrigin) override; + NS_IMETHOD GetSiteOrigin(nsACString& aSiteOrigin) override; bool IsContentPrincipal() const override { return true; } ContentPrincipal(); diff --git a/caps/nsIPrincipal.idl b/caps/nsIPrincipal.idl index 3f756f38c78b..5332259a4320 100644 --- a/caps/nsIPrincipal.idl +++ b/caps/nsIPrincipal.idl @@ -419,15 +419,10 @@ interface nsIPrincipal : nsISerializable * principals which allow mutating |domain|, such as ContentPrincipal, * override the default implementation in BasePrincipal. * + * TODO(nika): Use this in DocGroup. */ readonly attribute ACString siteOrigin; - /** - * The base part of |siteOrigin| without the concatenation with - * |originSuffix|. - */ - readonly attribute ACString siteOriginNoSuffix; - /** * The base domain of the principal URI to which this principal pertains * (generally the document URI), handling null principals and