OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) | 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) |
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 | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 const WebURLResponse& webURLResponse, | 319 const WebURLResponse& webURLResponse, |
320 std::unique_ptr<WebDataConsumerHandle> handle) { | 320 std::unique_ptr<WebDataConsumerHandle> handle) { |
321 DCHECK(!webURLResponse.isNull()); | 321 DCHECK(!webURLResponse.isNull()); |
322 | 322 |
323 const ResourceResponse& response = webURLResponse.toResourceResponse(); | 323 const ResourceResponse& response = webURLResponse.toResourceResponse(); |
324 | 324 |
325 if (response.wasFetchedViaServiceWorker()) { | 325 if (response.wasFetchedViaServiceWorker()) { |
326 if (m_resource->options().corsEnabled == IsCORSEnabled && | 326 if (m_resource->options().corsEnabled == IsCORSEnabled && |
327 response.wasFallbackRequiredByServiceWorker()) { | 327 response.wasFallbackRequiredByServiceWorker()) { |
328 ResourceRequest request = m_resource->lastResourceRequest(); | 328 ResourceRequest request = m_resource->lastResourceRequest(); |
329 DCHECK_EQ(request.skipServiceWorker(), | 329 DCHECK_EQ(request.getServiceWorkerMode(), |
330 WebURLRequest::SkipServiceWorker::None); | 330 WebURLRequest::ServiceWorkerMode::All); |
331 // This code handles the case when a regular controlling service worker | 331 // This code handles the case when a regular controlling service worker |
332 // doesn't handle a cross origin request. When this happens we still want | 332 // doesn't handle a cross origin request. When this happens we still want |
333 // to give foreign fetch a chance to handle the request, so only skip the | 333 // to give foreign fetch a chance to handle the request, so only skip the |
334 // controlling service worker for the fallback request. This is currently | 334 // controlling service worker for the fallback request. This is currently |
335 // safe because of http://crbug.com/604084 the | 335 // safe because of http://crbug.com/604084 the |
336 // wasFallbackRequiredByServiceWorker flag is never set when foreign fetch | 336 // wasFallbackRequiredByServiceWorker flag is never set when foreign fetch |
337 // handled a request. | 337 // handled a request. |
338 if (!context().shouldLoadNewResource(m_resource->getType())) { | 338 if (!context().shouldLoadNewResource(m_resource->getType())) { |
339 // Cancel the request if we should not trigger a reload now. | 339 // Cancel the request if we should not trigger a reload now. |
340 handleError(ResourceError::cancelledError(response.url())); | 340 handleError(ResourceError::cancelledError(response.url())); |
341 return; | 341 return; |
342 } | 342 } |
343 request.setSkipServiceWorker( | 343 request.setServiceWorkerMode(WebURLRequest::ServiceWorkerMode::Foreign); |
344 WebURLRequest::SkipServiceWorker::Controlling); | |
345 restart(request); | 344 restart(request); |
346 return; | 345 return; |
347 } | 346 } |
348 | 347 |
349 // If the response is fetched via ServiceWorker, the original URL of the | 348 // If the response is fetched via ServiceWorker, the original URL of the |
350 // response could be different from the URL of the request. We check the URL | 349 // response could be different from the URL of the request. We check the URL |
351 // not to load the resources which are forbidden by the page CSP. | 350 // not to load the resources which are forbidden by the page CSP. |
352 // https://w3c.github.io/webappsec-csp/#should-block-response | 351 // https://w3c.github.io/webappsec-csp/#should-block-response |
353 const KURL& originalURL = response.originalURLViaServiceWorker(); | 352 const KURL& originalURL = response.originalURLViaServiceWorker(); |
354 if (!originalURL.isEmpty()) { | 353 if (!originalURL.isEmpty()) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 return; | 520 return; |
522 | 521 |
523 // Don't activate if cache policy is explicitly set. | 522 // Don't activate if cache policy is explicitly set. |
524 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) | 523 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) |
525 return; | 524 return; |
526 | 525 |
527 m_isCacheAwareLoadingActivated = true; | 526 m_isCacheAwareLoadingActivated = true; |
528 } | 527 } |
529 | 528 |
530 } // namespace blink | 529 } // namespace blink |
OLD | NEW |