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

Side by Side Diff: content/public/common/referrer.cc

Issue 716813002: Referrer Policy: Update SanitizeForRequest with new default behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 unified diff | Download patch
« no previous file with comments | « content/public/common/referrer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "content/public/common/content_switches.h"
7 #include "content/public/common/referrer.h"
8
9 namespace content {
10
11 // static.
12 Referrer Referrer::SanitizeForRequest(const GURL& request,
13 const Referrer& referrer) {
14 Referrer sanitized_referrer(referrer.url.GetAsReferrer(), referrer.policy);
15
16 if (!request.SchemeIsHTTPOrHTTPS() ||
17 !sanitized_referrer.url.SchemeIsHTTPOrHTTPS()) {
18 sanitized_referrer.url = GURL();
19 return sanitized_referrer;
20 }
21
22 bool is_downgrade =
23 sanitized_referrer.url.SchemeIsSecure() && !request.SchemeIsSecure();
24
25 switch (sanitized_referrer.policy) {
26 case blink::WebReferrerPolicyDefault:
27 if (is_downgrade) {
28 sanitized_referrer.url = GURL();
29 } else if (request.GetOrigin() != sanitized_referrer.url.GetOrigin() &&
30 base::CommandLine::ForCurrentProcess()->HasSwitch(
31 switches::kReducedReferrerGranularity)) {
32 sanitized_referrer.url = sanitized_referrer.url.GetOrigin();
33 }
34 break;
35 case blink::WebReferrerPolicyNoReferrerWhenDowngrade:
36 if (is_downgrade)
37 sanitized_referrer.url = GURL();
38 break;
39 case blink::WebReferrerPolicyAlways:
40 break;
41 case blink::WebReferrerPolicyNever:
42 sanitized_referrer.url = GURL();
43 break;
44 case blink::WebReferrerPolicyOrigin:
45 sanitized_referrer.url = sanitized_referrer.url.GetOrigin();
46 break;
47 default:
48 NOTREACHED();
49 break;
50 }
51 return sanitized_referrer;
52 }
53
54 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/referrer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698