Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(962)

Unified Diff: Source/core/html/HTMLAnchorElement.cpp

Issue 1148603002: Anchor element's referrer attribute implementation for Referrer Policy Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fails for right-click opening (new window/tab, etc.) Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/html/HTMLAttributeNames.in » ('j') | Source/core/loader/FrameLoadRequest.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLAnchorElement.cpp
diff --git a/Source/core/html/HTMLAnchorElement.cpp b/Source/core/html/HTMLAnchorElement.cpp
index 59c3697985672a09cd15bb8b49d6d8e2cf86a226..b4cbd8fba5dde58623250013e4749a29d73d64d5 100644
--- a/Source/core/html/HTMLAnchorElement.cpp
+++ b/Source/core/html/HTMLAnchorElement.cpp
@@ -358,8 +358,29 @@ void HTMLAnchorElement::handleClick(Event* event)
request.setRequestContext(WebURLRequest::RequestContextHyperlink);
FrameLoadRequest frameRequest(&document(), request, getAttribute(targetAttr));
frameRequest.setTriggeringEvent(event);
- if (hasRel(RelationNoReferrer))
- frameRequest.setShouldSendReferrer(NeverSendReferrer);
Mike West 2015/05/20 07:56:41 Is `ShouldSendReferrer` actually used after this p
burnik 2015/05/20 08:27:56 I think it should be removed completely. Yesterday
burnik 2015/05/20 13:45:18 Done.
+ // We keep it strict. If there is a rel attribute saying 'noreferrer', that takes precedence.
+ if (hasRel(RelationNoReferrer)) {
+ frameRequest.setReferrerPolicyForRequest(ReferrerPolicyNever);
+ } else if (hasAttribute(referrerAttr)) {
+ const AtomicString& referrerPolicy = fastGetAttribute(referrerAttr);
+ ReferrerPolicy referrerPolicyForRequest = ReferrerPolicyNoReferrerWhenDowngrade;
Mike West 2015/05/20 07:56:41 Nit: You can pull this out of the `if`, set `refer
burnik 2015/05/20 08:27:55 Yes, I've seen it earlier, this initial approach w
+
+ // FIXME: This string parsing should be implemented in one place and
Mike West 2015/05/20 07:56:41 Nit: s/FIXME/TODO(burnik)/
burnik 2015/05/20 08:27:55 Done.
+ // not duplicated from |blink::Document::processReferrerPolicy|.
Mike West 2015/05/20 07:56:41 Perhaps you could extract this out to a method in
burnik 2015/05/20 08:27:55 Yes, the FIXME(TODO) actually instructs me to do s
+ if (equalIgnoringCase(referrerPolicy, "no-referrer") || equalIgnoringCase(referrerPolicy, "never"))
+ referrerPolicyForRequest = ReferrerPolicyNever;
+ else if (equalIgnoringCase(referrerPolicy, "unsafe-url") || equalIgnoringCase(referrerPolicy, "always"))
+ referrerPolicyForRequest = ReferrerPolicyAlways;
+ else if (equalIgnoringCase(referrerPolicy, "origin"))
+ referrerPolicyForRequest = ReferrerPolicyOrigin;
+ else if (equalIgnoringCase(referrerPolicy, "origin-when-cross-origin") || equalIgnoringCase(referrerPolicy, "origin-when-crossorigin"))
+ referrerPolicyForRequest = ReferrerPolicyOriginWhenCrossOrigin;
+ else if (equalIgnoringCase(referrerPolicy, "no-referrer-when-downgrade") || equalIgnoringCase(referrerPolicy, "default"))
+ referrerPolicyForRequest = ReferrerPolicyNoReferrerWhenDowngrade;
+
+ frameRequest.setReferrerPolicyForRequest(referrerPolicyForRequest);
+ }
+
frame->loader().load(frameRequest);
}
}
« no previous file with comments | « no previous file | Source/core/html/HTMLAttributeNames.in » ('j') | Source/core/loader/FrameLoadRequest.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698