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

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: Remove debug logging. 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
Index: Source/core/html/HTMLAnchorElement.cpp
diff --git a/Source/core/html/HTMLAnchorElement.cpp b/Source/core/html/HTMLAnchorElement.cpp
index 59c3697985672a09cd15bb8b49d6d8e2cf86a226..716274c128629aed1c793f96e7da5c3c537c8d94 100644
--- a/Source/core/html/HTMLAnchorElement.cpp
+++ b/Source/core/html/HTMLAnchorElement.cpp
@@ -38,6 +38,7 @@
#include "core/page/Chrome.h"
#include "core/page/ChromeClient.h"
#include "platform/network/NetworkHints.h"
+#include "platform/weborigin/ReferrerPolicy.h"
namespace blink {
@@ -358,8 +359,22 @@ void HTMLAnchorElement::handleClick(Event* event)
request.setRequestContext(WebURLRequest::RequestContextHyperlink);
FrameLoadRequest frameRequest(&document(), request, getAttribute(targetAttr));
frameRequest.setTriggeringEvent(event);
- if (hasRel(RelationNoReferrer))
- frameRequest.setShouldSendReferrer(NeverSendReferrer);
+
+ // TODO(burnik): Most of this section should be reused for any other type of navigation and resource loading.
+ // Inherit the policy from the document.
+ ReferrerPolicy referrerPolicyForRequest = document().referrerPolicy();
+ // We keep it strict. If there is a rel attribute saying 'noreferrer', that takes precedence.
+ if (hasRel(RelationNoReferrer)) {
+ referrerPolicyForRequest = ReferrerPolicyNever;
+ } else if (hasAttribute(referrerAttr)) {
+ const AtomicString& referrerPolicy = fastGetAttribute(referrerAttr);
+ if (!ParseReferrerPolicy(referrerPolicy.string(), &referrerPolicyForRequest)) {
+ // TODO(burnik): Possibly add a warning to the console?
+ ASSERT(referrerPolicyForRequest == document().referrerPolicy());
+ }
+ }
+
+ frameRequest.setReferrerPolicyForRequest(referrerPolicyForRequest);
frame->loader().load(frameRequest);
}
}

Powered by Google App Engine
This is Rietveld 408576698