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 #ifndef WebFrameLoaderClient_h 30 #define WebFrameLoaderClient_h 31 32 #pragma warning(push, 0) 33 #include <WebCore/FrameLoaderClient.h> 34 #pragma warning(pop) 35 36 namespace WebCore { 37 class PluginManualLoader; 38 class PluginView; 39 } 40 41 template <typename T> class COMPtr; 42 class WebFrame; 43 44 class WebFrameLoaderClient : public WebCore::FrameLoaderClient { 45 public: 46 virtual bool hasWebView() const; 47 48 virtual void forceLayout(); 49 50 virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&); 51 52 virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse); 53 virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier); 54 virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); 55 virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); 56 virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&); 57 virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived); 58 virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier); 59 virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&); 60 virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::ScriptString&); 61 virtual bool shouldCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&, const unsigned char* data, unsigned long long length); 62 63 virtual void dispatchDidHandleOnloadEvents(); 64 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); 65 virtual void dispatchDidCancelClientRedirect(); 66 virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate); 67 virtual void dispatchDidChangeLocationWithinPage(); 68 virtual void dispatchWillClose(); 69 virtual void dispatchDidReceiveIcon(); 70 virtual void dispatchDidStartProvisionalLoad(); 71 virtual void dispatchDidReceiveTitle(const WebCore::String&); 72 virtual void dispatchDidCommitLoad(); 73 virtual void dispatchDidFinishDocumentLoad(); 74 virtual void dispatchDidFinishLoad(); 75 virtual void dispatchDidFirstLayout(); 76 virtual void dispatchDidFirstVisuallyNonEmptyLayout(); 77 78 virtual WebCore::Frame* dispatchCreatePage(); 79 virtual void dispatchShow(); 80 81 virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); 82 virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); 83 84 virtual void postProgressStartedNotification(); 85 virtual void postProgressEstimateChangedNotification(); 86 virtual void postProgressFinishedNotification(); 87 88 virtual void committedLoad(WebCore::DocumentLoader*, const char*, int); 89 virtual void finishedLoading(WebCore::DocumentLoader*); 90 91 virtual void updateGlobalHistory(); 92 virtual void updateGlobalHistoryRedirectLinks(); 93 virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const; 94 95 virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); 96 virtual void setTitle(const WebCore::String& title, const WebCore::KURL&); 97 98 virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*); 99 virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*); 100 virtual void transitionToCommittedForNewPage(); 101 102 virtual bool canCachePage() const; 103 104 virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WebCore::String& name, WebCore::HTMLFrameOwnerElement* ownerElement, 105 const WebCore::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); 106 virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<WebCore::String>&, const Vector<WebCore::String>&, const WebCore::String&, bool loadManually); 107 virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget); 108 109 virtual bool shouldUsePluginDocument(const WebCore::String& mimeType) const; 110 111 virtual void dispatchDidFailToStartPlugin(const WebCore::PluginView*) const; 112 113 protected: 114 WebFrameLoaderClient(WebFrame*); 115 ~WebFrameLoaderClient(); 116 117 private: 118 PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL&, const WebCore::String& name, WebCore::HTMLFrameOwnerElement*, const WebCore::String& referrer); 119 void receivedData(const char*, int, const WebCore::String&); 120 WebHistory* webHistory() const; 121 122 WebFrame* m_webFrame; 123 124 // Points to the manual loader that data should be redirected to. 125 WebCore::PluginManualLoader* m_manualLoader; 126 127 bool m_hasSentResponseToPlugin; 128 }; 129 130 #endif // WebFrameLoaderClient_h 131