Drop FrameLoaderClient::sessionID()
[WebKit-https.git] / Source / WebKit / WebProcess / WebCoreSupport / WebFrameLoaderClient.h
1 /*
2  * Copyright (C) 2010-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. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #pragma once
27
28 #include "WebPageProxyIdentifier.h"
29 #include <WebCore/FrameLoaderClient.h>
30 #include <pal/SessionID.h>
31
32 namespace PAL {
33 class SessionID;
34 }
35
36 namespace WebKit {
37
38 class PluginView;
39 class WebFrame;
40 struct WebsitePoliciesData;
41     
42 class WebFrameLoaderClient final : public WebCore::FrameLoaderClient {
43 public:
44     WebFrameLoaderClient();
45     ~WebFrameLoaderClient();
46
47     void setWebFrame(WebFrame* webFrame) { m_frame = webFrame; }
48     WebFrame* webFrame() const { return m_frame; }
49
50     bool frameHasCustomContentProvider() const { return m_frameHasCustomContentProvider; }
51
52     void setUseIconLoadingClient(bool useIconLoadingClient) { m_useIconLoadingClient = useIconLoadingClient; }
53
54     void applyToDocumentLoader(WebsitePoliciesData&&);
55
56     Optional<WebPageProxyIdentifier> webPageProxyID() const;
57     Optional<WebCore::PageIdentifier> pageID() const final;
58     Optional<WebCore::FrameIdentifier> frameID() const final;
59
60 #if ENABLE(RESOURCE_LOAD_STATISTICS)
61     bool hasFrameSpecificStorageAccess() final { return !!m_frameSpecificStorageAccessIdentifier; }
62     
63     struct FrameSpecificStorageAccessIdentifier {
64         PAL::SessionID sessionID;
65         WebCore::FrameIdentifier frameID;
66         WebCore::PageIdentifier pageID;
67     };
68     void setHasFrameSpecificStorageAccess(FrameSpecificStorageAccessIdentifier&&);
69 #endif
70     
71 private:
72     void frameLoaderDestroyed() final;
73
74     bool hasHTMLView() const final;
75     bool hasWebView() const final;
76     
77     void makeRepresentation(WebCore::DocumentLoader*) final;
78 #if PLATFORM(IOS_FAMILY)
79     bool forceLayoutOnRestoreFromPageCache() final;
80 #endif
81     void forceLayoutForNonHTML() final;
82     
83     void setCopiesOnScroll() final;
84     
85     void detachedFromParent2() final;
86     void detachedFromParent3() final;
87     
88     void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&) final;
89     
90     void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse) final;
91     bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier) final;
92     void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&) final;
93 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
94     bool canAuthenticateAgainstProtectionSpace(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ProtectionSpace&) final;
95 #endif
96 #if PLATFORM(IOS_FAMILY)
97     RetainPtr<CFDictionaryRef> connectionProperties(WebCore::DocumentLoader*, unsigned long identifier) final;
98 #endif
99     void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&) final;
100     void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int dataLength) final;
101     void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier) final;
102     void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&) final;
103     bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length) final;
104 #if ENABLE(DATA_DETECTION)
105     void dispatchDidFinishDataDetection(NSArray *detectionResults) final;
106 #endif
107     void dispatchDidChangeMainDocument() final;
108     void dispatchWillChangeDocument(const URL& currentUrl, const URL& newUrl) final;
109
110     void dispatchDidDispatchOnloadEvents() final;
111     void dispatchDidReceiveServerRedirectForProvisionalLoad() final;
112     void dispatchDidChangeProvisionalURL() final;
113     void dispatchDidCancelClientRedirect() final;
114     void dispatchWillPerformClientRedirect(const URL&, double interval, WallTime fireDate, WebCore::LockBackForwardList) final;
115     void dispatchDidChangeLocationWithinPage() final;
116     void dispatchDidPushStateWithinPage() final;
117     void dispatchDidReplaceStateWithinPage() final;
118     void dispatchDidPopStateWithinPage() final;
119     void dispatchWillClose() final;
120     void dispatchDidStartProvisionalLoad() final;
121     void dispatchDidReceiveTitle(const WebCore::StringWithDirection&) final;
122     void dispatchDidCommitLoad(Optional<WebCore::HasInsecureContent>) final;
123     void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&, WebCore::WillContinueLoading) final;
124     void dispatchDidFailLoad(const WebCore::ResourceError&) final;
125     void dispatchDidFinishDocumentLoad() final;
126     void dispatchDidFinishLoad() final;
127     void dispatchDidExplicitOpen(const URL&) final;
128
129     void dispatchDidReachLayoutMilestone(OptionSet<WebCore::LayoutMilestone>) final;
130     void dispatchDidLayout() final;
131
132     WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&) final;
133     void dispatchShow() final;
134     
135     void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebCore::PolicyCheckIdentifier, const String&, WebCore::FramePolicyFunction&&) final;
136     void dispatchDecidePolicyForNewWindowAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, WebCore::FormState*, const String& frameName, WebCore::PolicyCheckIdentifier, WebCore::FramePolicyFunction&&) final;
137     void dispatchDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse, WebCore::FormState*, WebCore::PolicyDecisionMode, WebCore::PolicyCheckIdentifier, WebCore::FramePolicyFunction&&) final;
138     void cancelPolicyCheck() final;
139     
140     void dispatchUnableToImplementPolicy(const WebCore::ResourceError&) final;
141     
142     void dispatchWillSendSubmitEvent(Ref<WebCore::FormState>&&) final;
143     void dispatchWillSubmitForm(WebCore::FormState&, CompletionHandler<void()>&&) final;
144     
145     void revertToProvisionalState(WebCore::DocumentLoader*) final;
146     void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&) final;
147     
148     void setMainFrameDocumentReady(bool) final;
149     
150     void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String()) final;
151     
152     void willChangeTitle(WebCore::DocumentLoader*) final;
153     void didChangeTitle(WebCore::DocumentLoader*) final;
154
155     void willReplaceMultipartContent() final;
156     void didReplaceMultipartContent() final;
157
158     void committedLoad(WebCore::DocumentLoader*, const char*, int) final;
159     void finishedLoading(WebCore::DocumentLoader*) final;
160     
161     void updateGlobalHistory() final;
162     void updateGlobalHistoryRedirectLinks() final;
163     
164     bool shouldGoToHistoryItem(WebCore::HistoryItem&) const final;
165
166     void didDisplayInsecureContent() final;
167     void didRunInsecureContent(WebCore::SecurityOrigin&, const URL&) final;
168     void didDetectXSS(const URL&, bool didBlockEntirePage) final;
169
170     WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&) final;
171     WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) final;
172     WebCore::ResourceError blockedByContentBlockerError(const WebCore::ResourceRequest&) final;
173     WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&) final;
174     WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&) final;
175 #if ENABLE(CONTENT_FILTERING)
176     WebCore::ResourceError blockedByContentFilterError(const WebCore::ResourceRequest&) final;
177 #endif
178     
179     WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) final;
180     WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) final;
181     WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) final;
182     
183     bool shouldFallBack(const WebCore::ResourceError&) final;
184     
185     bool canHandleRequest(const WebCore::ResourceRequest&) const final;
186     bool canShowMIMEType(const String& MIMEType) const final;
187     bool canShowMIMETypeAsHTML(const String& MIMEType) const final;
188     bool representationExistsForURLScheme(const String& URLScheme) const final;
189     String generatedMIMETypeForURLScheme(const String& URLScheme) const final;
190     
191     void frameLoadCompleted() final;
192     void saveViewStateToItem(WebCore::HistoryItem&) final;
193     void restoreViewState() final;
194     void provisionalLoadStarted() final;
195     void didFinishLoad() final;
196     void prepareForDataSourceReplacement() final;
197     
198     Ref<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&) final;
199     void updateCachedDocumentLoader(WebCore::DocumentLoader&) final;
200
201     void setTitle(const WebCore::StringWithDirection&, const URL&) final;
202     
203     String userAgent(const URL&) final;
204
205     String overrideContentSecurityPolicy() const final;
206
207     void savePlatformDataToCachedFrame(WebCore::CachedFrame*) final;
208     void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) final;
209 #if PLATFORM(IOS_FAMILY)
210     void didRestoreFrameHierarchyForCachedFrame() final;
211 #endif
212     void transitionToCommittedForNewPage() final;
213
214     void didSaveToPageCache() final;
215     void didRestoreFromPageCache() final;
216
217     void dispatchDidBecomeFrameset(bool) final;
218
219     bool canCachePage() const final;
220     void convertMainResourceLoadToDownload(WebCore::DocumentLoader*, PAL::SessionID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&) final;
221
222     RefPtr<WebCore::Frame> createFrame(const URL&, const String& name, WebCore::HTMLFrameOwnerElement&, const String& referrer) final;
223
224     RefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement&, const URL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) final;
225     void redirectDataToPlugin(WebCore::Widget&) final;
226     
227 #if ENABLE(WEBGL)
228     WebCore::WebGLLoadPolicy webGLPolicyForURL(const URL&) const final;
229     WebCore::WebGLLoadPolicy resolveWebGLPolicyForURL(const URL&) const final;
230 #endif // ENABLE(WEBGL)
231
232     RefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement&, const URL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) final;
233     
234     WebCore::ObjectContentType objectContentType(const URL&, const String& mimeType) final;
235     String overrideMediaType() const final;
236
237     void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld&) final;
238     
239     void dispatchGlobalObjectAvailable(WebCore::DOMWrapperWorld&) final;
240     void dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(WebCore::DOMWindowExtension*) final;
241     void dispatchDidReconnectDOMWindowExtensionToGlobalObject(WebCore::DOMWindowExtension*) final;
242     void dispatchWillDestroyGlobalObjectForDOMWindowExtension(WebCore::DOMWindowExtension*) final;
243
244     void willInjectUserScript(WebCore::DOMWrapperWorld&) final;
245
246 #if PLATFORM(COCOA)
247     RemoteAXObjectRef accessibilityRemoteObject() final;
248     
249     void willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*, CompletionHandler<void(NSCachedURLResponse *)>&&) const final;
250
251     NSDictionary *dataDetectionContext() final;
252 #endif
253
254     void didChangeScrollOffset() final;
255
256     bool allowScript(bool enabledPerSettings) final;
257
258     bool shouldForceUniversalAccessFromLocalURL(const URL&) final;
259
260     Ref<WebCore::FrameNetworkingContext> createNetworkingContext() final;
261
262     void forcePageTransitionIfNeeded() final;
263
264 #if USE(QUICK_LOOK)
265     RefPtr<WebCore::PreviewLoaderClient> createPreviewLoaderClient(const String& fileName, const String& uti) final;
266 #endif
267
268 #if ENABLE(CONTENT_FILTERING)
269     void contentFilterDidBlockLoad(WebCore::ContentFilterUnblockHandler) final;
270 #endif
271
272     void prefetchDNS(const String&) final;
273
274     void didRestoreScrollPosition() final;
275
276     void getLoadDecisionForIcons(const Vector<std::pair<WebCore::LinkIcon&, uint64_t>>&) final;
277     void finishedLoadingIcon(uint64_t callbackIdentifier, WebCore::SharedBuffer*) final;
278
279     void didCreateWindow(WebCore::DOMWindow&) final;
280
281 #if ENABLE(APPLICATION_MANIFEST)
282     void finishedLoadingApplicationManifest(uint64_t, const Optional<WebCore::ApplicationManifest>&) final;
283 #endif
284
285     WebFrame* m_frame;
286     RefPtr<PluginView> m_pluginView;
287     bool m_hasSentResponseToPluginView;
288     bool m_didCompletePageTransition;
289     bool m_frameHasCustomContentProvider;
290     bool m_frameCameFromPageCache;
291     bool m_useIconLoadingClient { false };
292 #if ENABLE(RESOURCE_LOAD_STATISTICS)
293     Optional<FrameSpecificStorageAccessIdentifier> m_frameSpecificStorageAccessIdentifier;
294 #endif
295 };
296
297 // As long as EmptyFrameLoaderClient exists in WebCore, this can return 0.
298 inline WebFrameLoaderClient* toWebFrameLoaderClient(WebCore::FrameLoaderClient& client)
299 {
300     return client.isEmptyFrameLoaderClient() ? 0 : static_cast<WebFrameLoaderClient*>(&client);
301 }
302
303 } // namespace WebKit