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

Unified Diff: Source/platform/weborigin/SecurityPolicy.cpp

Issue 684683003: Referrer Policy: Add a flag to reduce `referer` granularity by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@default
Patch Set: Created 6 years, 1 month 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 | « Source/platform/RuntimeEnabledFeatures.in ('k') | Source/web/WebRuntimeFeatures.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/weborigin/SecurityPolicy.cpp
diff --git a/Source/platform/weborigin/SecurityPolicy.cpp b/Source/platform/weborigin/SecurityPolicy.cpp
index 92101a7207be0db1202144c443b14e5f3bb0a13e..631b1bbdcf78f064f97bda8f079a3e6772de8a4a 100644
--- a/Source/platform/weborigin/SecurityPolicy.cpp
+++ b/Source/platform/weborigin/SecurityPolicy.cpp
@@ -29,6 +29,7 @@
#include "config.h"
#include "platform/weborigin/SecurityPolicy.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/weborigin/KURL.h"
#include "platform/weborigin/OriginAccessEntry.h"
#include "platform/weborigin/SecurityOrigin.h"
@@ -86,7 +87,18 @@ Referrer SecurityPolicy::generateReferrer(ReferrerPolicy referrerPolicy, const K
// to turn it into a canonical URL we can use as referrer.
return Referrer(origin + "/", referrerPolicy);
}
- case ReferrerPolicyDefault:
+ case ReferrerPolicyDefault: {
+ // If the flag is enabled, and we're dealing with a cross-origin request, strip it.
+ // Otherwise fallthrough to NoReferrerWhenDowngrade behavior.
+ RefPtr<SecurityOrigin> referrerOrigin = SecurityOrigin::createFromString(referrer);
+ RefPtr<SecurityOrigin> urlOrigin = SecurityOrigin::create(url);
+ if (RuntimeEnabledFeatures::reducedReferrerGranularityEnabled() && !urlOrigin->isSameSchemeHostPort(referrerOrigin.get())) {
+ String origin = referrerOrigin->toString();
+ if (origin == "null")
+ return Referrer(String(), referrerPolicy);
+ return Referrer(shouldHideReferrer(url, referrer) ? String() : origin + "/", referrerPolicy);
jochen (gone - plz use gerrit) 2014/11/10 14:53:19 why not NoReferrerWhenDowngrade instead of referre
jochen (gone - plz use gerrit) 2014/11/10 14:53:19 why not NoReferrerWhenDowngrade instead of referre
Mike West 2014/11/10 15:13:45 Because that would break the eventual redirect pro
+ }
+ }
case ReferrerPolicyNoReferrerWhenDowngrade:
break;
}
« no previous file with comments | « Source/platform/RuntimeEnabledFeatures.in ('k') | Source/web/WebRuntimeFeatures.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698