OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 RefPtr<SecurityOrigin> referrerOrigin = | 158 RefPtr<SecurityOrigin> referrerOrigin = |
159 SecurityOrigin::createFromString(referrer); | 159 SecurityOrigin::createFromString(referrer); |
160 RefPtr<SecurityOrigin> urlOrigin = SecurityOrigin::create(url); | 160 RefPtr<SecurityOrigin> urlOrigin = SecurityOrigin::create(url); |
161 if (!urlOrigin->isSameSchemeHostPort(referrerOrigin.get())) { | 161 if (!urlOrigin->isSameSchemeHostPort(referrerOrigin.get())) { |
162 String origin = referrerOrigin->toString(); | 162 String origin = referrerOrigin->toString(); |
163 return Referrer(origin + "/", referrerPolicyNoDefault); | 163 return Referrer(origin + "/", referrerPolicyNoDefault); |
164 } | 164 } |
165 break; | 165 break; |
166 } | 166 } |
167 case ReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin: { | 167 case ReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin: { |
168 // If the flag is enabled, and we're dealing with a cross-origin request,
strip it. | 168 // If the flag is enabled, and we're dealing with a cross-origin request, |
169 // Otherwise fallthrough to NoReferrerWhenDowngrade behavior. | 169 // strip it. Otherwise fall through to NoReferrerWhenDowngrade behavior. |
170 RefPtr<SecurityOrigin> referrerOrigin = | 170 RefPtr<SecurityOrigin> referrerOrigin = |
171 SecurityOrigin::createFromString(referrer); | 171 SecurityOrigin::createFromString(referrer); |
172 RefPtr<SecurityOrigin> urlOrigin = SecurityOrigin::create(url); | 172 RefPtr<SecurityOrigin> urlOrigin = SecurityOrigin::create(url); |
173 if (!urlOrigin->isSameSchemeHostPort(referrerOrigin.get())) { | 173 if (!urlOrigin->isSameSchemeHostPort(referrerOrigin.get())) { |
174 String origin = referrerOrigin->toString(); | 174 String origin = referrerOrigin->toString(); |
175 return Referrer(shouldHideReferrer(url, referrer) | 175 return Referrer(shouldHideReferrer(url, referrer) |
176 ? Referrer::noReferrer() | 176 ? Referrer::noReferrer() |
177 : origin + "/", | 177 : origin + "/", |
178 referrerPolicyNoDefault); | 178 referrerPolicyNoDefault); |
179 } | 179 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 293 } |
294 | 294 |
295 bool SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords( | 295 bool SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords( |
296 const String& policy, | 296 const String& policy, |
297 ReferrerPolicy* result) { | 297 ReferrerPolicy* result) { |
298 return referrerPolicyFromStringImpl( | 298 return referrerPolicyFromStringImpl( |
299 policy, SupportReferrerPolicyLegacyKeywords, result); | 299 policy, SupportReferrerPolicyLegacyKeywords, result); |
300 } | 300 } |
301 | 301 |
302 } // namespace blink | 302 } // namespace blink |
OLD | NEW |