1/* 2 * Copyright (C) 2006, 2007, 2008, 2013 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 * 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. 16 * 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. 27 */ 28 29#ifndef WebFrameLoaderClient_h 30#define WebFrameLoaderClient_h 31 32#include <WebCore/COMPtr.h> 33#include <WebCore/FrameLoaderClient.h> 34#include <WebCore/ProgressTrackerClient.h> 35 36namespace WebCore { 37 class PluginManualLoader; 38 class PluginView; 39} 40 41class WebFrame; 42class WebFramePolicyListener; 43class WebHistory; 44 45class WebFrameLoaderClient : public WebCore::FrameLoaderClient, public WebCore::ProgressTrackerClient { 46public: 47 WebFrameLoaderClient(WebFrame* = 0); 48 ~WebFrameLoaderClient(); 49 50 void setWebFrame(WebFrame* webFrame) { m_webFrame = webFrame; } 51 WebFrame* webFrame() const { return m_webFrame; } 52 53 virtual bool hasWebView() const; 54 55 virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext(); 56 57 virtual void frameLoaderDestroyed() override; 58 virtual void makeRepresentation(WebCore::DocumentLoader*) override; 59 virtual void forceLayoutForNonHTML() override; 60 61 virtual void setCopiesOnScroll() override; 62 63 virtual void detachedFromParent2() override; 64 virtual void detachedFromParent3() override; 65 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&); 68 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); 78 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; 98 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; 103 104 virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&) override; 105 106 virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>) override; 107 virtual void dispatchWillSubmitForm(PassRefPtr<WebCore::FormState>, WebCore::FramePolicyFunction) override; 108 109 virtual void revertToProvisionalState(WebCore::DocumentLoader*) override; 110 virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length) override; 111 112 virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&) override; 113 virtual void dispatchShow() override; 114 115 virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&) override; 116 virtual void setMainFrameDocumentReady(bool) override; 117 118 virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String()) override; 119 120 virtual void progressStarted(WebCore::Frame&); 121 virtual void progressEstimateChanged(WebCore::Frame&); 122 virtual void progressFinished(WebCore::Frame&); 123 124 virtual void committedLoad(WebCore::DocumentLoader*, const char*, int) override; 125 virtual void finishedLoading(WebCore::DocumentLoader*) override; 126 127 virtual void willChangeTitle(WebCore::DocumentLoader*) override; 128 virtual void didChangeTitle(WebCore::DocumentLoader*) override; 129 130 virtual void updateGlobalHistory() override; 131 virtual void updateGlobalHistoryRedirectLinks() override; 132 virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const override; 133 virtual void updateGlobalHistoryItemForPage() override; 134 135 virtual void didDisplayInsecureContent() override; 136 virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::URL&) override; 137 virtual void didDetectXSS(const WebCore::URL&, bool didBlockEntirePage) override; 138 139 virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&) override; 140 virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) override; 141 virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&) override; 142 virtual WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&) override; 143 virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) override; 144 virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) override; 145 virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) override; 146 147 virtual bool shouldFallBack(const WebCore::ResourceError&) override; 148 149 virtual WTF::String userAgent(const WebCore::URL&) override; 150 151 virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); 152 virtual void setTitle(const WebCore::StringWithDirection&, const WebCore::URL&); 153 154 virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*) override; 155 virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) override; 156 virtual void transitionToCommittedForNewPage() override; 157 158 virtual bool canHandleRequest(const WebCore::ResourceRequest&) const override; 159 virtual bool canShowMIMEType(const WTF::String& MIMEType) const override; 160 virtual bool canShowMIMETypeAsHTML(const WTF::String& MIMEType) const override; 161 virtual bool representationExistsForURLScheme(const WTF::String& URLScheme) const override; 162 virtual WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const override; 163 164 virtual void frameLoadCompleted() override; 165 virtual void saveViewStateToItem(WebCore::HistoryItem *) override; 166 virtual void restoreViewState() override; 167 virtual void provisionalLoadStarted() override; 168 virtual void didFinishLoad() override; 169 virtual void prepareForDataSourceReplacement() override; 170 171 virtual void didSaveToPageCache() override; 172 virtual void didRestoreFromPageCache() override; 173 174 virtual void dispatchDidBecomeFrameset(bool) override; 175 176 virtual bool canCachePage() const; 177 178 virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::URL& url, const WTF::String& name, WebCore::HTMLFrameOwnerElement* ownerElement, 179 const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) override; 180 virtual PassRefPtr<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; 181 virtual void recreatePlugin(WebCore::Widget*) override { } 182 virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget) override; 183 184 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; 185 186 virtual WebCore::ObjectContentType objectContentType(const WebCore::URL&, const WTF::String& mimeType, bool shouldPreferPlugInsForImages) override; 187 virtual WTF::String overrideMediaType() const override; 188 189 virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld&) override; 190 191 COMPtr<WebFramePolicyListener> setUpPolicyListener(WebCore::FramePolicyFunction); 192 void receivedPolicyDecision(WebCore::PolicyAction); 193 194 virtual void registerForIconNotification(bool listen) override; 195 196 virtual bool shouldAlwaysUsePluginDocument(const WTF::String& mimeType) const; 197 198 virtual void dispatchDidFailToStartPlugin(const WebCore::PluginView*) const; 199 200protected: 201 class WebFramePolicyListenerPrivate; 202 OwnPtr<WebFramePolicyListenerPrivate> m_policyListenerPrivate; 203 204private: 205 PassRefPtr<WebCore::Frame> createFrame(const WebCore::URL&, const WTF::String& name, WebCore::HTMLFrameOwnerElement*, const WTF::String& referrer); 206 WebHistory* webHistory() const; 207 208 WebFrame* m_webFrame; 209 210 // Points to the manual loader that data should be redirected to. 211 WebCore::PluginManualLoader* m_manualLoader; 212 213 bool m_hasSentResponseToPlugin; 214}; 215 216#endif // WebFrameLoaderClient_h 217