OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 DocumentLoader* documentLoader = masterDocumentLoader(); | 587 DocumentLoader* documentLoader = masterDocumentLoader(); |
588 if (documentLoader && documentLoader->subresourceFilter() && type != Resourc
e::MainResource && type != Resource::ImportResource && !documentLoader->subresou
rceFilter()->allowLoad(url, resourceRequest.requestContext())) | 588 if (documentLoader && documentLoader->subresourceFilter() && type != Resourc
e::MainResource && type != Resource::ImportResource && !documentLoader->subresou
rceFilter()->allowLoad(url, resourceRequest.requestContext())) |
589 return ResourceRequestBlockedReasonSubresourceFilter; | 589 return ResourceRequestBlockedReasonSubresourceFilter; |
590 | 590 |
591 return ResourceRequestBlockedReasonNone; | 591 return ResourceRequestBlockedReasonNone; |
592 } | 592 } |
593 | 593 |
594 bool FrameFetchContext::isControlledByServiceWorker() const | 594 bool FrameFetchContext::isControlledByServiceWorker() const |
595 { | 595 { |
596 DCHECK(m_documentLoader || frame()->loader().documentLoader()); | 596 DCHECK(m_documentLoader || frame()->loader().documentLoader()); |
| 597 |
| 598 // Service workers are bypassed by suborigins (see |
| 599 // https://w3c.github.io/webappsec-suborigins/). Since service worker |
| 600 // controllers are assigned based on physical origin, without knowledge of |
| 601 // whether the context is in a suborigin, it is necessary to explicitly |
| 602 // bypass service workers on a per-request basis. Additionally, it is |
| 603 // necessary to explicitly return |false| here so that it is clear that the |
| 604 // SW will be bypassed. In particular, this is important for |
| 605 // ResourceFetcher::getCacheIdentifier(), which will return the SW's cache |
| 606 // if the context's isControlledByServiceWorker() returns |true|, and thus |
| 607 // will returned cached resources from the service worker. That would have |
| 608 // the effect of not bypassing the SW. |
| 609 if (getSecurityOrigin() && getSecurityOrigin()->hasSuborigin()) |
| 610 return false; |
| 611 |
597 if (m_documentLoader) | 612 if (m_documentLoader) |
598 return frame()->loader().client()->isControlledByServiceWorker(*m_docume
ntLoader); | 613 return frame()->loader().client()->isControlledByServiceWorker(*m_docume
ntLoader); |
599 // m_documentLoader is null while loading resources from an HTML import. | 614 // m_documentLoader is null while loading resources from an HTML import. |
600 // In such cases whether the request is controlled by ServiceWorker or not | 615 // In such cases whether the request is controlled by ServiceWorker or not |
601 // is determined by the document loader of the frame. | 616 // is determined by the document loader of the frame. |
602 return frame()->loader().client()->isControlledByServiceWorker(*frame()->loa
der().documentLoader()); | 617 return frame()->loader().client()->isControlledByServiceWorker(*frame()->loa
der().documentLoader()); |
603 } | 618 } |
604 | 619 |
605 int64_t FrameFetchContext::serviceWorkerID() const | 620 int64_t FrameFetchContext::serviceWorkerID() const |
606 { | 621 { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 } | 815 } |
801 | 816 |
802 DEFINE_TRACE(FrameFetchContext) | 817 DEFINE_TRACE(FrameFetchContext) |
803 { | 818 { |
804 visitor->trace(m_document); | 819 visitor->trace(m_document); |
805 visitor->trace(m_documentLoader); | 820 visitor->trace(m_documentLoader); |
806 FetchContext::trace(visitor); | 821 FetchContext::trace(visitor); |
807 } | 822 } |
808 | 823 |
809 } // namespace blink | 824 } // namespace blink |
OLD | NEW |