blob: ae4b9677041192668777f54d8a0b9e415e775144 [file] [log] [blame]
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +00001/*
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.com92047332014-03-15 04:08:27 +000016 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000017 * 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.org553e8d32016-11-12 08:57:21 +000026#pragma once
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000027
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000028#include "CachedResource.h"
beidson@apple.comb98919a2015-03-23 22:34:53 +000029#include "DocumentLoader.h"
eric@webkit.orgf3f6e042013-02-11 05:14:03 +000030#include "Element.h"
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000031#include "ResourceLoadPriority.h"
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000032#include "ResourceLoaderOptions.h"
33#include "ResourceRequest.h"
commit-queue@webkit.org7049f922016-09-22 08:57:12 +000034#include "SecurityOrigin.h"
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000035#include <wtf/RefPtr.h>
36#include <wtf/text/AtomicString.h>
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000037
38namespace WebCore {
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000039
40namespace ContentExtensions {
41struct BlockedStatus;
42}
commit-queue@webkit.org3e6753e2016-10-25 14:16:15 +000043
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000044class Document;
commit-queue@webkit.org3e6753e2016-10-25 14:16:15 +000045class FrameLoader;
46enum class ReferrerPolicy;
47
48bool isRequestCrossOrigin(SecurityOrigin*, const URL& requestURL, const ResourceLoaderOptions&);
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000049
50class CachedResourceRequest {
51public:
commit-queue@webkit.org77951322016-10-11 06:42:53 +000052 CachedResourceRequest(ResourceRequest&&, const ResourceLoaderOptions&, Optional<ResourceLoadPriority> = Nullopt, String&& charset = String());
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000053
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000054 ResourceRequest&& releaseResourceRequest() { return WTFMove(m_resourceRequest); }
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000055 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.org864dbda2012-11-16 12:21:57 +000059 void setOptions(const ResourceLoaderOptions& options) { m_options = options; }
cdumez@apple.com8da16fb2015-02-04 01:23:58 +000060 const Optional<ResourceLoadPriority>& priority() const { return m_priority; }
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000061 void setInitiator(PassRefPtr<Element>);
simonjam@chromium.org5928faa2012-11-22 00:18:35 +000062 void setInitiator(const AtomicString& name);
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000063 const AtomicString& initiatorName() const;
commit-queue@webkit.org877e1492016-08-02 06:46:57 +000064 bool allowsCaching() const { return m_options.cachingPolicy == CachingPolicy::AllowCaching; }
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000065 void setCachingPolicy(CachingPolicy policy) { m_options.cachingPolicy = policy; }
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000066
youenn.fablet@crf.canon.fr70851bfd2016-06-10 18:17:11 +000067 void setAsPotentiallyCrossOrigin(const String&, Document&);
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000068 void updateForAccessControl(Document&);
69
commit-queue@webkit.org3e6753e2016-10-25 14:16:15 +000070 void updateReferrerOriginAndUserAgentHeaders(FrameLoader&, ReferrerPolicy);
commit-queue@webkit.org858242f2016-10-13 10:34:15 +000071 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.org3e6753e2016-10-25 14:16:15 +000082 void setOrigin(RefPtr<SecurityOrigin>&& origin) { m_origin = WTFMove(origin); }
commit-queue@webkit.org7049f922016-09-22 08:57:12 +000083 RefPtr<SecurityOrigin> releaseOrigin() { return WTFMove(m_origin); }
84 SecurityOrigin* origin() const { return m_origin.get(); }
youenn.fablet@crf.canon.fr70851bfd2016-06-10 18:17:11 +000085
commit-queue@webkit.org73e0a1b2016-10-18 12:30:40 +000086 String&& releaseFragmentIdentifier() { return WTFMove(m_fragmentIdentifier); }
87 void clearFragmentIdentifier() { m_fragmentIdentifier = { }; }
88
89 static String splitFragmentIdentifierFromRequestURL(ResourceRequest&);
90
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +000091private:
92 ResourceRequest m_resourceRequest;
93 String m_charset;
94 ResourceLoaderOptions m_options;
cdumez@apple.com8da16fb2015-02-04 01:23:58 +000095 Optional<ResourceLoadPriority> m_priority;
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000096 RefPtr<Element> m_initiatorElement;
commit-queue@webkit.org864dbda2012-11-16 12:21:57 +000097 AtomicString m_initiatorName;
commit-queue@webkit.org7049f922016-09-22 08:57:12 +000098 RefPtr<SecurityOrigin> m_origin;
commit-queue@webkit.org73e0a1b2016-10-18 12:30:40 +000099 String m_fragmentIdentifier;
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +0000100};
101
commit-queue@webkit.org4edc6bf2016-10-24 07:49:14 +0000102void upgradeInsecureResourceRequestIfNeeded(ResourceRequest&, Document&);
103
commit-queue@webkit.org5e7ea1b2012-10-22 23:35:28 +0000104} // namespace WebCore