Index: Source/core/loader/DocumentThreadableLoader.cpp |
diff --git a/Source/core/loader/DocumentThreadableLoader.cpp b/Source/core/loader/DocumentThreadableLoader.cpp |
index 15e351a0bce9f3b6f676d73c3ae81d5163130cbb..a2d2251888079da725fd2482977e42ee7d1e7e35 100644 |
--- a/Source/core/loader/DocumentThreadableLoader.cpp |
+++ b/Source/core/loader/DocumentThreadableLoader.cpp |
@@ -46,6 +46,7 @@ |
#include "core/loader/CrossOriginPreflightResultCache.h" |
#include "core/loader/DocumentThreadableLoaderClient.h" |
#include "core/loader/FrameLoader.h" |
+#include "core/loader/FrameLoaderClient.h" |
#include "core/loader/ThreadableLoaderClient.h" |
#include "platform/SharedBuffer.h" |
#include "platform/network/ResourceRequest.h" |
@@ -99,6 +100,29 @@ DocumentThreadableLoader::DocumentThreadableLoader(Document& document, Threadabl |
m_simpleRequestHeaders.add(it->key, it->value); |
} |
+ if (m_async && !request.skipServiceWorker() && m_document.fetcher()->isControlledByServiceWorker()) { |
yhirano
2014/10/07 08:03:14
why m_async is needed, is it a workaround?
yhirano
2014/10/07 08:03:15
Can you write a brief comment about this block?
horo
2014/10/08 02:34:56
Done.
horo
2014/10/08 02:34:56
ServiceWorker's onFetch event doesn't support sync
|
+ if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == DenyCrossOriginRequests) { |
+ m_client->didFail(ResourceError(errorDomainBlinkInternal, 0, request.url().string(), "Cross origin requests are not supported.")); |
+ return; |
+ } |
+ ResourceRequest newRequest = ResourceRequest(request); |
yhirano
2014/10/07 08:03:15
ResourceRequest newRequest(request) is enough.
horo
2014/10/08 02:34:56
Done.
|
+ if (options.preflightPolicy == ForcePreflight) |
yhirano
2014/10/07 08:03:14
Sorry I don't understand this flag manipulation. W
horo
2014/10/08 02:34:56
Added the comment.
|
+ newRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORSWithForcedPreflight); |
+ else |
+ newRequest.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS); |
+ |
+ if (resourceLoaderOptions.credentialsRequested == ClientRequestedCredentials) |
yhirano
2014/10/07 08:03:14
Ditto
horo
2014/10/08 02:34:56
removed
|
+ newRequest.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeInclude); |
+ else |
+ newRequest.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeSameOrigin); |
+ |
yhirano
2014/10/07 08:03:14
Shouldn't we check the credentials flag correctnes
horo
2014/10/08 02:34:56
removed setFetchCredentialsMode
|
+ m_fallbackRequest = adoptPtr(new ResourceRequest(request)); |
+ m_fallbackRequest->setSkipServiceWorker(true); |
+ |
+ loadRequest(newRequest, m_resourceLoaderOptions); |
+ return; |
+ } |
+ |
if (m_sameOriginRequest || m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) { |
loadRequest(request, m_resourceLoaderOptions); |
return; |
@@ -365,22 +389,13 @@ void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re |
// If the response is fetched via ServiceWorker, the original URL of the response could be different from the URL of the request. |
bool isCrossOriginResponse = false; |
if (response.wasFetchedViaServiceWorker()) { |
- if (!isAllowedByPolicy(response.url())) { |
- notifyResponseReceived(identifier, response); |
- m_client->didFailRedirectCheck(); |
+ if (response.wasFallbackRequiredByServiceWorker() && m_fallbackRequest) { |
yhirano
2014/10/07 08:03:14
What happens if wasFallbackRequiredByServiceWorker
horo
2014/10/08 02:34:56
m_fallbackRequest must not be null when wasFallbac
|
+ loadFallbackRequest(); |
return; |
} |
- isCrossOriginResponse = !securityOrigin()->canRequest(response.url()); |
- if (m_options.crossOriginRequestPolicy == DenyCrossOriginRequests && isCrossOriginResponse) { |
- notifyResponseReceived(identifier, response); |
- m_client->didFail(ResourceError(errorDomainBlinkInternal, 0, response.url().string(), "Cross origin requests are not supported.")); |
- return; |
- } |
- if (isCrossOriginResponse && m_resourceLoaderOptions.credentialsRequested == ClientDidNotRequestCredentials) { |
- // Since the request is no longer same-origin, if the user didn't request credentials in |
- // the first place, update our state so we neither request them nor expect they must be allowed. |
- m_forceDoNotAllowStoredCredentials = true; |
- } |
+ m_fallbackRequest = nullptr; |
+ m_client->didReceiveResponse(identifier, response); |
+ return; |
} else { |
isCrossOriginResponse = !m_sameOriginRequest; |
} |
@@ -406,7 +421,7 @@ void DocumentThreadableLoader::handleReceivedData(const char* data, unsigned dat |
{ |
ASSERT(m_client); |
// Preflight data should be invisible to clients. |
- if (!m_actualRequest) |
+ if (!m_actualRequest && !m_fallbackRequest) |
m_client->didReceiveData(data, dataLength); |
} |
@@ -448,6 +463,18 @@ void DocumentThreadableLoader::didTimeout(Timer<DocumentThreadableLoader>* timer |
cancelWithError(error); |
} |
+void DocumentThreadableLoader::loadFallbackRequest() |
+{ |
+ clearResource(); |
+ OwnPtr<ResourceRequest> fallbackRequest; |
yhirano
2014/10/07 08:03:15
fallbackRequest(m_fallbackRequest.release());
horo
2014/10/08 02:34:56
Done.
|
+ fallbackRequest.swap(m_fallbackRequest); |
+ if (m_sameOriginRequest || m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) { |
+ loadRequest(*fallbackRequest, m_resourceLoaderOptions); |
+ return; |
+ } |
yhirano
2014/10/07 08:03:15
makeCrossOriginAccessRequest expects that the poli
horo
2014/10/08 02:34:56
Done.
|
+ makeCrossOriginAccessRequest(*fallbackRequest); |
+} |
+ |
void DocumentThreadableLoader::loadActualRequest() |
{ |
OwnPtr<ResourceRequest> actualRequest; |