1 | /* |
2 | * Copyright (C) 2006-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 | * |
8 | * 1. Redistributions of source code must retain the above copyright |
9 | * notice, this list of conditions and the following disclaimer. |
10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. |
13 | * 3. Neither the name of Apple Inc. ("Apple") nor the names of |
14 | * its contributors may be used to endorse or promote products derived |
15 | * from this software without specific prior written permission. |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
28 | |
29 | #pragma once |
30 | |
31 | #include "IntRect.h" |
32 | #include "ProcessIdentifier.h" |
33 | |
34 | namespace WebCore { |
35 | |
36 | enum FrameState { |
37 | FrameStateProvisional, |
38 | // This state indicates we are ready to commit to a page, |
39 | // which means the view will transition to use the new data source. |
40 | FrameStateCommittedPage, |
41 | FrameStateComplete |
42 | }; |
43 | |
44 | enum class PolicyAction : uint8_t { |
45 | Use, |
46 | Download, |
47 | Ignore, |
48 | StopAllLoads |
49 | }; |
50 | |
51 | enum class ReloadOption : uint8_t { |
52 | ExpiredOnly = 1 << 0, |
53 | FromOrigin = 1 << 1, |
54 | DisableContentBlockers = 1 << 2, |
55 | }; |
56 | |
57 | enum class FrameLoadType : uint8_t { |
58 | Standard, |
59 | Back, |
60 | Forward, |
61 | IndexedBackForward, // a multi-item hop in the backforward list |
62 | Reload, |
63 | Same, // user loads same URL again (but not reload button) |
64 | RedirectWithLockedBackForwardList, // FIXME: Merge "lockBackForwardList", "lockHistory", "quickRedirect" and "clientRedirect" into a single concept of redirect. |
65 | Replace, |
66 | ReloadFromOrigin, |
67 | ReloadExpiredOnly |
68 | }; |
69 | |
70 | enum class WillContinueLoading : bool { No, Yes }; |
71 | |
72 | class PolicyCheckIdentifier { |
73 | public: |
74 | PolicyCheckIdentifier() = default; |
75 | |
76 | static PolicyCheckIdentifier create(); |
77 | |
78 | bool isValidFor(PolicyCheckIdentifier); |
79 | bool operator==(const PolicyCheckIdentifier& other) const { return m_process == other.m_process && m_policyCheck == other.m_policyCheck; } |
80 | |
81 | template<class Encoder> void encode(Encoder&) const; |
82 | template<class Decoder> static Optional<PolicyCheckIdentifier> decode(Decoder&); |
83 | |
84 | private: |
85 | PolicyCheckIdentifier(ProcessIdentifier process, uint64_t policyCheck) |
86 | : m_process(process) |
87 | , m_policyCheck(policyCheck) |
88 | { } |
89 | |
90 | ProcessIdentifier m_process; |
91 | uint64_t m_policyCheck { 0 }; |
92 | }; |
93 | |
94 | template<class Encoder> |
95 | void PolicyCheckIdentifier::encode(Encoder& encoder) const |
96 | { |
97 | encoder << m_process << m_policyCheck; |
98 | } |
99 | |
100 | template<class Decoder> |
101 | Optional<PolicyCheckIdentifier> PolicyCheckIdentifier::decode(Decoder& decoder) |
102 | { |
103 | auto process = ProcessIdentifier::decode(decoder); |
104 | if (!process) |
105 | return WTF::nullopt; |
106 | |
107 | uint64_t policyCheck; |
108 | if (!decoder.decode(policyCheck)) |
109 | return WTF::nullopt; |
110 | |
111 | return PolicyCheckIdentifier { *process, policyCheck }; |
112 | } |
113 | |
114 | enum class NewFrameOpenerPolicy : uint8_t { |
115 | Suppress, |
116 | Allow |
117 | }; |
118 | |
119 | enum class NavigationType : uint8_t { |
120 | LinkClicked, |
121 | FormSubmitted, |
122 | BackForward, |
123 | Reload, |
124 | FormResubmitted, |
125 | Other |
126 | }; |
127 | |
128 | enum class ShouldOpenExternalURLsPolicy : uint8_t { |
129 | ShouldNotAllow, |
130 | ShouldAllowExternalSchemes, |
131 | ShouldAllow, |
132 | }; |
133 | |
134 | enum class InitiatedByMainFrame : uint8_t { |
135 | Yes, |
136 | Unknown, |
137 | }; |
138 | |
139 | enum ClearProvisionalItemPolicy { |
140 | ShouldClearProvisionalItem, |
141 | ShouldNotClearProvisionalItem |
142 | }; |
143 | |
144 | enum class ObjectContentType : uint8_t { |
145 | None, |
146 | Image, |
147 | Frame, |
148 | PlugIn, |
149 | }; |
150 | |
151 | enum UnloadEventPolicy { |
152 | UnloadEventPolicyNone, |
153 | UnloadEventPolicyUnloadOnly, |
154 | UnloadEventPolicyUnloadAndPageHide |
155 | }; |
156 | |
157 | enum ShouldSendReferrer { |
158 | MaybeSendReferrer, |
159 | NeverSendReferrer |
160 | }; |
161 | |
162 | // Passed to FrameLoader::urlSelected() and ScriptController::executeIfJavaScriptURL() |
163 | // to control whether, in the case of a JavaScript URL, executeIfJavaScriptURL() should |
164 | // replace the document. It is a FIXME to eliminate this extra parameter from |
165 | // executeIfJavaScriptURL(), in which case this enum can go away. |
166 | enum ShouldReplaceDocumentIfJavaScriptURL { |
167 | ReplaceDocumentIfJavaScriptURL, |
168 | DoNotReplaceDocumentIfJavaScriptURL |
169 | }; |
170 | |
171 | enum WebGLLoadPolicy { |
172 | WebGLBlockCreation, |
173 | WebGLAllowCreation, |
174 | WebGLPendingCreation |
175 | }; |
176 | |
177 | enum class LockHistory : bool { No, Yes }; |
178 | enum class LockBackForwardList : bool { No, Yes }; |
179 | enum class AllowNavigationToInvalidURL : bool { No, Yes }; |
180 | enum class HasInsecureContent : bool { No, Yes }; |
181 | |
182 | struct SystemPreviewInfo { |
183 | IntRect systemPreviewRect; |
184 | bool isSystemPreview { false }; |
185 | }; |
186 | |
187 | enum class LoadCompletionType : uint8_t { |
188 | Finish, |
189 | Cancel |
190 | }; |
191 | |
192 | } // namespace WebCore |
193 | |
194 | namespace WTF { |
195 | |
196 | template<> struct EnumTraits<WebCore::PolicyAction> { |
197 | using values = EnumValues< |
198 | WebCore::PolicyAction, |
199 | WebCore::PolicyAction::Use, |
200 | WebCore::PolicyAction::Download, |
201 | WebCore::PolicyAction::Ignore, |
202 | WebCore::PolicyAction::StopAllLoads |
203 | >; |
204 | }; |
205 | |
206 | template<> struct EnumTraits<WebCore::FrameLoadType> { |
207 | using values = EnumValues< |
208 | WebCore::FrameLoadType, |
209 | WebCore::FrameLoadType::Standard, |
210 | WebCore::FrameLoadType::Back, |
211 | WebCore::FrameLoadType::Forward, |
212 | WebCore::FrameLoadType::IndexedBackForward, |
213 | WebCore::FrameLoadType::Reload, |
214 | WebCore::FrameLoadType::Same, |
215 | WebCore::FrameLoadType::RedirectWithLockedBackForwardList, |
216 | WebCore::FrameLoadType::Replace, |
217 | WebCore::FrameLoadType::ReloadFromOrigin, |
218 | WebCore::FrameLoadType::ReloadExpiredOnly |
219 | >; |
220 | }; |
221 | |
222 | } // namespace WTF |
223 | |