forked from qtwebkit/qtwebkit
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathFrameLoaderClientQt.h
More file actions
264 lines (204 loc) · 12.2 KB
/
FrameLoaderClientQt.h
File metadata and controls
264 lines (204 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*
* Copyright (C) 2006 Zack Rusin <zack@kde.org>
* Copyright (C) 2006, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2008 Collabora Ltd. All rights reserved.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef FrameLoaderClientQt_h
#define FrameLoaderClientQt_h
#include <WebCore/CachedResource.h>
#include <WebCore/FormState.h>
#include <WebCore/LocalFrameLoaderClient.h>
#include <WebCore/NetworkLoadMetrics.h>
#include <WebCore/ProcessSwapDisposition.h>
#include <WebCore/ResourceResponse.h>
#include <WebCore/ResourceError.h>
#include <QObject>
#include "qwebresourcetypes.h"
#include <QUrl>
#include <wtf/URL.h>
QT_BEGIN_NAMESPACE
class QNetworkReply;
QT_END_NAMESPACE
class QWebFrame;
class QWebFrameAdapter;
namespace WebCore {
class AuthenticationChallenge;
class DocumentLoader;
class Element;
class FormState;
class NavigationAction;
class FrameNetworkingContext;
class ResourceLoader;
struct LoadErrorResetToken;
class FrameLoaderClientQt final : public QObject, public LocalFrameLoaderClient {
Q_OBJECT
friend class ::QWebFrameAdapter;
bool callErrorPageExtension(const ResourceError&);
Q_SIGNALS:
void titleChanged(const QString& title);
void unsupportedContent(QNetworkReply*);
void resourceLoadStarted(const QUrl& url, const QtResourceRequestInfo& requestInfo, bool fromCache);
void resourceLoadFinished(const QUrl& url, qint64 size, const QtResourceTimingInfo& timing, bool success);
public:
FrameLoaderClientQt(WebCore::FrameLoader&);
~FrameLoaderClientQt();
void setFrame(QWebFrameAdapter*, LocalFrame*);
bool hasWebView() const override; // mainly for assertions
void makeRepresentation(DocumentLoader*) override { }
void forceLayoutForNonHTML() override;
void setCopiesOnScroll() override;
void detachedFromParent2() override;
void detachedFromParent3() override;
void assignIdentifierToInitialRequest(WebCore::ResourceLoaderIdentifier, WebCore::IsMainResourceLoad, WebCore::DocumentLoader*, const WebCore::ResourceRequest&) override;
void dispatchLoadEventToOwnerElementInAnotherProcess() override { };
void dispatchWillSendRequest(WebCore::DocumentLoader*, WebCore::ResourceLoaderIdentifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse&) override;
bool shouldUseCredentialStorage(DocumentLoader*, WebCore::ResourceLoaderIdentifier identifier) override;
void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, WebCore::ResourceLoaderIdentifier identifier, const AuthenticationChallenge&) override;
void dispatchDidReceiveResponse(WebCore::DocumentLoader*, WebCore::ResourceLoaderIdentifier, const WebCore::ResourceResponse&) override;
void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, WebCore::ResourceLoaderIdentifier, int) override;
void dispatchDidFinishLoading(WebCore::DocumentLoader*, WebCore::IsMainResourceLoad, WebCore::ResourceLoaderIdentifier) override;
void dispatchDidFailLoading(WebCore::DocumentLoader*, WebCore::IsMainResourceLoad, WebCore::ResourceLoaderIdentifier, const WebCore::ResourceError&) override;
bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int) override;
void dispatchDidStartResourceLoad(const WebCore::CachedResource&) override;
void dispatchDidFinishResourceLoad(const WebCore::CachedResource&) override;
void dispatchDidDispatchOnloadEvents() override;
void dispatchDidReceiveServerRedirectForProvisionalLoad() override;
void dispatchDidCancelClientRedirect() override;
void dispatchWillPerformClientRedirect(const URL&, double interval, WallTime fireDate, LockBackForwardList) override;
void dispatchDidNavigateWithinPage() override;
void dispatchDidChangeLocationWithinPage() override;
void dispatchDidPushStateWithinPage() override;
void dispatchDidReplaceStateWithinPage() override;
void dispatchDidPopStateWithinPage() override;
void dispatchWillClose() override;
void dispatchDidReceiveIcon() override;
void dispatchDidStartProvisionalLoad() override;
void dispatchDidReceiveTitle(const StringWithDirection&) override;
void dispatchDidCommitLoad(std::optional<HasInsecureContent>, std::optional<WebCore::UsedLegacyTLS>, std::optional<WebCore::WasPrivateRelayed>) override;
void dispatchDidFailProvisionalLoad(const ResourceError&, WillContinueLoading, WillInternallyHandleFailure) override;
void dispatchDidFailLoad(const WebCore::ResourceError&) override;
void dispatchDidFinishDocumentLoad() override;
void dispatchDidFinishLoad() override;
void dispatchDidReachLayoutMilestone(OptionSet<LayoutMilestone>) override;
WebCore::LocalFrame* dispatchCreatePage(const WebCore::NavigationAction&, NewFrameOpenerPolicy) override;
void dispatchShow() override;
void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, const String& downloadAttribute, FramePolicyFunction&&) override;
void dispatchDecidePolicyForNewWindowAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, FormState*, const String&, std::optional<HitTestResult>&&, FramePolicyFunction&&) override;
void dispatchDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse, WebCore::FormState*, const String&, std::optional<NavigationIdentifier>, std::optional<HitTestResult>&&, bool, IsPerformingHTTPFallback, WebCore::SandboxFlags, WebCore::PolicyDecisionMode, FramePolicyFunction&&) override;
void cancelPolicyCheck() override;
void dispatchUnableToImplementPolicy(const WebCore::ResourceError&) override;
void dispatchWillSendSubmitEvent(Ref<FormState>&&) override { }
void dispatchWillSubmitForm(FormState&, CompletionHandler<void()>&&) override;
void revertToProvisionalState(DocumentLoader*) override { }
void setMainDocumentError(DocumentLoader*, const ResourceError&) override;
void setMainFrameDocumentReady(bool) override;
void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String(), FromDownloadAttribute = FromDownloadAttribute::No) override;
void willChangeTitle(DocumentLoader*) override;
void didChangeTitle(DocumentLoader*) override;
void committedLoad(WebCore::DocumentLoader*, const SharedBuffer&) override;
void finishedLoading(DocumentLoader*) override;
void updateGlobalHistory() override;
void updateGlobalHistoryRedirectLinks() override;
ShouldGoToHistoryItem shouldGoToHistoryItem(HistoryItem&, IsSameDocumentNavigation, ProcessSwapDisposition processSwapDisposition) const override;
bool supportsAsyncShouldGoToHistoryItem() const override;
void shouldGoToHistoryItemAsync(HistoryItem&, CompletionHandler<void(ShouldGoToHistoryItem)>&&) const override;
void didDisplayInsecureContent() override;
void didRunInsecureContent(SecurityOrigin&) override;
void loadStorageAccessQuirksIfNeeded() final { }
bool shouldFallBack(const ResourceError&) const override;
bool canHandleRequest(const WebCore::ResourceRequest&) const override;
bool canShowMIMEType(const String& MIMEType) const override;
bool canShowMIMETypeAsHTML(const String& MIMEType) const override;
bool representationExistsForURLScheme(StringView URLScheme) const override;
String generatedMIMETypeForURLScheme(StringView URLScheme) const override;
void frameLoadCompleted() override;
void saveViewStateToItem(WebCore::HistoryItem&) override;
void restoreViewState() override;
void provisionalLoadStarted() override;
void didFinishLoad() override;
void prepareForDataSourceReplacement() override;
Ref<WebCore::DocumentLoader> createDocumentLoader(WebCore::ResourceRequest&&, WebCore::SubstituteData&&) override;
void setTitle(const StringWithDirection&, const URL&) override;
String userAgent(const WTF::URL&) const override;
void savePlatformDataToCachedFrame(WebCore::CachedFrame*) override;
void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) override;
void transitionToCommittedForNewPage(InitializingIframe) override;
void didRestoreFromBackForwardCache() override;
bool canCachePage() const override;
void convertMainResourceLoadToDownload(DocumentLoader*, const ResourceRequest&, const WebCore::ResourceResponse&) override;
RefPtr<LocalFrame> createFrame(const AtomString& name, HTMLFrameOwnerElement&) override;
RefPtr<Widget> createPlugin(HTMLPlugInElement&, const URL&, const Vector<AtomString>&, const Vector<AtomString>&, const String&, bool) override;
void redirectDataToPlugin(Widget& pluginWidget) override;
ObjectContentType objectContentType(const URL&, const String& mimeTypeIn) override;
AtomString overrideMediaType() const override;
void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld&) override;
void registerForIconNotification() override;
void willReplaceMultipartContent() override;
void didReplaceMultipartContent() override;
void updateCachedDocumentLoader(DocumentLoader &) override;
void prefetchDNS(const WTF::String &) override;
Ref<FrameNetworkingContext> createNetworkingContext() override;
const URL& lastRequestedUrl() const { return m_lastRequestedUrl; }
QWebFrameAdapter* webFrame() const;
void originatingLoadStarted() { m_isOriginatingLoad = true; }
void sendH2Ping(const URL&, CompletionHandler<void(Expected<Seconds, ResourceError>&&)>&&) override;
void updateSandboxFlags(WebCore::SandboxFlags) override { }
void updateOpener(const WebCore::Frame&) override { }
RefPtr<HistoryItem> createHistoryItemTree(bool clipAtTarget, BackForwardItemIdentifier itemID) const override;
static bool dumpFrameLoaderCallbacks;
static bool dumpUserGestureInFrameLoaderCallbacks;
static bool dumpResourceLoadCallbacks;
static bool dumpResourceResponseMIMETypes;
static bool dumpWillCacheResponseCallbacks;
static QString dumpResourceLoadCallbacksPath;
static bool sendRequestReturnsNullOnRedirect;
static bool sendRequestReturnsNull;
static QStringList sendRequestClearHeaders;
static bool policyDelegateEnabled;
static bool policyDelegatePermissive;
static bool deferMainResourceDataLoad;
static bool dumpHistoryCallbacks;
static QMap<QString, QString> URLsToRedirect;
private Q_SLOTS:
void onIconLoadedForPageURL(const QString&);
private:
void emitLoadStarted();
void emitLoadFinished(bool ok);
LocalFrame *m_frame;
QWebFrameAdapter *m_webFrame;
ResourceResponse m_response;
WTF::URL m_lastRequestedUrl;
bool m_isOriginatingLoad;
// QTFIXME: consider introducing some sort of flags for storing state
bool m_isDisplayingErrorPage;
bool m_shouldSuppressLoadStarted;
// Helper methods for resource tracking
QString resourceTypeToString(WebCore::CachedResource::Type type) const;
QtResourceTimingInfo extractTimingInfo(const WebCore::NetworkLoadMetrics& metrics) const;
};
}
#endif