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