Chromium Code Reviews| 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 // example, referrer. We need to accept them. For security, we must reject | 362 // example, referrer. We need to accept them. For security, we must reject |
| 363 // forbidden headers/methods at the point we accept user's input. Not here. | 363 // forbidden headers/methods at the point we accept user's input. Not here. |
| 364 if (!request.isExternalRequest() && | 364 if (!request.isExternalRequest() && |
| 365 ((m_options.preflightPolicy == ConsiderPreflight && | 365 ((m_options.preflightPolicy == ConsiderPreflight && |
| 366 FetchUtils::isSimpleOrForbiddenRequest(request.httpMethod(), | 366 FetchUtils::isSimpleOrForbiddenRequest(request.httpMethod(), |
| 367 request.httpHeaderFields())) || | 367 request.httpHeaderFields())) || |
| 368 m_options.preflightPolicy == PreventPreflight)) { | 368 m_options.preflightPolicy == PreventPreflight)) { |
| 369 prepareCrossOriginRequest(crossOriginRequest); | 369 prepareCrossOriginRequest(crossOriginRequest); |
| 370 loadRequest(crossOriginRequest, crossOriginOptions); | 370 loadRequest(crossOriginRequest, crossOriginOptions); |
| 371 } else { | 371 } else { |
| 372 // Explicitly set the SkipServiceWorker flag here. Even if the page is not | |
| 373 // controlled by a SW at this point, a new SW may be controlling the page | |
|
falken
2016/12/20 05:27:42
so we only get to this point when the page is not
Marijn Kruisselbrink
2016/12/20 17:28:28
Yes, ::start() only ends up calling dispatchInitia
| |
| 374 // when this request gets send later. We should not send the actual request | |
|
falken
2016/12/20 05:27:42
sent later
Marijn Kruisselbrink
2016/12/20 17:28:28
Done
| |
| 375 // to the SW. https://crbug.com/604583 | |
| 376 // Similarly we don't want any requests that could involve a CORS preflight | |
| 377 // to get intercepted by a foreign fetch service worker, even if we have the | |
| 378 // result of the preflight cached already. https://crbug.com/674370 | |
|
falken
2016/12/20 05:27:42
Not sure I understand the bug.. the cache was surv
Marijn Kruisselbrink
2016/12/20 17:28:28
Yes, that seems to be what was happening. Not sure
| |
| 379 crossOriginRequest.setSkipServiceWorker( | |
| 380 WebURLRequest::SkipServiceWorker::All); | |
| 381 | |
| 372 bool shouldForcePreflight = | 382 bool shouldForcePreflight = |
| 373 request.isExternalRequest() || | 383 request.isExternalRequest() || |
| 374 InspectorInstrumentation::shouldForceCORSPreflight(m_document); | 384 InspectorInstrumentation::shouldForceCORSPreflight(m_document); |
| 375 bool canSkipPreflight = | 385 bool canSkipPreflight = |
| 376 CrossOriginPreflightResultCache::shared().canSkipPreflight( | 386 CrossOriginPreflightResultCache::shared().canSkipPreflight( |
| 377 getSecurityOrigin()->toString(), crossOriginRequest.url(), | 387 getSecurityOrigin()->toString(), crossOriginRequest.url(), |
| 378 effectiveAllowCredentials(), crossOriginRequest.httpMethod(), | 388 effectiveAllowCredentials(), crossOriginRequest.httpMethod(), |
| 379 crossOriginRequest.httpHeaderFields()); | 389 crossOriginRequest.httpHeaderFields()); |
| 380 if (canSkipPreflight && !shouldForcePreflight) { | 390 if (canSkipPreflight && !shouldForcePreflight) { |
| 381 if (getSecurityOrigin()) | 391 if (getSecurityOrigin()) |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 909 } | 919 } |
| 910 | 920 |
| 911 void DocumentThreadableLoader::loadActualRequest() { | 921 void DocumentThreadableLoader::loadActualRequest() { |
| 912 ResourceRequest actualRequest = m_actualRequest; | 922 ResourceRequest actualRequest = m_actualRequest; |
| 913 ResourceLoaderOptions actualOptions = m_actualOptions; | 923 ResourceLoaderOptions actualOptions = m_actualOptions; |
| 914 m_actualRequest = ResourceRequest(); | 924 m_actualRequest = ResourceRequest(); |
| 915 m_actualOptions = ResourceLoaderOptions(); | 925 m_actualOptions = ResourceLoaderOptions(); |
| 916 | 926 |
| 917 clearResource(); | 927 clearResource(); |
| 918 | 928 |
| 919 // Explicitly set the SkipServiceWorker flag here. Even if the page was not | |
| 920 // controlled by a SW when the preflight request was sent, a new SW may be | |
| 921 // controlling the page now by calling clients.claim(). We should not send | |
| 922 // the actual request to the SW. https://crbug.com/604583 | |
| 923 actualRequest.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); | |
| 924 | |
| 925 prepareCrossOriginRequest(actualRequest); | 929 prepareCrossOriginRequest(actualRequest); |
| 926 loadRequest(actualRequest, actualOptions); | 930 loadRequest(actualRequest, actualOptions); |
| 927 } | 931 } |
| 928 | 932 |
| 929 void DocumentThreadableLoader::handlePreflightFailure( | 933 void DocumentThreadableLoader::handlePreflightFailure( |
| 930 const String& url, | 934 const String& url, |
| 931 const String& errorDescription) { | 935 const String& errorDescription) { |
| 932 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); | 936 ResourceError error(errorDomainBlinkInternal, 0, url, errorDescription); |
| 933 | 937 |
| 934 // Prevent handleSuccessfulFinish() from bypassing access check. | 938 // Prevent handleSuccessfulFinish() from bypassing access check. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1114 } | 1118 } |
| 1115 | 1119 |
| 1116 DEFINE_TRACE(DocumentThreadableLoader) { | 1120 DEFINE_TRACE(DocumentThreadableLoader) { |
| 1117 visitor->trace(m_resource); | 1121 visitor->trace(m_resource); |
| 1118 visitor->trace(m_document); | 1122 visitor->trace(m_document); |
| 1119 ThreadableLoader::trace(visitor); | 1123 ThreadableLoader::trace(visitor); |
| 1120 RawResourceClient::trace(visitor); | 1124 RawResourceClient::trace(visitor); |
| 1121 } | 1125 } |
| 1122 | 1126 |
| 1123 } // namespace blink | 1127 } // namespace blink |
| OLD | NEW |