1 /* 2 * Copyright (C) 2006, 2007, 2008 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 Computer, 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 #import <WebCore/FrameLoaderClient.h> 30 #import <WebCore/Timer.h> 31 #import <wtf/Forward.h> 32 #import <wtf/HashMap.h> 33 #import <wtf/RetainPtr.h> 34 35 @class WebDownload; 36 @class WebFrame; 37 @class WebFramePolicyListener; 38 @class WebHistoryItem; 39 @class WebResource; 40 41 namespace WebCore { 42 class AuthenticationChallenge; 43 class CachedFrame; 44 class HistoryItem; 45 class String; 46 class ResourceLoader; 47 class ResourceRequest; 48 } 49 50 typedef HashMap<RefPtr<WebCore::ResourceLoader>, RetainPtr<WebResource> > ResourceMap; 51 52 class WebFrameLoaderClient : public WebCore::FrameLoaderClient { 53 public: 54 WebFrameLoaderClient(WebFrame*); 55 webFrame()56 WebFrame* webFrame() const { return m_webFrame.get(); } 57 58 virtual void frameLoaderDestroyed(); 59 void receivedPolicyDecison(WebCore::PolicyAction); 60 61 private: 62 virtual bool hasWebView() const; // mainly for assertions 63 64 virtual void makeRepresentation(WebCore::DocumentLoader*); 65 virtual bool hasHTMLView() const; 66 virtual void forceLayout(); 67 virtual void forceLayoutForNonHTML(); 68 69 virtual void setCopiesOnScroll(); 70 71 virtual void detachedFromParent2(); 72 virtual void detachedFromParent3(); 73 74 virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&); 75 76 virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&); 77 78 virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse); 79 virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier); 80 virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); 81 virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); 82 virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&); 83 virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived); 84 virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier); 85 virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&); 86 87 virtual NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const; 88 89 virtual void dispatchDidHandleOnloadEvents(); 90 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); 91 virtual void dispatchDidCancelClientRedirect(); 92 virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate); 93 virtual void dispatchDidChangeLocationWithinPage(); 94 virtual void dispatchDidPushStateWithinPage(); 95 virtual void dispatchDidReplaceStateWithinPage(); 96 virtual void dispatchDidPopStateWithinPage(); 97 98 virtual void dispatchWillClose(); 99 virtual void dispatchDidReceiveIcon(); 100 virtual void dispatchDidStartProvisionalLoad(); 101 virtual void dispatchDidReceiveTitle(const WebCore::String& title); 102 virtual void dispatchDidCommitLoad(); 103 virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&); 104 virtual void dispatchDidFailLoad(const WebCore::ResourceError&); 105 virtual void dispatchDidFinishDocumentLoad(); 106 virtual void dispatchDidFinishLoad(); 107 virtual void dispatchDidFirstLayout(); 108 virtual void dispatchDidFirstVisuallyNonEmptyLayout(); 109 110 virtual WebCore::Frame* dispatchCreatePage(); 111 virtual void dispatchShow(); 112 113 virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction, 114 const WebCore::String& MIMEType, const WebCore::ResourceRequest&); 115 virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction, 116 const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, const WebCore::String& frameName); 117 virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction, 118 const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>); 119 virtual void cancelPolicyCheck(); 120 121 virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); 122 123 virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>); 124 125 virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); 126 virtual void revertToProvisionalState(WebCore::DocumentLoader*); 127 virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); 128 virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length); 129 virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::ScriptString&); 130 131 virtual void willChangeEstimatedProgress(); 132 virtual void didChangeEstimatedProgress(); 133 virtual void postProgressStartedNotification(); 134 virtual void postProgressEstimateChangedNotification(); 135 virtual void postProgressFinishedNotification(); 136 137 virtual void setMainFrameDocumentReady(bool); 138 139 virtual void startDownload(const WebCore::ResourceRequest&); 140 141 virtual void willChangeTitle(WebCore::DocumentLoader*); 142 virtual void didChangeTitle(WebCore::DocumentLoader*); 143 144 virtual void committedLoad(WebCore::DocumentLoader*, const char*, int); 145 virtual void finishedLoading(WebCore::DocumentLoader*); 146 virtual void updateGlobalHistory(); 147 virtual void updateGlobalHistoryRedirectLinks(); 148 149 virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const; 150 virtual void dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const; 151 virtual void dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const; 152 virtual void dispatchDidChangeBackForwardIndex() const; 153 154 virtual void didDisplayInsecureContent(); 155 virtual void didRunInsecureContent(WebCore::SecurityOrigin*); 156 157 virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&); 158 virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&); 159 virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&); 160 virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&); 161 162 virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&); 163 virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&); 164 virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&); 165 166 virtual bool shouldFallBack(const WebCore::ResourceError&); 167 168 virtual WebCore::String userAgent(const WebCore::KURL&); 169 170 virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*); 171 virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*); 172 virtual void transitionToCommittedForNewPage(); 173 174 virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; 175 virtual bool canShowMIMEType(const WebCore::String& MIMEType) const; 176 virtual bool representationExistsForURLScheme(const WebCore::String& URLScheme) const; 177 virtual WebCore::String generatedMIMETypeForURLScheme(const WebCore::String& URLScheme) const; 178 179 virtual void frameLoadCompleted(); 180 virtual void saveViewStateToItem(WebCore::HistoryItem*); 181 virtual void restoreViewState(); 182 virtual void provisionalLoadStarted(); 183 virtual void didFinishLoad(); 184 virtual void prepareForDataSourceReplacement(); 185 virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); 186 187 virtual void setTitle(const WebCore::String& title, const WebCore::KURL&); 188 189 virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WebCore::String& name, WebCore::HTMLFrameOwnerElement*, 190 const WebCore::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); 191 virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<WebCore::String>&, 192 const Vector<WebCore::String>&, const WebCore::String&, bool); 193 virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget); 194 195 virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, 196 const Vector<WebCore::String>& paramNames, const Vector<WebCore::String>& paramValues); 197 198 virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType); 199 virtual WebCore::String overrideMediaType() const; 200 201 virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); 202 virtual void documentElementAvailable(); 203 virtual void didPerformFirstNavigation() const; 204 205 virtual void registerForIconNotification(bool listen); 206 207 #if ENABLE(MAC_JAVA_BRIDGE) 208 virtual jobject javaApplet(NSView*); 209 #endif 210 211 void setOriginalURLForDownload(WebDownload *, const WebCore::ResourceRequest&) const; 212 213 RetainPtr<WebFramePolicyListener> setUpPolicyListener(WebCore::FramePolicyFunction); 214 215 NSDictionary *actionDictionary(const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>) const; 216 217 virtual bool canCachePage() const; 218 219 RetainPtr<WebFrame> m_webFrame; 220 221 RetainPtr<WebFramePolicyListener> m_policyListener; 222 WebCore::FramePolicyFunction m_policyFunction; 223 }; 224