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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 if (resource()) | 176 if (resource()) |
177 resource()->setDefersLoading(value); | 177 resource()->setDefersLoading(value); |
178 } | 178 } |
179 | 179 |
180 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ
est& request, const ResourceResponse& redirectResponse) | 180 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ
est& request, const ResourceResponse& redirectResponse) |
181 { | 181 { |
182 ASSERT(m_client); | 182 ASSERT(m_client); |
183 ASSERT_UNUSED(resource, resource == this->resource()); | 183 ASSERT_UNUSED(resource, resource == this->resource()); |
184 | 184 |
185 RefPtr<DocumentThreadableLoader> protect(this); | 185 RefPtr<DocumentThreadableLoader> protect(this); |
| 186 |
| 187 // We don't support redirect in Fech API yet. |
| 188 // FIXME: Support redirect in Fech API. |
| 189 if (resource->resourceRequest().requestContext() == blink::WebURLRequest::Re
questContextFetch) { |
| 190 m_client->didFailRedirectCheck(); |
| 191 request = ResourceRequest(); |
| 192 return; |
| 193 } |
| 194 |
186 if (!isAllowedByPolicy(request.url())) { | 195 if (!isAllowedByPolicy(request.url())) { |
187 m_client->didFailRedirectCheck(); | 196 m_client->didFailRedirectCheck(); |
188 request = ResourceRequest(); | 197 request = ResourceRequest(); |
189 return; | 198 return; |
190 } | 199 } |
191 | 200 |
192 // Allow same origin requests to continue after allowing clients to audit th
e redirect. | 201 // Allow same origin requests to continue after allowing clients to audit th
e redirect. |
193 if (isAllowedRedirect(request.url())) { | 202 if (isAllowedRedirect(request.url())) { |
194 if (m_client->isDocumentThreadableLoaderClient()) | 203 if (m_client->isDocumentThreadableLoaderClient()) |
195 static_cast<DocumentThreadableLoaderClient*>(m_client)->willSendRequ
est(request, redirectResponse); | 204 static_cast<DocumentThreadableLoaderClient*>(m_client)->willSendRequ
est(request, redirectResponse); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 321 |
313 void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re
sourceResponse& response) | 322 void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re
sourceResponse& response) |
314 { | 323 { |
315 ASSERT(m_client); | 324 ASSERT(m_client); |
316 | 325 |
317 if (m_actualRequest) { | 326 if (m_actualRequest) { |
318 handlePreflightResponse(identifier, response); | 327 handlePreflightResponse(identifier, response); |
319 return; | 328 return; |
320 } | 329 } |
321 | 330 |
322 // FIXME: When response.wasFetchedViaServiceWorker() is true, we need to che
ck the URL of the response for CSP and CORS. | 331 // If the response is fetched via ServiceWorker, the original URL of the res
ponse could be different from the URL of the request. |
| 332 if (response.wasFetchedViaServiceWorker()) { |
| 333 if (!isAllowedByPolicy(response.url())) { |
| 334 m_client->didFailRedirectCheck(); |
| 335 return; |
| 336 } |
| 337 if (!isAllowedRedirect(response.url())) { |
| 338 if (m_options.crossOriginRequestPolicy == DenyCrossOriginRequests) { |
| 339 m_client->didFail(ResourceError(errorDomainBlinkInternal, 0, res
ponse.url().string(), "Cross origin requests are not supported.")); |
| 340 return; |
| 341 } |
| 342 if (m_options.crossOriginRequestPolicy == UseAccessControl) { |
| 343 String accessControlErrorDescription; |
| 344 if (!passesAccessControlCheck(response, effectiveAllowCredential
s(), securityOrigin(), accessControlErrorDescription)) { |
| 345 m_client->didFailAccessControlCheck(ResourceError(errorDomai
nBlinkInternal, 0, response.url().string(), accessControlErrorDescription)); |
| 346 return; |
| 347 } |
| 348 } |
| 349 } |
| 350 } |
323 | 351 |
324 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == UseAccessC
ontrol) { | 352 if (!m_sameOriginRequest && m_options.crossOriginRequestPolicy == UseAccessC
ontrol) { |
325 String accessControlErrorDescription; | 353 String accessControlErrorDescription; |
326 if (!passesAccessControlCheck(response, effectiveAllowCredentials(), sec
urityOrigin(), accessControlErrorDescription)) { | 354 if (!passesAccessControlCheck(response, effectiveAllowCredentials(), sec
urityOrigin(), accessControlErrorDescription)) { |
327 m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkIn
ternal, 0, response.url().string(), accessControlErrorDescription)); | 355 m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkIn
ternal, 0, response.url().string(), accessControlErrorDescription)); |
328 return; | 356 return; |
329 } | 357 } |
330 } | 358 } |
331 | 359 |
332 m_client->didReceiveResponse(identifier, response); | 360 m_client->didReceiveResponse(identifier, response); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 return DoNotAllowStoredCredentials; | 528 return DoNotAllowStoredCredentials; |
501 return m_resourceLoaderOptions.allowCredentials; | 529 return m_resourceLoaderOptions.allowCredentials; |
502 } | 530 } |
503 | 531 |
504 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const | 532 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const |
505 { | 533 { |
506 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin
(); | 534 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin
(); |
507 } | 535 } |
508 | 536 |
509 } // namespace WebCore | 537 } // namespace WebCore |
OLD | NEW |