commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Google, Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
commit-queue@webkit.org | 553e8d3 | 2016-11-12 08:57:21 +0000 | [diff] [blame] | 26 | #pragma once |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 27 | |
commit-queue@webkit.org | 858242f | 2016-10-13 10:34:15 +0000 | [diff] [blame] | 28 | #include "CachedResource.h" |
beidson@apple.com | b98919a | 2015-03-23 22:34:53 +0000 | [diff] [blame] | 29 | #include "DocumentLoader.h" |
eric@webkit.org | f3f6e04 | 2013-02-11 05:14:03 +0000 | [diff] [blame] | 30 | #include "Element.h" |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 31 | #include "ResourceLoadPriority.h" |
commit-queue@webkit.org | 864dbda | 2012-11-16 12:21:57 +0000 | [diff] [blame] | 32 | #include "ResourceLoaderOptions.h" |
| 33 | #include "ResourceRequest.h" |
commit-queue@webkit.org | 7049f92 | 2016-09-22 08:57:12 +0000 | [diff] [blame] | 34 | #include "SecurityOrigin.h" |
commit-queue@webkit.org | 864dbda | 2012-11-16 12:21:57 +0000 | [diff] [blame] | 35 | #include <wtf/RefPtr.h> |
| 36 | #include <wtf/text/AtomicString.h> |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 37 | |
| 38 | namespace WebCore { |
commit-queue@webkit.org | 858242f | 2016-10-13 10:34:15 +0000 | [diff] [blame] | 39 | |
| 40 | namespace ContentExtensions { |
| 41 | struct BlockedStatus; |
| 42 | } |
commit-queue@webkit.org | 3e6753e | 2016-10-25 14:16:15 +0000 | [diff] [blame] | 43 | |
commit-queue@webkit.org | 864dbda | 2012-11-16 12:21:57 +0000 | [diff] [blame] | 44 | class Document; |
commit-queue@webkit.org | 3e6753e | 2016-10-25 14:16:15 +0000 | [diff] [blame] | 45 | class FrameLoader; |
| 46 | enum class ReferrerPolicy; |
| 47 | |
| 48 | bool isRequestCrossOrigin(SecurityOrigin*, const URL& requestURL, const ResourceLoaderOptions&); |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 49 | |
| 50 | class CachedResourceRequest { |
| 51 | public: |
commit-queue@webkit.org | 7795132 | 2016-10-11 06:42:53 +0000 | [diff] [blame] | 52 | CachedResourceRequest(ResourceRequest&&, const ResourceLoaderOptions&, Optional<ResourceLoadPriority> = Nullopt, String&& charset = String()); |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 53 | |
commit-queue@webkit.org | 858242f | 2016-10-13 10:34:15 +0000 | [diff] [blame] | 54 | ResourceRequest&& releaseResourceRequest() { return WTFMove(m_resourceRequest); } |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 55 | const ResourceRequest& resourceRequest() const { return m_resourceRequest; } |
| 56 | const String& charset() const { return m_charset; } |
| 57 | void setCharset(const String& charset) { m_charset = charset; } |
| 58 | const ResourceLoaderOptions& options() const { return m_options; } |
commit-queue@webkit.org | 864dbda | 2012-11-16 12:21:57 +0000 | [diff] [blame] | 59 | void setOptions(const ResourceLoaderOptions& options) { m_options = options; } |
cdumez@apple.com | 8da16fb | 2015-02-04 01:23:58 +0000 | [diff] [blame] | 60 | const Optional<ResourceLoadPriority>& priority() const { return m_priority; } |
commit-queue@webkit.org | 864dbda | 2012-11-16 12:21:57 +0000 | [diff] [blame] | 61 | void setInitiator(PassRefPtr<Element>); |
simonjam@chromium.org | 5928faa | 2012-11-22 00:18:35 +0000 | [diff] [blame] | 62 | void setInitiator(const AtomicString& name); |
commit-queue@webkit.org | 864dbda | 2012-11-16 12:21:57 +0000 | [diff] [blame] | 63 | const AtomicString& initiatorName() const; |
commit-queue@webkit.org | 877e149 | 2016-08-02 06:46:57 +0000 | [diff] [blame] | 64 | bool allowsCaching() const { return m_options.cachingPolicy == CachingPolicy::AllowCaching; } |
commit-queue@webkit.org | 858242f | 2016-10-13 10:34:15 +0000 | [diff] [blame] | 65 | void setCachingPolicy(CachingPolicy policy) { m_options.cachingPolicy = policy; } |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 66 | |
youenn.fablet@crf.canon.fr | 70851bfd | 2016-06-10 18:17:11 +0000 | [diff] [blame] | 67 | void setAsPotentiallyCrossOrigin(const String&, Document&); |
commit-queue@webkit.org | 858242f | 2016-10-13 10:34:15 +0000 | [diff] [blame] | 68 | void updateForAccessControl(Document&); |
| 69 | |
commit-queue@webkit.org | 3e6753e | 2016-10-25 14:16:15 +0000 | [diff] [blame] | 70 | void updateReferrerOriginAndUserAgentHeaders(FrameLoader&, ReferrerPolicy); |
commit-queue@webkit.org | 858242f | 2016-10-13 10:34:15 +0000 | [diff] [blame] | 71 | void upgradeInsecureRequestIfNeeded(Document&); |
| 72 | void setAcceptHeaderIfNone(CachedResource::Type); |
| 73 | void updateAccordingCacheMode(); |
| 74 | void removeFragmentIdentifierIfNeeded(); |
| 75 | #if ENABLE(CONTENT_EXTENSIONS) |
| 76 | void applyBlockedStatus(const ContentExtensions::BlockedStatus&); |
| 77 | #endif |
| 78 | #if ENABLE(CACHE_PARTITIONING) |
| 79 | void setDomainForCachePartition(Document&); |
| 80 | #endif |
| 81 | |
commit-queue@webkit.org | 3e6753e | 2016-10-25 14:16:15 +0000 | [diff] [blame] | 82 | void setOrigin(RefPtr<SecurityOrigin>&& origin) { m_origin = WTFMove(origin); } |
commit-queue@webkit.org | 7049f92 | 2016-09-22 08:57:12 +0000 | [diff] [blame] | 83 | RefPtr<SecurityOrigin> releaseOrigin() { return WTFMove(m_origin); } |
| 84 | SecurityOrigin* origin() const { return m_origin.get(); } |
youenn.fablet@crf.canon.fr | 70851bfd | 2016-06-10 18:17:11 +0000 | [diff] [blame] | 85 | |
commit-queue@webkit.org | 73e0a1b | 2016-10-18 12:30:40 +0000 | [diff] [blame] | 86 | String&& releaseFragmentIdentifier() { return WTFMove(m_fragmentIdentifier); } |
| 87 | void clearFragmentIdentifier() { m_fragmentIdentifier = { }; } |
| 88 | |
| 89 | static String splitFragmentIdentifierFromRequestURL(ResourceRequest&); |
| 90 | |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 91 | private: |
| 92 | ResourceRequest m_resourceRequest; |
| 93 | String m_charset; |
| 94 | ResourceLoaderOptions m_options; |
cdumez@apple.com | 8da16fb | 2015-02-04 01:23:58 +0000 | [diff] [blame] | 95 | Optional<ResourceLoadPriority> m_priority; |
commit-queue@webkit.org | 864dbda | 2012-11-16 12:21:57 +0000 | [diff] [blame] | 96 | RefPtr<Element> m_initiatorElement; |
commit-queue@webkit.org | 864dbda | 2012-11-16 12:21:57 +0000 | [diff] [blame] | 97 | AtomicString m_initiatorName; |
commit-queue@webkit.org | 7049f92 | 2016-09-22 08:57:12 +0000 | [diff] [blame] | 98 | RefPtr<SecurityOrigin> m_origin; |
commit-queue@webkit.org | 73e0a1b | 2016-10-18 12:30:40 +0000 | [diff] [blame] | 99 | String m_fragmentIdentifier; |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
commit-queue@webkit.org | 4edc6bf | 2016-10-24 07:49:14 +0000 | [diff] [blame] | 102 | void upgradeInsecureResourceRequestIfNeeded(ResourceRequest&, Document&); |
| 103 | |
commit-queue@webkit.org | 5e7ea1b | 2012-10-22 23:35:28 +0000 | [diff] [blame] | 104 | } // namespace WebCore |