2 * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef WebFrameLoaderClient_h
27 #define WebFrameLoaderClient_h
29 #include <WebCore/FrameLoaderClient.h>
36 class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
38 WebFrameLoaderClient();
39 ~WebFrameLoaderClient();
41 void setWebFrame(WebFrame* webFrame) { m_frame = webFrame; }
42 WebFrame* webFrame() const { return m_frame; }
44 bool frameHasCustomContentProvider() const { return m_frameHasCustomContentProvider; }
47 virtual void frameLoaderDestroyed() override;
49 virtual bool hasHTMLView() const override;
50 virtual bool hasWebView() const override;
52 virtual void makeRepresentation(WebCore::DocumentLoader*) override;
54 virtual bool forceLayoutOnRestoreFromPageCache() override;
56 virtual void forceLayoutForNonHTML() override;
58 virtual void setCopiesOnScroll() override;
60 virtual void detachedFromParent2() override;
61 virtual void detachedFromParent3() override;
63 virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&) override;
65 virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse) override;
66 virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier) override;
67 virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&) override;
68 virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&) override;
69 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
70 virtual bool canAuthenticateAgainstProtectionSpace(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ProtectionSpace&) override;
73 virtual RetainPtr<CFDictionaryRef> connectionProperties(WebCore::DocumentLoader*, unsigned long identifier) override;
75 virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&) override;
76 virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int dataLength) override;
77 virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier) override;
78 virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&) override;
79 virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length) override;
81 virtual void dispatchDidHandleOnloadEvents() override;
82 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() override;
83 virtual void dispatchDidChangeProvisionalURL() override;
84 virtual void dispatchDidCancelClientRedirect() override;
85 virtual void dispatchWillPerformClientRedirect(const WebCore::URL&, double interval, double fireDate) override;
86 virtual void dispatchDidChangeLocationWithinPage() override;
87 virtual void dispatchDidPushStateWithinPage() override;
88 virtual void dispatchDidReplaceStateWithinPage() override;
89 virtual void dispatchDidPopStateWithinPage() override;
90 virtual void dispatchWillClose() override;
91 virtual void dispatchDidReceiveIcon() override;
92 virtual void dispatchDidStartProvisionalLoad() override;
93 virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&) override;
94 virtual void dispatchDidChangeIcons(WebCore::IconType) override;
95 virtual void dispatchDidCommitLoad() override;
96 virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&) override;
97 virtual void dispatchDidFailLoad(const WebCore::ResourceError&) override;
98 virtual void dispatchDidFinishDocumentLoad() override;
99 virtual void dispatchDidFinishLoad() override;
101 virtual void dispatchDidLayout(WebCore::LayoutMilestones) override;
102 virtual void dispatchDidLayout() override;
104 virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&) override;
105 virtual void dispatchShow() override;
107 virtual void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebCore::FramePolicyFunction) override;
108 virtual void dispatchDecidePolicyForNewWindowAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, const String& frameName, WebCore::FramePolicyFunction) override;
109 virtual void dispatchDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, WebCore::FramePolicyFunction) override;
110 virtual void cancelPolicyCheck() override;
112 virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&) override;
114 virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>) override;
115 virtual void dispatchWillSubmitForm(PassRefPtr<WebCore::FormState>, WebCore::FramePolicyFunction) override;
117 virtual void revertToProvisionalState(WebCore::DocumentLoader*) override;
118 virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&) override;
120 virtual void setMainFrameDocumentReady(bool) override;
122 virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String()) override;
124 virtual void willChangeTitle(WebCore::DocumentLoader*) override;
125 virtual void didChangeTitle(WebCore::DocumentLoader*) override;
127 virtual void willReplaceMultipartContent() override;
128 virtual void didReplaceMultipartContent() override;
130 virtual void committedLoad(WebCore::DocumentLoader*, const char*, int) override;
131 virtual void finishedLoading(WebCore::DocumentLoader*) override;
133 virtual void updateGlobalHistory() override;
134 virtual void updateGlobalHistoryRedirectLinks() override;
136 virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const override;
138 virtual void didDisplayInsecureContent() override;
139 virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::URL&) override;
140 virtual void didDetectXSS(const WebCore::URL&, bool didBlockEntirePage) override;
142 virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&) override;
143 virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) override;
144 virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&) override;
145 virtual WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&) override;
147 virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) override;
148 virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) override;
149 virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) override;
151 virtual bool shouldFallBack(const WebCore::ResourceError&) override;
153 virtual bool canHandleRequest(const WebCore::ResourceRequest&) const override;
154 virtual bool canShowMIMEType(const String& MIMEType) const override;
155 virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const override;
156 virtual bool representationExistsForURLScheme(const String& URLScheme) const override;
157 virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const override;
159 virtual void frameLoadCompleted() override;
160 virtual void saveViewStateToItem(WebCore::HistoryItem*) override;
161 virtual void restoreViewState() override;
162 virtual void provisionalLoadStarted() override;
163 virtual void didFinishLoad() override;
164 virtual void prepareForDataSourceReplacement() override;
166 virtual Ref<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&) override;
167 virtual void updateCachedDocumentLoader(WebCore::DocumentLoader&) override;
169 virtual void setTitle(const WebCore::StringWithDirection&, const WebCore::URL&) override;
171 virtual String userAgent(const WebCore::URL&) override;
173 virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*) override;
174 virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) override;
176 virtual void didRestoreFrameHierarchyForCachedFrame() override;
178 virtual void transitionToCommittedForNewPage() override;
180 virtual void didSaveToPageCache() override;
181 virtual void didRestoreFromPageCache() override;
183 virtual void dispatchDidBecomeFrameset(bool) override;
185 virtual bool canCachePage() const override;
186 virtual void convertMainResourceLoadToDownload(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&) override;
188 virtual RefPtr<WebCore::Frame> createFrame(const WebCore::URL&, const String& name, WebCore::HTMLFrameOwnerElement*,
189 const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) override;
191 virtual RefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::URL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) override;
192 virtual void recreatePlugin(WebCore::Widget*) override;
193 virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget) override;
196 virtual WebCore::WebGLLoadPolicy webGLPolicyForURL(const String&) const override;
197 virtual WebCore::WebGLLoadPolicy resolveWebGLPolicyForURL(const String&) const override;
198 #endif // ENABLE(WEBGL)
200 virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::URL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) override;
202 virtual WebCore::ObjectContentType objectContentType(const WebCore::URL&, const String& mimeType, bool shouldPreferPlugInsForImages) override;
203 virtual String overrideMediaType() const override;
205 virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld&) override;
207 virtual void dispatchGlobalObjectAvailable(WebCore::DOMWrapperWorld&) override;
208 virtual void dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(WebCore::DOMWindowExtension*) override;
209 virtual void dispatchDidReconnectDOMWindowExtensionToGlobalObject(WebCore::DOMWindowExtension*) override;
210 virtual void dispatchWillDestroyGlobalObjectForDOMWindowExtension(WebCore::DOMWindowExtension*) override;
212 virtual void registerForIconNotification(bool listen = true) override;
215 virtual RemoteAXObjectRef accessibilityRemoteObject() override;
217 virtual NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const override;
220 virtual bool shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const override;
222 virtual void didChangeScrollOffset() override;
224 virtual bool allowScript(bool enabledPerSettings) override;
226 virtual bool shouldForceUniversalAccessFromLocalURL(const WebCore::URL&) override;
228 virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext() override;
230 #if ENABLE(REQUEST_AUTOCOMPLETE)
231 virtual void didRequestAutocomplete(PassRefPtr<WebCore::FormState>) override;
234 virtual void forcePageTransitionIfNeeded() override;
237 virtual void didCreateQuickLookHandle(WebCore::QuickLookHandle&) override;
240 #if ENABLE(CONTENT_FILTERING)
241 void contentFilterDidBlockLoad(WebCore::ContentFilterUnblockHandler) override;
244 void prefetchDNS(const String&) override;
247 RefPtr<PluginView> m_pluginView;
248 bool m_hasSentResponseToPluginView;
249 bool m_didCompletePageTransition;
250 bool m_frameHasCustomContentProvider;
251 bool m_frameCameFromPageCache;
254 // As long as EmptyFrameLoaderClient exists in WebCore, this can return 0.
255 inline WebFrameLoaderClient* toWebFrameLoaderClient(WebCore::FrameLoaderClient& client)
257 return client.isEmptyFrameLoaderClient() ? 0 : static_cast<WebFrameLoaderClient*>(&client);
260 } // namespace WebKit
262 #endif // WebFrameLoaderClient_h