2 * Copyright (C) 2006, 2007, 2008, 2013 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
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.
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.
29 #ifndef WebFrameLoaderClient_h
30 #define WebFrameLoaderClient_h
32 #include <WebCore/COMPtr.h>
33 #include <WebCore/FrameLoaderClient.h>
34 #include <WebCore/ProgressTrackerClient.h>
37 class PluginManualLoader;
42 class WebFramePolicyListener;
45 class WebFrameLoaderClient : public WebCore::FrameLoaderClient, public WebCore::ProgressTrackerClient {
47 WebFrameLoaderClient(WebFrame* = 0);
48 ~WebFrameLoaderClient();
50 void setWebFrame(WebFrame* webFrame) { m_webFrame = webFrame; }
51 WebFrame* webFrame() const { return m_webFrame; }
53 virtual bool hasWebView() const;
55 virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext();
57 virtual void frameLoaderDestroyed() override;
58 virtual void makeRepresentation(WebCore::DocumentLoader*) override;
59 virtual void forceLayoutForNonHTML() override;
61 virtual void setCopiesOnScroll() override;
63 virtual void detachedFromParent2() override;
64 virtual void detachedFromParent3() override;
66 virtual void convertMainResourceLoadToDownload(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&) override;
67 virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
69 virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse) override;
70 virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier) override;
71 virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&) override;
72 virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&) override;
73 virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&) override;
74 virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int dataLength) override;
75 virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier) override;
76 virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&) override;
77 virtual bool shouldCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&, const unsigned char* data, unsigned long long length);
79 virtual void dispatchDidHandleOnloadEvents() override;
80 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() override;
81 virtual void dispatchDidCancelClientRedirect() override;
82 virtual void dispatchWillPerformClientRedirect(const WebCore::URL&, double interval, double fireDate) override;
83 virtual void dispatchDidChangeLocationWithinPage() override;
84 virtual void dispatchDidPushStateWithinPage() override;
85 virtual void dispatchDidReplaceStateWithinPage() override;
86 virtual void dispatchDidPopStateWithinPage() override;
87 virtual void dispatchWillClose() override;
88 virtual void dispatchDidReceiveIcon() override;
89 virtual void dispatchDidStartProvisionalLoad() override;
90 virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&) override;
91 virtual void dispatchDidChangeIcons(WebCore::IconType) override;
92 virtual void dispatchDidCommitLoad() override;
93 virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&) override;
94 virtual void dispatchDidFailLoad(const WebCore::ResourceError&) override;
95 virtual void dispatchDidFinishDocumentLoad() override;
96 virtual void dispatchDidFinishLoad() override;
97 virtual void dispatchDidLayout(WebCore::LayoutMilestones) override;
99 virtual void dispatchDecidePolicyForResponse(const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebCore::FramePolicyFunction) override;
100 virtual void dispatchDecidePolicyForNewWindowAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, const WTF::String& frameName, WebCore::FramePolicyFunction) override;
101 virtual void dispatchDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, WebCore::FramePolicyFunction) override;
102 virtual void cancelPolicyCheck() override;
104 virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&) override;
106 virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>) override;
107 virtual void dispatchWillSubmitForm(PassRefPtr<WebCore::FormState>, WebCore::FramePolicyFunction) override;
109 virtual void revertToProvisionalState(WebCore::DocumentLoader*) override;
110 virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length) override;
112 virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&) override;
113 virtual void dispatchShow() override;
115 virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&) override;
116 virtual void setMainFrameDocumentReady(bool) override;
118 virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String()) override;
120 virtual void progressStarted(WebCore::Frame&);
121 virtual void progressEstimateChanged(WebCore::Frame&);
122 virtual void progressFinished(WebCore::Frame&);
124 virtual void committedLoad(WebCore::DocumentLoader*, const char*, int) override;
125 virtual void finishedLoading(WebCore::DocumentLoader*) override;
127 virtual void willChangeTitle(WebCore::DocumentLoader*) override;
128 virtual void didChangeTitle(WebCore::DocumentLoader*) override;
130 virtual void willReplaceMultipartContent() override { }
131 virtual void didReplaceMultipartContent() override { }
133 virtual void updateGlobalHistory() override;
134 virtual void updateGlobalHistoryRedirectLinks() override;
135 virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const override;
136 virtual void updateGlobalHistoryItemForPage() 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;
146 virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) override;
147 virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) override;
148 virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) override;
150 virtual bool shouldFallBack(const WebCore::ResourceError&) override;
152 virtual WTF::String userAgent(const WebCore::URL&) override;
154 virtual Ref<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
155 virtual void updateCachedDocumentLoader(WebCore::DocumentLoader&) override { }
157 virtual void setTitle(const WebCore::StringWithDirection&, const WebCore::URL&);
159 virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*) override;
160 virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) override;
161 virtual void transitionToCommittedForNewPage() override;
163 virtual bool canHandleRequest(const WebCore::ResourceRequest&) const override;
164 virtual bool canShowMIMEType(const WTF::String& MIMEType) const override;
165 virtual bool canShowMIMETypeAsHTML(const WTF::String& MIMEType) const override;
166 virtual bool representationExistsForURLScheme(const WTF::String& URLScheme) const override;
167 virtual WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const override;
169 virtual void frameLoadCompleted() override;
170 virtual void saveViewStateToItem(WebCore::HistoryItem *) override;
171 virtual void restoreViewState() override;
172 virtual void provisionalLoadStarted() override;
173 virtual void didFinishLoad() override;
174 virtual void prepareForDataSourceReplacement() override;
176 virtual void didSaveToPageCache() override;
177 virtual void didRestoreFromPageCache() override;
179 virtual void dispatchDidBecomeFrameset(bool) override;
181 virtual bool canCachePage() const;
183 virtual RefPtr<WebCore::Frame> createFrame(const WebCore::URL&, const WTF::String& name, WebCore::HTMLFrameOwnerElement*,
184 const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) override;
185 virtual RefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::URL&, const Vector<WTF::String>&, const Vector<WTF::String>&, const WTF::String&, bool loadManually) override;
186 virtual void recreatePlugin(WebCore::Widget*) override { }
187 virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget) override;
189 virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::URL& baseURL, const Vector<WTF::String>& paramNames, const Vector<WTF::String>& paramValues) override;
191 virtual WebCore::ObjectContentType objectContentType(const WebCore::URL&, const WTF::String& mimeType, bool shouldPreferPlugInsForImages) override;
192 virtual WTF::String overrideMediaType() const override;
194 virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld&) override;
196 COMPtr<WebFramePolicyListener> setUpPolicyListener(WebCore::FramePolicyFunction);
197 void receivedPolicyDecision(WebCore::PolicyAction);
199 virtual void registerForIconNotification(bool listen) override;
201 virtual bool shouldAlwaysUsePluginDocument(const WTF::String& mimeType) const;
203 virtual void dispatchDidFailToStartPlugin(const WebCore::PluginView*) const;
206 class WebFramePolicyListenerPrivate;
207 std::unique_ptr<WebFramePolicyListenerPrivate> m_policyListenerPrivate;
210 RefPtr<WebCore::Frame> createFrame(const WebCore::URL&, const WTF::String& name, WebCore::HTMLFrameOwnerElement*, const WTF::String& referrer);
211 WebHistory* webHistory() const;
213 WebFrame* m_webFrame;
215 // Points to the manual loader that data should be redirected to.
216 WebCore::PluginManualLoader* m_manualLoader;
218 bool m_hasSentResponseToPlugin;
221 #endif // WebFrameLoaderClient_h