Bug 1174913 - anchor and area referrer attributes. r=ckerschb, r=bz

This commit is contained in:
Franziskus Kiefer
2015-06-05 15:25:24 -07:00
parent 12cb196e3d
commit 07c4ad95f7
11 changed files with 165 additions and 21 deletions

View File

@@ -13515,6 +13515,22 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
nsCOMPtr<nsIURI> referer = refererDoc->GetDocumentURI();
uint32_t refererPolicy = refererDoc->GetReferrerPolicy();
// get referrer attribute from clicked link and parse it
// if per element referrer is enabled, the element referrer overrules
// the document wide referrer
if (IsElementAnchor(aContent)) {
MOZ_ASSERT(aContent->IsHTMLElement());
if (Preferences::GetBool("network.http.enablePerElementReferrer", false)) {
nsAutoString referrerPolicy;
if (aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::referrer, referrerPolicy)) {
uint32_t refPolEnum = mozilla::net::ReferrerPolicyFromString(referrerPolicy);
if (refPolEnum != mozilla::net::RP_Unset) {
refererPolicy = refPolEnum;
}
}
}
}
// referer could be null here in some odd cases, but that's ok,
// we'll just load the link w/o sending a referer in those cases.