OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013, Intel Corporation | 3 * Copyright (C) 2013, Intel Corporation |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 | 250 |
251 // We use isSimpleOrForbiddenRequest() here since |request| may have been | 251 // We use isSimpleOrForbiddenRequest() here since |request| may have been |
252 // modified in the process of loading (not from the user's input). For | 252 // modified in the process of loading (not from the user's input). For |
253 // example, referrer. We need to accept them. For security, we must reject | 253 // example, referrer. We need to accept them. For security, we must reject |
254 // forbidden headers/methods at the point we accept user's input. Not here. | 254 // forbidden headers/methods at the point we accept user's input. Not here. |
255 if ((m_options.preflightPolicy == ConsiderPreflight && FetchUtils::isSimpleO
rForbiddenRequest(request.httpMethod(), request.httpHeaderFields())) || m_option
s.preflightPolicy == PreventPreflight) { | 255 if ((m_options.preflightPolicy == ConsiderPreflight && FetchUtils::isSimpleO
rForbiddenRequest(request.httpMethod(), request.httpHeaderFields())) || m_option
s.preflightPolicy == PreventPreflight) { |
256 ResourceRequest crossOriginRequest(request); | 256 ResourceRequest crossOriginRequest(request); |
257 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); | 257 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); |
258 updateRequestForAccessControl(crossOriginRequest, securityOrigin(), effe
ctiveAllowCredentials()); | 258 updateRequestForAccessControl(crossOriginRequest, securityOrigin(), effe
ctiveAllowCredentials()); |
| 259 // We update the credentials mode according to effectiveAllowCredentials
() here for backward compatibility. But this is not correct. |
| 260 // FIXME: We should set it in the caller of DocumentThreadableLoader. |
| 261 crossOriginRequest.setFetchCredentialsMode(effectiveAllowCredentials() =
= AllowStoredCredentials ? WebURLRequest::FetchCredentialsModeInclude : WebURLRe
quest::FetchCredentialsModeOmit); |
259 loadRequest(crossOriginRequest, crossOriginOptions); | 262 loadRequest(crossOriginRequest, crossOriginOptions); |
260 } else { | 263 } else { |
261 m_crossOriginNonSimpleRequest = true; | 264 m_crossOriginNonSimpleRequest = true; |
262 | 265 |
263 ResourceRequest crossOriginRequest(request); | 266 ResourceRequest crossOriginRequest(request); |
264 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); | 267 ResourceLoaderOptions crossOriginOptions(m_resourceLoaderOptions); |
265 // Do not set the Origin header for preflight requests. | 268 // Do not set the Origin header for preflight requests. |
266 updateRequestForAccessControl(crossOriginRequest, 0, effectiveAllowCrede
ntials()); | 269 updateRequestForAccessControl(crossOriginRequest, 0, effectiveAllowCrede
ntials()); |
| 270 // We update the credentials mode according to effectiveAllowCredentials
() here for backward compatibility. But this is not correct. |
| 271 // FIXME: We should set it in the caller of DocumentThreadableLoader. |
| 272 crossOriginRequest.setFetchCredentialsMode(effectiveAllowCredentials() =
= AllowStoredCredentials ? WebURLRequest::FetchCredentialsModeInclude : WebURLRe
quest::FetchCredentialsModeOmit); |
267 m_actualRequest = crossOriginRequest; | 273 m_actualRequest = crossOriginRequest; |
268 m_actualOptions = crossOriginOptions; | 274 m_actualOptions = crossOriginOptions; |
269 | 275 |
270 bool shouldForcePreflight = InspectorInstrumentation::shouldForceCORSPre
flight(m_document); | 276 bool shouldForcePreflight = InspectorInstrumentation::shouldForceCORSPre
flight(m_document); |
271 bool canSkipPreflight = CrossOriginPreflightResultCache::shared().canSki
pPreflight(securityOrigin()->toString(), m_actualRequest.url(), effectiveAllowCr
edentials(), m_actualRequest.httpMethod(), m_actualRequest.httpHeaderFields()); | 277 bool canSkipPreflight = CrossOriginPreflightResultCache::shared().canSki
pPreflight(securityOrigin()->toString(), m_actualRequest.url(), effectiveAllowCr
edentials(), m_actualRequest.httpMethod(), m_actualRequest.httpHeaderFields()); |
272 if (canSkipPreflight && !shouldForcePreflight) { | 278 if (canSkipPreflight && !shouldForcePreflight) { |
273 loadActualRequest(); | 279 loadActualRequest(); |
274 } else { | 280 } else { |
275 ResourceRequest preflightRequest = createAccessControlPreflightReque
st(m_actualRequest, securityOrigin()); | 281 ResourceRequest preflightRequest = createAccessControlPreflightReque
st(m_actualRequest, securityOrigin()); |
276 // Create a ResourceLoaderOptions for preflight. | 282 // Create a ResourceLoaderOptions for preflight. |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin
(); | 889 return m_securityOrigin ? m_securityOrigin.get() : document().securityOrigin
(); |
884 } | 890 } |
885 | 891 |
886 Document& DocumentThreadableLoader::document() const | 892 Document& DocumentThreadableLoader::document() const |
887 { | 893 { |
888 ASSERT(m_document); | 894 ASSERT(m_document); |
889 return *m_document; | 895 return *m_document; |
890 } | 896 } |
891 | 897 |
892 } // namespace blink | 898 } // namespace blink |
OLD | NEW |