/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Serializes/Deserializes non-default values into the suffix format, i.e. // |^key1=value1&key2=value2|. If there are no non-default attributes, this // returns an empty string. void CreateSuffix(nsACString& aStr) const;
// Like CreateSuffix, but returns an atom instead of producing a string.
already_AddRefed<nsAtom> CreateSuffixAtom() const;
// Don't use this method for anything else than debugging! void CreateAnonymizedSuffix(nsACString& aStr) const;
// Populates the attributes from a string like // |uri^key1=value1&key2=value2| and returns the uri without the suffix.
[[nodiscard]] bool PopulateFromOrigin(const nsACString& aOrigin,
nsACString& aOriginNoSuffix);
// Helper function to match mIsPrivateBrowsing to existing private browsing // flags. Once all other flags are removed, this can be removed too. void SyncAttributesWithPrivateBrowsing(bool aInPrivateBrowsing);
// check if "privacy.firstparty.isolate" is enabled. staticinlinebool IsFirstPartyEnabled() { return StaticPrefs::privacy_firstparty_isolate();
}
// check if the access of window.opener across different FPDs is restricted. // We only restrict the access of window.opener when first party isolation // is enabled and "privacy.firstparty.isolate.restrict_opener_access" is on. staticinlinebool IsRestrictOpenerAccessForFPI() { // We always want to restrict window.opener if first party isolation is // disabled. return !StaticPrefs::privacy_firstparty_isolate() ||
StaticPrefs::privacy_firstparty_isolate_restrict_opener_access();
}
// Check whether we block the postMessage across different FPDs when the // targetOrigin is '*'.
[[nodiscard]] staticinlinebool IsBlockPostMessageForFPI() { return StaticPrefs::privacy_firstparty_isolate() &&
StaticPrefs::privacy_firstparty_isolate_block_post_message();
}
// returns true if the originAttributes suffix has mPrivateBrowsingId value // different than 0. staticbool IsPrivateBrowsing(const nsACString& aOrigin);
// Parse a partitionKey of the format // "(<scheme>,<baseDomain>,[port],[ancestorbit])" into its components. Returns // false if the partitionKey cannot be parsed because the format is invalid. staticbool ParsePartitionKey(const nsAString& aPartitionKey,
nsAString& outScheme, nsAString& outBaseDomain,
int32_t& outPort, bool& outForeignByAncestorContext);
// Parse a partitionKey and extract the site from it. Returns false if the // partitionKey cannot be parsed because the format is invalid. staticbool ExtractSiteFromPartitionKey(const nsAString& aPartitionKey,
nsAString& aOutSite);
};
class OriginAttributesPattern : public dom::OriginAttributesPatternDictionary { public: // To convert a JSON string to an OriginAttributesPattern, do the following: // // OriginAttributesPattern pattern; // if (!pattern.Init(aJSONString)) { // ... // handle failure. // }
OriginAttributesPattern() = default;
// Performs a match of |aAttrs| against this pattern. bool Matches(const OriginAttributes& aAttrs) const { if (mUserContextId.WasPassed() &&
mUserContextId.Value() != aAttrs.mUserContextId) { returnfalse;
}
if (mPrivateBrowsingId.WasPassed() &&
mPrivateBrowsingId.Value() != aAttrs.mPrivateBrowsingId) { returnfalse;
}
if (mFirstPartyDomain.WasPassed() &&
mFirstPartyDomain.Value() != aAttrs.mFirstPartyDomain) { returnfalse;
}
if (mGeckoViewSessionContextId.WasPassed() &&
mGeckoViewSessionContextId.Value() !=
aAttrs.mGeckoViewSessionContextId) { returnfalse;
}
// If both mPartitionKey and mPartitionKeyPattern are passed, mPartitionKey // takes precedence. if (mPartitionKey.WasPassed()) { if (mPartitionKey.Value() != aAttrs.mPartitionKey) { returnfalse;
}
} elseif (mPartitionKeyPattern.WasPassed()) { auto& pkPattern = mPartitionKeyPattern.Value();
if (pkPattern.mScheme.WasPassed() || pkPattern.mBaseDomain.WasPassed() ||
pkPattern.mPort.WasPassed()) { if (aAttrs.mPartitionKey.IsEmpty()) { returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.