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

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

Issue 1253413003: Implement referrerpolicy attribute for anchor elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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 0e49c829ee7e3e136e827760e1bceabc25431131..083ee0a44df4fa5ba23d556e922748a7c69495ed 100644
--- a/Source/core/html/HTMLAnchorElement.cpp
+++ b/Source/core/html/HTMLAnchorElement.cpp
@@ -37,6 +37,7 @@
#include "core/loader/PingLoader.h"
#include "core/page/ChromeClient.h"
#include "platform/network/NetworkHints.h"
+#include "platform/weborigin/SecurityPolicy.h"
namespace blink {
@@ -348,6 +349,12 @@ void HTMLAnchorElement::handleClick(Event* event)
ResourceRequest request(completedURL);
request.setUIStartTime(event->uiCreateTime());
request.setInputPerfMetricReportPolicy(InputToLoadPerfMetricReportPolicy::ReportLink);
+
+ ReferrerPolicy policy;
+ if (hasAttribute(referrerpolicyAttr) && SecurityPolicy::referrerPolicyFromString(fastGetAttribute(referrerpolicyAttr), &policy)) {
+ request.setHTTPReferrer(SecurityPolicy::generateReferrer(policy, completedURL, document().outgoingReferrer()));
+ }
+
if (hasAttribute(downloadAttr)) {
request.setRequestContext(WebURLRequest::RequestContextDownload);
bool isSameOrigin = completedURL.protocolIsData() || document().securityOrigin()->canRequest(completedURL);

Powered by Google App Engine
This is Rietveld 408576698