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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 if (referrer_policy_no_default == kReferrerPolicyDefault) { | 85 if (referrer_policy_no_default == kReferrerPolicyDefault) { |
86 if (RuntimeEnabledFeatures::reducedReferrerGranularityEnabled()) { | 86 if (RuntimeEnabledFeatures::reducedReferrerGranularityEnabled()) { |
87 referrer_policy_no_default = | 87 referrer_policy_no_default = |
88 kReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin; | 88 kReferrerPolicyNoReferrerWhenDowngradeOriginWhenCrossOrigin; |
89 } else { | 89 } else { |
90 referrer_policy_no_default = kReferrerPolicyNoReferrerWhenDowngrade; | 90 referrer_policy_no_default = kReferrerPolicyNoReferrerWhenDowngrade; |
91 } | 91 } |
92 } | 92 } |
93 if (referrer == Referrer::NoReferrer()) | 93 if (referrer == Referrer::NoReferrer()) |
94 return Referrer(Referrer::NoReferrer(), referrer_policy_no_default); | 94 return Referrer(Referrer::NoReferrer(), referrer_policy_no_default); |
95 ASSERT(!referrer.IsEmpty()); | 95 DCHECK(!referrer.IsEmpty()); |
96 | 96 |
97 KURL referrer_url = KURL(KURL(), referrer); | 97 KURL referrer_url = KURL(KURL(), referrer); |
98 String scheme = referrer_url.Protocol(); | 98 String scheme = referrer_url.Protocol(); |
99 if (!SchemeRegistry::ShouldTreatURLSchemeAsAllowedForReferrer(scheme)) | 99 if (!SchemeRegistry::ShouldTreatURLSchemeAsAllowedForReferrer(scheme)) |
100 return Referrer(Referrer::NoReferrer(), referrer_policy_no_default); | 100 return Referrer(Referrer::NoReferrer(), referrer_policy_no_default); |
101 | 101 |
102 if (SecurityOrigin::ShouldUseInnerURL(url)) | 102 if (SecurityOrigin::ShouldUseInnerURL(url)) |
103 return Referrer(Referrer::NoReferrer(), referrer_policy_no_default); | 103 return Referrer(Referrer::NoReferrer(), referrer_policy_no_default); |
104 | 104 |
105 switch (referrer_policy_no_default) { | 105 switch (referrer_policy_no_default) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 const KURL& url) { | 195 const KURL& url) { |
196 RefPtr<SecurityOrigin> target_origin = SecurityOrigin::Create(url); | 196 RefPtr<SecurityOrigin> target_origin = SecurityOrigin::Create(url); |
197 return IsAccessWhiteListed(active_origin, target_origin.Get()); | 197 return IsAccessWhiteListed(active_origin, target_origin.Get()); |
198 } | 198 } |
199 | 199 |
200 void SecurityPolicy::AddOriginAccessWhitelistEntry( | 200 void SecurityPolicy::AddOriginAccessWhitelistEntry( |
201 const SecurityOrigin& source_origin, | 201 const SecurityOrigin& source_origin, |
202 const String& destination_protocol, | 202 const String& destination_protocol, |
203 const String& destination_domain, | 203 const String& destination_domain, |
204 bool allow_destination_subdomains) { | 204 bool allow_destination_subdomains) { |
205 ASSERT(IsMainThread()); | 205 DCHECK(IsMainThread()); |
206 ASSERT(!source_origin.IsUnique()); | 206 DCHECK(!source_origin.IsUnique()); |
207 if (source_origin.IsUnique()) | 207 if (source_origin.IsUnique()) |
208 return; | 208 return; |
209 | 209 |
210 String source_string = source_origin.ToString(); | 210 String source_string = source_origin.ToString(); |
211 OriginAccessMap::AddResult result = | 211 OriginAccessMap::AddResult result = |
212 GetOriginAccessMap().insert(source_string, nullptr); | 212 GetOriginAccessMap().insert(source_string, nullptr); |
213 if (result.is_new_entry) | 213 if (result.is_new_entry) |
214 result.stored_value->value = WTF::WrapUnique(new OriginAccessWhiteList); | 214 result.stored_value->value = WTF::WrapUnique(new OriginAccessWhiteList); |
215 | 215 |
216 OriginAccessWhiteList* list = result.stored_value->value.get(); | 216 OriginAccessWhiteList* list = result.stored_value->value.get(); |
217 list->push_back(OriginAccessEntry( | 217 list->push_back(OriginAccessEntry( |
218 destination_protocol, destination_domain, | 218 destination_protocol, destination_domain, |
219 allow_destination_subdomains ? OriginAccessEntry::kAllowSubdomains | 219 allow_destination_subdomains ? OriginAccessEntry::kAllowSubdomains |
220 : OriginAccessEntry::kDisallowSubdomains)); | 220 : OriginAccessEntry::kDisallowSubdomains)); |
221 } | 221 } |
222 | 222 |
223 void SecurityPolicy::RemoveOriginAccessWhitelistEntry( | 223 void SecurityPolicy::RemoveOriginAccessWhitelistEntry( |
224 const SecurityOrigin& source_origin, | 224 const SecurityOrigin& source_origin, |
225 const String& destination_protocol, | 225 const String& destination_protocol, |
226 const String& destination_domain, | 226 const String& destination_domain, |
227 bool allow_destination_subdomains) { | 227 bool allow_destination_subdomains) { |
228 ASSERT(IsMainThread()); | 228 DCHECK(IsMainThread()); |
229 ASSERT(!source_origin.IsUnique()); | 229 DCHECK(!source_origin.IsUnique()); |
230 if (source_origin.IsUnique()) | 230 if (source_origin.IsUnique()) |
231 return; | 231 return; |
232 | 232 |
233 String source_string = source_origin.ToString(); | 233 String source_string = source_origin.ToString(); |
234 OriginAccessMap& map = GetOriginAccessMap(); | 234 OriginAccessMap& map = GetOriginAccessMap(); |
235 OriginAccessMap::iterator it = map.find(source_string); | 235 OriginAccessMap::iterator it = map.find(source_string); |
236 if (it == map.end()) | 236 if (it == map.end()) |
237 return; | 237 return; |
238 | 238 |
239 OriginAccessWhiteList* list = it->value.get(); | 239 OriginAccessWhiteList* list = it->value.get(); |
240 size_t index = list->Find(OriginAccessEntry( | 240 size_t index = list->Find(OriginAccessEntry( |
241 destination_protocol, destination_domain, | 241 destination_protocol, destination_domain, |
242 allow_destination_subdomains ? OriginAccessEntry::kAllowSubdomains | 242 allow_destination_subdomains ? OriginAccessEntry::kAllowSubdomains |
243 : OriginAccessEntry::kDisallowSubdomains)); | 243 : OriginAccessEntry::kDisallowSubdomains)); |
244 | 244 |
245 if (index == kNotFound) | 245 if (index == kNotFound) |
246 return; | 246 return; |
247 | 247 |
248 list->erase(index); | 248 list->erase(index); |
249 | 249 |
250 if (list->IsEmpty()) | 250 if (list->IsEmpty()) |
251 map.erase(it); | 251 map.erase(it); |
252 } | 252 } |
253 | 253 |
254 void SecurityPolicy::ResetOriginAccessWhitelists() { | 254 void SecurityPolicy::ResetOriginAccessWhitelists() { |
255 ASSERT(IsMainThread()); | 255 DCHECK(IsMainThread()); |
256 GetOriginAccessMap().clear(); | 256 GetOriginAccessMap().clear(); |
257 } | 257 } |
258 | 258 |
259 bool SecurityPolicy::ReferrerPolicyFromString( | 259 bool SecurityPolicy::ReferrerPolicyFromString( |
260 const String& policy, | 260 const String& policy, |
261 ReferrerPolicyLegacyKeywordsSupport legacy_keywords_support, | 261 ReferrerPolicyLegacyKeywordsSupport legacy_keywords_support, |
262 ReferrerPolicy* result) { | 262 ReferrerPolicy* result) { |
263 DCHECK(!policy.IsNull()); | 263 DCHECK(!policy.IsNull()); |
264 bool support_legacy_keywords = | 264 bool support_legacy_keywords = |
265 (legacy_keywords_support == kSupportReferrerPolicyLegacyKeywords); | 265 (legacy_keywords_support == kSupportReferrerPolicyLegacyKeywords); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 310 } |
311 | 311 |
312 if (referrer_policy == kReferrerPolicyDefault) | 312 if (referrer_policy == kReferrerPolicyDefault) |
313 return false; | 313 return false; |
314 | 314 |
315 *result = referrer_policy; | 315 *result = referrer_policy; |
316 return true; | 316 return true; |
317 } | 317 } |
318 | 318 |
319 } // namespace blink | 319 } // namespace blink |
OLD | NEW |