be2722307af03e7e14d882a998a6296d7c55dbdc
[WebKit-https.git] / Source / WebCore / loader / FrameLoadRequest.h
1 /*
2  * Copyright (C) 2003-2016 Apple 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 APPLE 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
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
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
26 #pragma once
27
28 #include "FrameLoaderTypes.h"
29 #include "ResourceRequest.h"
30 #include "SecurityOrigin.h"
31 #include "SubstituteData.h"
32
33 namespace WebCore {
34 class Frame;
35
36 struct FrameLoadRequest {
37 public:
38     FrameLoadRequest(SecurityOrigin* requester, LockHistory lockHistory, LockBackForwardList lockBackForwardList, ShouldSendReferrer shouldSendReferrer, AllowNavigationToInvalidURL allowNavigationToInvalidURL, NewFrameOpenerPolicy newFrameOpenerPolicy, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy)
39         : m_requester(requester)
40         , m_lockHistory(lockHistory)
41         , m_lockBackForwardList(lockBackForwardList)
42         , m_shouldSendReferrer(shouldSendReferrer)
43         , m_allowNavigationToInvalidURL(allowNavigationToInvalidURL)
44         , m_newFrameOpenerPolicy(newFrameOpenerPolicy)
45         , m_shouldReplaceDocumentIfJavaScriptURL(ReplaceDocumentIfJavaScriptURL)
46         , m_shouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicy)
47     {
48     }
49
50     FrameLoadRequest(SecurityOrigin* requester, const ResourceRequest& resourceRequest, LockHistory lockHistory, LockBackForwardList lockBackForwardList, ShouldSendReferrer shouldSendReferrer, AllowNavigationToInvalidURL allowNavigationToInvalidURL, NewFrameOpenerPolicy newFrameOpenerPolicy, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy)
51         : m_requester(requester)
52         , m_resourceRequest(resourceRequest)
53         , m_lockHistory(lockHistory)
54         , m_lockBackForwardList(lockBackForwardList)
55         , m_shouldSendReferrer(shouldSendReferrer)
56         , m_allowNavigationToInvalidURL(allowNavigationToInvalidURL)
57         , m_newFrameOpenerPolicy(newFrameOpenerPolicy)
58         , m_shouldReplaceDocumentIfJavaScriptURL(ReplaceDocumentIfJavaScriptURL)
59         , m_shouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicy)
60     {
61     }
62
63     FrameLoadRequest(SecurityOrigin* requester, const ResourceRequest& resourceRequest, const String& frameName, LockHistory lockHistory, LockBackForwardList lockBackForwardList, ShouldSendReferrer shouldSendReferrer, AllowNavigationToInvalidURL allowNavigationToInvalidURL, NewFrameOpenerPolicy newFrameOpenerPolicy, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy)
64         : m_requester(requester)
65         , m_resourceRequest(resourceRequest)
66         , m_frameName(frameName)
67         , m_lockHistory(lockHistory)
68         , m_lockBackForwardList(lockBackForwardList)
69         , m_shouldSendReferrer(shouldSendReferrer)
70         , m_allowNavigationToInvalidURL(allowNavigationToInvalidURL)
71         , m_newFrameOpenerPolicy(newFrameOpenerPolicy)
72         , m_shouldReplaceDocumentIfJavaScriptURL(ReplaceDocumentIfJavaScriptURL)
73         , m_shouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicy)
74     {
75     }
76
77     FrameLoadRequest(SecurityOrigin* requester, const ResourceRequest& resourceRequest, const String& frameName, LockHistory lockHistory, LockBackForwardList lockBackForwardList, ShouldSendReferrer shouldSendReferrer, AllowNavigationToInvalidURL allowNavigationToInvalidURL, NewFrameOpenerPolicy newFrameOpenerPolicy, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy)
78         : m_requester(requester)
79         , m_resourceRequest(resourceRequest)
80         , m_frameName(frameName)
81         , m_lockHistory(lockHistory)
82         , m_lockBackForwardList(lockBackForwardList)
83         , m_shouldSendReferrer(shouldSendReferrer)
84         , m_allowNavigationToInvalidURL(allowNavigationToInvalidURL)
85         , m_newFrameOpenerPolicy(newFrameOpenerPolicy)
86         , m_shouldReplaceDocumentIfJavaScriptURL(shouldReplaceDocumentIfJavaScriptURL)
87         , m_shouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicy)
88     {
89     }
90
91     FrameLoadRequest(SecurityOrigin* requester, const ResourceRequest& resourceRequest, const String& frameName, LockHistory lockHistory, LockBackForwardList lockBackForwardList, ShouldSendReferrer shouldSendReferrer, AllowNavigationToInvalidURL allowNavigationToInvalidURL, NewFrameOpenerPolicy newFrameOpenerPolicy, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy, const AtomicString& downloadAttribute)
92         : m_requester(requester)
93         , m_resourceRequest(resourceRequest)
94         , m_frameName(frameName)
95         , m_lockHistory(lockHistory)
96         , m_lockBackForwardList(lockBackForwardList)
97         , m_shouldSendReferrer(shouldSendReferrer)
98         , m_allowNavigationToInvalidURL(allowNavigationToInvalidURL)
99         , m_newFrameOpenerPolicy(newFrameOpenerPolicy)
100         , m_shouldReplaceDocumentIfJavaScriptURL(shouldReplaceDocumentIfJavaScriptURL)
101         , m_shouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicy)
102         , m_downloadAttribute(downloadAttribute)
103     {
104     }
105
106     WEBCORE_EXPORT FrameLoadRequest(Frame*, const ResourceRequest&, ShouldOpenExternalURLsPolicy, const SubstituteData& = SubstituteData());
107
108     bool isEmpty() const { return m_resourceRequest.isEmpty(); }
109
110     const SecurityOrigin* requester() const { return m_requester.get(); }
111
112     ResourceRequest& resourceRequest() { return m_resourceRequest; }
113     const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
114
115     const String& frameName() const { return m_frameName; }
116     void setFrameName(const String& frameName) { m_frameName = frameName; }
117
118     void setShouldCheckNewWindowPolicy(bool checkPolicy) { m_shouldCheckNewWindowPolicy = checkPolicy; }
119     bool shouldCheckNewWindowPolicy() const { return m_shouldCheckNewWindowPolicy; }
120
121     const SubstituteData& substituteData() const { return m_substituteData; }
122     void setSubstituteData(const SubstituteData& data) { m_substituteData = data; }
123     bool hasSubstituteData() { return m_substituteData.isValid(); }
124
125     LockHistory lockHistory() const { return m_lockHistory; }
126     LockBackForwardList lockBackForwardList() const { return m_lockBackForwardList; }
127     ShouldSendReferrer shouldSendReferrer() const { return m_shouldSendReferrer; }
128     AllowNavigationToInvalidURL allowNavigationToInvalidURL() const { return m_allowNavigationToInvalidURL; }
129     NewFrameOpenerPolicy newFrameOpenerPolicy() const { return m_newFrameOpenerPolicy; }
130
131     // The shouldReplaceDocumentIfJavaScriptURL parameter will go away when the FIXME to eliminate the
132     // corresponding parameter from ScriptController::executeIfJavaScriptURL() is addressed.
133     ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL() const { return m_shouldReplaceDocumentIfJavaScriptURL; }
134
135     void setShouldOpenExternalURLsPolicy(ShouldOpenExternalURLsPolicy policy) { m_shouldOpenExternalURLsPolicy = policy; }
136     ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy() const { return m_shouldOpenExternalURLsPolicy; }
137
138     const AtomicString& downloadAttribute() const { return m_downloadAttribute; }
139
140 private:
141     RefPtr<SecurityOrigin> m_requester;
142     ResourceRequest m_resourceRequest;
143     String m_frameName;
144     bool m_shouldCheckNewWindowPolicy { false };
145     SubstituteData m_substituteData;
146
147     LockHistory m_lockHistory;
148     LockBackForwardList m_lockBackForwardList;
149     ShouldSendReferrer m_shouldSendReferrer;
150     AllowNavigationToInvalidURL m_allowNavigationToInvalidURL;
151     NewFrameOpenerPolicy m_newFrameOpenerPolicy;
152     ShouldReplaceDocumentIfJavaScriptURL m_shouldReplaceDocumentIfJavaScriptURL;
153     ShouldOpenExternalURLsPolicy m_shouldOpenExternalURLsPolicy { ShouldOpenExternalURLsPolicy::ShouldNotAllow };
154     AtomicString m_downloadAttribute;
155 };
156
157 } // namespace WebCore