| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "platform/weborigin/SecurityOrigin.h" | 36 #include "platform/weborigin/SecurityOrigin.h" |
| 37 #include "wtf/PtrUtil.h" | 37 #include "wtf/PtrUtil.h" |
| 38 #include "wtf/Threading.h" | 38 #include "wtf/Threading.h" |
| 39 #include "wtf/text/AtomicString.h" | 39 #include "wtf/text/AtomicString.h" |
| 40 #include "wtf/text/StringBuilder.h" | 40 #include "wtf/text/StringBuilder.h" |
| 41 #include <algorithm> | 41 #include <algorithm> |
| 42 #include <memory> | 42 #include <memory> |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 static std::unique_ptr<HTTPHeaderSet> createAllowedCrossOriginResponseHeadersSet
() | |
| 47 { | |
| 48 std::unique_ptr<HTTPHeaderSet> headerSet = wrapUnique(new HashSet<String, Ca
seFoldingHash>); | |
| 49 | |
| 50 headerSet->add("cache-control"); | |
| 51 headerSet->add("content-language"); | |
| 52 headerSet->add("content-type"); | |
| 53 headerSet->add("expires"); | |
| 54 headerSet->add("last-modified"); | |
| 55 headerSet->add("pragma"); | |
| 56 | |
| 57 return headerSet; | |
| 58 } | |
| 59 | |
| 60 bool isOnAccessControlResponseHeaderWhitelist(const String& name) | 46 bool isOnAccessControlResponseHeaderWhitelist(const String& name) |
| 61 { | 47 { |
| 62 DEFINE_THREAD_SAFE_STATIC_LOCAL(HTTPHeaderSet, allowedCrossOriginResponseHea
ders, (createAllowedCrossOriginResponseHeadersSet().release())); | 48 DEFINE_THREAD_SAFE_STATIC_LOCAL(HTTPHeaderSet, allowedCrossOriginResponseHea
ders, (new HTTPHeaderSet({ |
| 63 | 49 "cache-control", |
| 50 "content-language", |
| 51 "content-type", |
| 52 "expires", |
| 53 "last-modified", |
| 54 "pragma", |
| 55 }))); |
| 64 return allowedCrossOriginResponseHeaders.contains(name); | 56 return allowedCrossOriginResponseHeaders.contains(name); |
| 65 } | 57 } |
| 66 | 58 |
| 67 void updateRequestForAccessControl(ResourceRequest& request, SecurityOrigin* sec
urityOrigin, StoredCredentials allowCredentials) | 59 void updateRequestForAccessControl(ResourceRequest& request, SecurityOrigin* sec
urityOrigin, StoredCredentials allowCredentials) |
| 68 { | 60 { |
| 69 request.removeCredentials(); | 61 request.removeCredentials(); |
| 70 request.setAllowStoredCredentials(allowCredentials == AllowStoredCredentials
); | 62 request.setAllowStoredCredentials(allowCredentials == AllowStoredCredentials
); |
| 71 | 63 |
| 72 if (securityOrigin) | 64 if (securityOrigin) |
| 73 request.setHTTPOrigin(securityOrigin); | 65 request.setHTTPOrigin(securityOrigin); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 newRequest.setHTTPOrigin(securityOrigin); | 320 newRequest.setHTTPOrigin(securityOrigin); |
| 329 // If the user didn't request credentials in the first place, update our | 321 // If the user didn't request credentials in the first place, update our |
| 330 // state so we neither request them nor expect they must be allowed. | 322 // state so we neither request them nor expect they must be allowed. |
| 331 if (options.credentialsRequested == ClientDidNotRequestCredentials) | 323 if (options.credentialsRequested == ClientDidNotRequestCredentials) |
| 332 options.allowCredentials = DoNotAllowStoredCredentials; | 324 options.allowCredentials = DoNotAllowStoredCredentials; |
| 333 } | 325 } |
| 334 return true; | 326 return true; |
| 335 } | 327 } |
| 336 | 328 |
| 337 } // namespace blink | 329 } // namespace blink |
| OLD | NEW |