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