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

Side by Side Diff: third_party/WebKit/Source/platform/weborigin/SecurityPolicy.cpp

Issue 2417883002: Avoid initializing a SecurityOrigin from a KURL for isSecure() check. (Closed)
Patch Set: Created 4 years, 2 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 | « third_party/WebKit/Source/platform/weborigin/SecurityPolicy.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
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 trustworthyOriginSet().add(origin->toRawString()); 200 trustworthyOriginSet().add(origin->toRawString());
201 } 201 }
202 202
203 bool SecurityPolicy::isOriginWhiteListedTrustworthy( 203 bool SecurityPolicy::isOriginWhiteListedTrustworthy(
204 const SecurityOrigin& origin) { 204 const SecurityOrigin& origin) {
205 if (origin.isUnique()) 205 if (origin.isUnique())
206 return false; 206 return false;
207 return trustworthyOriginSet().contains(origin.toRawString()); 207 return trustworthyOriginSet().contains(origin.toRawString());
208 } 208 }
209 209
210 bool SecurityPolicy::isUrlWhiteListedTrustworthy(const KURL& url) {
211 // Early return to avoid initializing the SecurityOrigin.
212 if (trustworthyOriginSet().isEmpty())
213 return false;
214 return isOriginWhiteListedTrustworthy(*SecurityOrigin::create(url).get());
215 }
216
210 bool SecurityPolicy::isAccessWhiteListed(const SecurityOrigin* activeOrigin, 217 bool SecurityPolicy::isAccessWhiteListed(const SecurityOrigin* activeOrigin,
211 const SecurityOrigin* targetOrigin) { 218 const SecurityOrigin* targetOrigin) {
212 if (OriginAccessWhiteList* list = 219 if (OriginAccessWhiteList* list =
213 originAccessMap().get(activeOrigin->toString())) { 220 originAccessMap().get(activeOrigin->toString())) {
214 for (size_t i = 0; i < list->size(); ++i) { 221 for (size_t i = 0; i < list->size(); ++i) {
215 if (list->at(i).matchesOrigin(*targetOrigin) != 222 if (list->at(i).matchesOrigin(*targetOrigin) !=
216 OriginAccessEntry::DoesNotMatchOrigin) 223 OriginAccessEntry::DoesNotMatchOrigin)
217 return true; 224 return true;
218 } 225 }
219 } 226 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 300 }
294 301
295 bool SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords( 302 bool SecurityPolicy::referrerPolicyFromStringWithLegacyKeywords(
296 const String& policy, 303 const String& policy,
297 ReferrerPolicy* result) { 304 ReferrerPolicy* result) {
298 return referrerPolicyFromStringImpl( 305 return referrerPolicyFromStringImpl(
299 policy, SupportReferrerPolicyLegacyKeywords, result); 306 policy, SupportReferrerPolicyLegacyKeywords, result);
300 } 307 }
301 308
302 } // namespace blink 309 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/SecurityPolicy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698