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

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

Issue 1098983003: Switch SchemeIsSecure to SchemeIsCryptographic for referrer-related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « content/child/resource_dispatcher.cc ('k') | ios/web/public/referrer_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "content/public/common/content_switches.h" 6 #include "content/public/common/content_switches.h"
7 #include "content/public/common/referrer.h" 7 #include "content/public/common/referrer.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 // static. 11 // static.
12 Referrer Referrer::SanitizeForRequest(const GURL& request, 12 Referrer Referrer::SanitizeForRequest(const GURL& request,
13 const Referrer& referrer) { 13 const Referrer& referrer) {
14 Referrer sanitized_referrer(referrer.url.GetAsReferrer(), referrer.policy); 14 Referrer sanitized_referrer(referrer.url.GetAsReferrer(), referrer.policy);
15 15
16 if (!request.SchemeIsHTTPOrHTTPS() || 16 if (!request.SchemeIsHTTPOrHTTPS() ||
17 !sanitized_referrer.url.SchemeIsHTTPOrHTTPS()) { 17 !sanitized_referrer.url.SchemeIsHTTPOrHTTPS()) {
18 sanitized_referrer.url = GURL(); 18 sanitized_referrer.url = GURL();
19 return sanitized_referrer; 19 return sanitized_referrer;
20 } 20 }
21 21
22 bool is_downgrade = 22 bool is_downgrade = sanitized_referrer.url.SchemeIsCryptographic() &&
23 sanitized_referrer.url.SchemeIsSecure() && !request.SchemeIsSecure(); 23 !request.SchemeIsCryptographic();
24 24
25 if (sanitized_referrer.policy < 0 || 25 if (sanitized_referrer.policy < 0 ||
26 sanitized_referrer.policy > blink::WebReferrerPolicyLast) { 26 sanitized_referrer.policy > blink::WebReferrerPolicyLast) {
27 NOTREACHED(); 27 NOTREACHED();
28 sanitized_referrer.policy = blink::WebReferrerPolicyNever; 28 sanitized_referrer.policy = blink::WebReferrerPolicyNever;
29 } 29 }
30 30
31 switch (sanitized_referrer.policy) { 31 switch (sanitized_referrer.policy) {
32 case blink::WebReferrerPolicyDefault: 32 case blink::WebReferrerPolicyDefault:
33 if (is_downgrade) { 33 if (is_downgrade) {
(...skipping 18 matching lines...) Expand all
52 break; 52 break;
53 case blink::WebReferrerPolicyOriginWhenCrossOrigin: 53 case blink::WebReferrerPolicyOriginWhenCrossOrigin:
54 if (request.GetOrigin() != sanitized_referrer.url.GetOrigin()) 54 if (request.GetOrigin() != sanitized_referrer.url.GetOrigin())
55 sanitized_referrer.url = sanitized_referrer.url.GetOrigin(); 55 sanitized_referrer.url = sanitized_referrer.url.GetOrigin();
56 break; 56 break;
57 } 57 }
58 return sanitized_referrer; 58 return sanitized_referrer;
59 } 59 }
60 60
61 } // namespace content 61 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher.cc ('k') | ios/web/public/referrer_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698