зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset d15b968aa6d1 (bug 1615297) for causing build bustage
CLOSED TREE --HG-- extra : rebase_source : 4e525e82fb7f194d9b7eac0020932ed09ac005b7
This commit is contained in:
Родитель
8ba260392e
Коммит
8edab673d8
|
@ -155,7 +155,6 @@ class BasePrincipal : public nsJSPrincipals {
|
|||
nsIReferrerInfo** _retval) override;
|
||||
NS_IMETHOD GetIsScriptAllowedByPolicy(
|
||||
bool* aIsScriptAllowedByPolicy) override;
|
||||
NS_IMETHOD GetStorageOriginKey(nsACString& aOriginKey) override;
|
||||
nsresult ToJSON(nsACString& aJSON);
|
||||
static already_AddRefed<BasePrincipal> FromJSON(const nsACString& aJSON);
|
||||
// Method populates a passed Json::Value with serializable fields
|
||||
|
|
|
@ -330,12 +330,6 @@ interface nsIPrincipal : nsISerializable
|
|||
*/
|
||||
uint32_t getAboutModuleFlags();
|
||||
|
||||
/*
|
||||
* Returns the Key to access the Principals
|
||||
* Origin Local/Session Storage
|
||||
*/
|
||||
readonly attribute ACString storageOriginKey;
|
||||
|
||||
/**
|
||||
* Creates and Returns a new ReferrerInfo with the
|
||||
* Principals URI
|
||||
|
|
|
@ -271,9 +271,8 @@ nsresult LSObject::CreateForWindow(nsPIDOMWindowInner* aWindow,
|
|||
// for the check.
|
||||
nsCString originAttrSuffix;
|
||||
nsCString originKey;
|
||||
nsresult rv = storagePrincipal->GetStorageOriginKey(originKey);
|
||||
storagePrincipal->OriginAttributesRef().CreateSuffix(originAttrSuffix);
|
||||
|
||||
nsresult rv =
|
||||
GenerateOriginKey(storagePrincipal, originAttrSuffix, originKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
@ -356,8 +355,8 @@ nsresult LSObject::CreateForPrincipal(nsPIDOMWindowInner* aWindow,
|
|||
|
||||
nsCString originAttrSuffix;
|
||||
nsCString originKey;
|
||||
nsresult rv = aStoragePrincipal->GetStorageOriginKey(originKey);
|
||||
aStoragePrincipal->OriginAttributesRef().CreateSuffix(originAttrSuffix);
|
||||
nsresult rv =
|
||||
GenerateOriginKey(aStoragePrincipal, originAttrSuffix, originKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
|
|
@ -269,8 +269,7 @@ LocalStorageManager2::Preload(nsIPrincipal* aPrincipal, JSContext* aContext,
|
|||
|
||||
nsCString originAttrSuffix;
|
||||
nsCString originKey;
|
||||
nsresult rv = aPrincipal->GetStorageOriginKey(originKey);
|
||||
aPrincipal->OriginAttributesRef().CreateSuffix(originAttrSuffix);
|
||||
nsresult rv = GenerateOriginKey(aPrincipal, originAttrSuffix, originKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
|
|
@ -45,8 +45,7 @@ already_AddRefed<nsIPrincipal> GetContentPrincipal(const char* aSpec) {
|
|||
void CheckGeneratedOriginKey(nsIPrincipal* aPrincipal, const char* aOriginKey) {
|
||||
nsCString originAttrSuffix;
|
||||
nsCString originKey;
|
||||
nsresult rv = aPrincipal->GetStorageOriginKey(originKey);
|
||||
aPrincipal->OriginAttributesRef().CreateSuffix(originAttrSuffix);
|
||||
nsresult rv = GenerateOriginKey(aPrincipal, originAttrSuffix, originKey);
|
||||
if (aOriginKey) {
|
||||
ASSERT_EQ(rv, NS_OK) << "GenerateOriginKey should not fail";
|
||||
EXPECT_TRUE(originKey == nsDependentCString(aOriginKey));
|
||||
|
|
|
@ -147,8 +147,8 @@ nsresult LocalStorageManager::GetStorageInternal(
|
|||
nsAutoCString originAttrSuffix;
|
||||
nsAutoCString originKey;
|
||||
|
||||
nsresult rv = aStoragePrincipal->GetStorageOriginKey(originKey);
|
||||
aStoragePrincipal->OriginAttributesRef().CreateSuffix(originAttrSuffix);
|
||||
nsresult rv =
|
||||
GenerateOriginKey(aStoragePrincipal, originAttrSuffix, originKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
|
|
@ -102,8 +102,7 @@ nsresult SessionStorageManager::GetSessionStorageCacheHelper(
|
|||
SessionStorageCache* aCloneFrom, RefPtr<SessionStorageCache>* aRetVal) {
|
||||
nsAutoCString originKey;
|
||||
nsAutoCString originAttributes;
|
||||
nsresult rv = aPrincipal->GetStorageOriginKey(originKey);
|
||||
aPrincipal->OriginAttributesRef().CreateSuffix(originAttributes);
|
||||
nsresult rv = GenerateOriginKey(aPrincipal, originAttributes, originKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
@ -302,8 +301,7 @@ void SessionStorageManager::SendSessionStorageDataToContentProcess(
|
|||
ContentParent* const aActor, nsIPrincipal* const aPrincipal) {
|
||||
nsAutoCString originAttrs;
|
||||
nsAutoCString originKey;
|
||||
nsresult rv = aPrincipal->GetStorageOriginKey(originKey);
|
||||
aPrincipal->OriginAttributesRef().CreateSuffix(originAttrs);
|
||||
auto rv = GenerateOriginKey(aPrincipal, originAttrs, originKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,62 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
namespace StorageUtils {
|
||||
|
||||
nsresult GenerateOriginKey(nsIPrincipal* aPrincipal,
|
||||
nsACString& aOriginAttrSuffix,
|
||||
nsACString& aOriginKey) {
|
||||
if (NS_WARN_IF(!aPrincipal)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
aPrincipal->OriginAttributesRef().CreateSuffix(aOriginAttrSuffix);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = aPrincipal->GetURI(getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!uri) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsAutoCString domainOrigin;
|
||||
rv = uri->GetAsciiHost(domainOrigin);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (domainOrigin.IsEmpty()) {
|
||||
// For the file:/// protocol use the exact directory as domain.
|
||||
if (uri->SchemeIs("file")) {
|
||||
nsCOMPtr<nsIURL> url = do_QueryInterface(uri, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = url->GetDirectory(domainOrigin);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
// Append reversed domain
|
||||
nsAutoCString reverseDomain;
|
||||
rv = CreateReversedDomain(domainOrigin, reverseDomain);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
aOriginKey.Append(reverseDomain);
|
||||
|
||||
// Append scheme
|
||||
nsAutoCString scheme;
|
||||
rv = uri->GetScheme(scheme);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aOriginKey.Append(':');
|
||||
aOriginKey.Append(scheme);
|
||||
|
||||
// Append port if any
|
||||
int32_t port = NS_GetRealPort(uri);
|
||||
if (port != -1) {
|
||||
aOriginKey.Append(nsPrintfCString(":%d", port));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool PrincipalsEqual(nsIPrincipal* aObjectPrincipal,
|
||||
nsIPrincipal* aSubjectPrincipal) {
|
||||
if (!aSubjectPrincipal) {
|
||||
|
|
|
@ -15,6 +15,10 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
namespace StorageUtils {
|
||||
|
||||
nsresult GenerateOriginKey(nsIPrincipal* aPrincipal,
|
||||
nsACString& aOriginAttrSuffix,
|
||||
nsACString& aOriginKey);
|
||||
|
||||
bool PrincipalsEqual(nsIPrincipal* aObjectPrincipal,
|
||||
nsIPrincipal* aSubjectPrincipal);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче