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

Side by Side Diff: ios/web/public/referrer_util.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/public/common/referrer.cc ('k') | net/base/sdch_manager.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ios/web/public/referrer_util.h" 5 #include "ios/web/public/referrer_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ios/web/public/referrer.h" 8 #include "ios/web/public/referrer.h"
9 #include "url/gurl.h" 9 #include "url/gurl.h"
10 10
11 namespace web { 11 namespace web {
12 12
13 GURL ReferrerForHeader(const GURL& referrer) { 13 GURL ReferrerForHeader(const GURL& referrer) {
14 DCHECK(referrer.is_valid()); 14 DCHECK(referrer.is_valid());
15 GURL::Replacements replacements; 15 GURL::Replacements replacements;
16 replacements.ClearUsername(); 16 replacements.ClearUsername();
17 replacements.ClearPassword(); 17 replacements.ClearPassword();
18 replacements.ClearRef(); 18 replacements.ClearRef();
19 return referrer.ReplaceComponents(replacements); 19 return referrer.ReplaceComponents(replacements);
20 } 20 }
21 21
22 std::string ReferrerHeaderValueForNavigation( 22 std::string ReferrerHeaderValueForNavigation(
23 const GURL& destination, 23 const GURL& destination,
24 const web::Referrer& referrer) { 24 const web::Referrer& referrer) {
25 std::string referrer_value; 25 std::string referrer_value;
26 bool leaving_secure_scheme = 26 bool leaving_secure_scheme = referrer.url.SchemeIsCryptographic() &&
27 referrer.url.SchemeIsSecure() && !destination.SchemeIsSecure(); 27 !destination.SchemeIsCryptographic();
28 if (referrer.policy == ReferrerPolicyAlways || 28 if (referrer.policy == ReferrerPolicyAlways ||
29 (referrer.policy == ReferrerPolicyDefault && !leaving_secure_scheme)) { 29 (referrer.policy == ReferrerPolicyDefault && !leaving_secure_scheme)) {
30 if (referrer.url.is_valid()) 30 if (referrer.url.is_valid())
31 referrer_value = ReferrerForHeader(referrer.url).spec(); 31 referrer_value = ReferrerForHeader(referrer.url).spec();
32 } else if (referrer.policy == ReferrerPolicyOrigin) { 32 } else if (referrer.policy == ReferrerPolicyOrigin) {
33 referrer_value = referrer.url.GetOrigin().spec(); 33 referrer_value = referrer.url.GetOrigin().spec();
34 } else { 34 } else {
35 // Policy is Never, or it's Default with a secure->insecure transition, so 35 // Policy is Never, or it's Default with a secure->insecure transition, so
36 // leave it empty. 36 // leave it empty.
37 } 37 }
(...skipping 28 matching lines...) Expand all
66 if (policy == "never") 66 if (policy == "never")
67 return ReferrerPolicyNever; 67 return ReferrerPolicyNever;
68 if (policy == "always") 68 if (policy == "always")
69 return ReferrerPolicyAlways; 69 return ReferrerPolicyAlways;
70 if (policy == "origin") 70 if (policy == "origin")
71 return ReferrerPolicyOrigin; 71 return ReferrerPolicyOrigin;
72 return web::ReferrerPolicyDefault; 72 return web::ReferrerPolicyDefault;
73 } 73 }
74 74
75 } // namespace web 75 } // namespace web
OLDNEW
« no previous file with comments | « content/public/common/referrer.cc ('k') | net/base/sdch_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698