1 /* 2 * Copyright (C) 2006, 2007, 2008, 2009 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 #ifndef FrameLoaderClient_h 30 #define FrameLoaderClient_h 31 32 #include "FrameLoaderTypes.h" 33 #include "ScrollTypes.h" 34 #include <wtf/Forward.h> 35 #include <wtf/Platform.h> 36 #include <wtf/Vector.h> 37 38 typedef class _jobject* jobject; 39 40 #if PLATFORM(MAC) && !defined(__OBJC__) 41 class NSCachedURLResponse; 42 class NSView; 43 #endif 44 45 namespace WebCore { 46 47 class AuthenticationChallenge; 48 class CachedFrame; 49 class Color; 50 class DocumentLoader; 51 class Element; 52 class FormState; 53 class Frame; 54 class FrameLoader; 55 class HistoryItem; 56 class HTMLAppletElement; 57 class HTMLFrameOwnerElement; 58 class HTMLPlugInElement; 59 class IntSize; 60 class KURL; 61 class NavigationAction; 62 class PluginView; 63 class ResourceError; 64 class ResourceHandle; 65 class ResourceLoader; 66 struct ResourceRequest; 67 class ResourceResponse; 68 class ScriptString; 69 class SharedBuffer; 70 class SubstituteData; 71 class String; 72 class Widget; 73 74 #ifdef ANDROID_HISTORY_CLIENT 75 class BackForwardList; 76 #endif 77 78 typedef void (FrameLoader::*FramePolicyFunction)(PolicyAction); 79 80 class FrameLoaderClient { 81 public: 82 // An inline function cannot be the first non-abstract virtual function declared 83 // in the class as it results in the vtable being generated as a weak symbol. 84 // This hurts performance (in Mac OS X at least, when loadig frameworks), so we 85 // don't want to do it in WebKit. 86 virtual bool hasHTMLView() const; 87 ~FrameLoaderClient()88 virtual ~FrameLoaderClient() { } 89 90 virtual void frameLoaderDestroyed() = 0; 91 92 virtual bool hasWebView() const = 0; // mainly for assertions 93 94 virtual void makeRepresentation(DocumentLoader*) = 0; 95 virtual void forceLayout() = 0; 96 virtual void forceLayoutForNonHTML() = 0; 97 98 virtual void setCopiesOnScroll() = 0; 99 100 virtual void detachedFromParent2() = 0; 101 virtual void detachedFromParent3() = 0; 102 103 virtual void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&) = 0; 104 105 virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse) = 0; 106 virtual bool shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier) = 0; 107 virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) = 0; 108 virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) = 0; 109 virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&) = 0; 110 virtual void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived) = 0; 111 virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) = 0; 112 virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&) = 0; 113 virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) = 0; 114 virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString&) = 0; 115 116 virtual void dispatchDidHandleOnloadEvents() = 0; 117 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0; 118 virtual void dispatchDidCancelClientRedirect() = 0; 119 virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate) = 0; 120 virtual void dispatchDidChangeLocationWithinPage() = 0; 121 virtual void dispatchWillClose() = 0; 122 virtual void dispatchDidReceiveIcon() = 0; 123 virtual void dispatchDidStartProvisionalLoad() = 0; 124 virtual void dispatchDidReceiveTitle(const String& title) = 0; 125 virtual void dispatchDidCommitLoad() = 0; 126 virtual void dispatchDidFailProvisionalLoad(const ResourceError&) = 0; 127 virtual void dispatchDidFailLoad(const ResourceError&) = 0; 128 virtual void dispatchDidFinishDocumentLoad() = 0; 129 virtual void dispatchDidFinishLoad() = 0; 130 virtual void dispatchDidFirstLayout() = 0; 131 virtual void dispatchDidFirstVisuallyNonEmptyLayout() = 0; 132 133 virtual Frame* dispatchCreatePage() = 0; 134 virtual void dispatchShow() = 0; 135 136 virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction, const String& MIMEType, const ResourceRequest&) = 0; 137 virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName) = 0; 138 virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>) = 0; 139 virtual void cancelPolicyCheck() = 0; 140 141 virtual void dispatchUnableToImplementPolicy(const ResourceError&) = 0; 142 143 virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>) = 0; 144 145 virtual void dispatchDidLoadMainResource(DocumentLoader*) = 0; 146 virtual void revertToProvisionalState(DocumentLoader*) = 0; 147 virtual void setMainDocumentError(DocumentLoader*, const ResourceError&) = 0; 148 149 // Maybe these should go into a ProgressTrackerClient some day willChangeEstimatedProgress()150 virtual void willChangeEstimatedProgress() { } didChangeEstimatedProgress()151 virtual void didChangeEstimatedProgress() { } 152 virtual void postProgressStartedNotification() = 0; 153 virtual void postProgressEstimateChangedNotification() = 0; 154 virtual void postProgressFinishedNotification() = 0; 155 156 virtual void setMainFrameDocumentReady(bool) = 0; 157 158 virtual void startDownload(const ResourceRequest&) = 0; 159 160 virtual void willChangeTitle(DocumentLoader*) = 0; 161 virtual void didChangeTitle(DocumentLoader*) = 0; 162 163 virtual void committedLoad(DocumentLoader*, const char*, int) = 0; 164 virtual void finishedLoading(DocumentLoader*) = 0; 165 166 virtual void updateGlobalHistory() = 0; 167 virtual void updateGlobalHistoryRedirectLinks() = 0; 168 169 virtual bool shouldGoToHistoryItem(HistoryItem*) const = 0; 170 #ifdef ANDROID_HISTORY_CLIENT 171 virtual void dispatchDidAddHistoryItem(HistoryItem*) const = 0; 172 virtual void dispatchDidRemoveHistoryItem(HistoryItem*, int) const = 0; 173 virtual void dispatchDidChangeHistoryIndex(BackForwardList*) const = 0; 174 #endif 175 176 virtual ResourceError cancelledError(const ResourceRequest&) = 0; 177 virtual ResourceError blockedError(const ResourceRequest&) = 0; 178 virtual ResourceError cannotShowURLError(const ResourceRequest&) = 0; 179 virtual ResourceError interruptForPolicyChangeError(const ResourceRequest&) = 0; 180 181 virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) = 0; 182 virtual ResourceError fileDoesNotExistError(const ResourceResponse&) = 0; 183 virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&) = 0; 184 185 virtual bool shouldFallBack(const ResourceError&) = 0; 186 187 virtual bool canHandleRequest(const ResourceRequest&) const = 0; 188 virtual bool canShowMIMEType(const String& MIMEType) const = 0; 189 virtual bool representationExistsForURLScheme(const String& URLScheme) const = 0; 190 virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const = 0; 191 192 virtual void frameLoadCompleted() = 0; 193 virtual void saveViewStateToItem(HistoryItem*) = 0; 194 virtual void restoreViewState() = 0; 195 virtual void provisionalLoadStarted() = 0; 196 virtual void didFinishLoad() = 0; 197 virtual void prepareForDataSourceReplacement() = 0; 198 199 virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) = 0; 200 virtual void setTitle(const String& title, const KURL&) = 0; 201 202 virtual String userAgent(const KURL&) = 0; 203 204 virtual void savePlatformDataToCachedFrame(CachedFrame*) = 0; 205 virtual void transitionToCommittedFromCachedFrame(CachedFrame*) = 0; 206 virtual void transitionToCommittedForNewPage() = 0; 207 208 virtual bool canCachePage() const = 0; 209 virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&) = 0; 210 211 virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, 212 const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) = 0; 213 virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0; 214 virtual void redirectDataToPlugin(Widget* pluginWidget) = 0; 215 216 virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) = 0; 217 dispatchDidFailToStartPlugin(const PluginView *)218 virtual void dispatchDidFailToStartPlugin(const PluginView*) const { } 219 220 virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType) = 0; 221 virtual String overrideMediaType() const = 0; 222 223 virtual void windowObjectCleared() = 0; 224 virtual void documentElementAvailable() = 0; 225 virtual void didPerformFirstNavigation() const = 0; // "Navigation" here means a transition from one page to another that ends up in the back/forward list. 226 227 #if USE(V8) 228 virtual void didCreateScriptContextForFrame() = 0; 229 virtual void didDestroyScriptContextForFrame() = 0; 230 virtual void didCreateIsolatedScriptContext() = 0; 231 #endif 232 233 virtual void registerForIconNotification(bool listen = true) = 0; 234 #ifdef ANDROID_APPLE_TOUCH_ICON 235 virtual void dispatchDidReceiveTouchIconURL(const String& url, bool precomposed) = 0; 236 #endif 237 238 #if PLATFORM(MAC) 239 #if ENABLE(MAC_JAVA_BRIDGE) javaApplet(NSView *)240 virtual jobject javaApplet(NSView*) { return 0; } 241 #endif 242 virtual NSCachedURLResponse* willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const = 0; 243 #endif 244 #if USE(CFNETWORK) 245 virtual bool shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length) = 0; 246 #endif 247 shouldUsePluginDocument(const String &)248 virtual bool shouldUsePluginDocument(const String& /*mimeType*/) const { return false; } 249 }; 250 251 } // namespace WebCore 252 253 #endif // FrameLoaderClient_h 254