1 /* 2 * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com> 3 * Copyright (C) 2011 Apple Inc. All rights reserved. 4 * 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef FrameLoaderClientWx_H 30 #define FrameLoaderClientWx_H 31 32 #include "FrameLoaderClient.h" 33 #include "FrameLoader.h" 34 #include "KURL.h" 35 #include "PluginView.h" 36 #include "ResourceResponse.h" 37 #include "HTMLPlugInElement.h" 38 #include <wtf/Forward.h> 39 40 class wxWebFrame; 41 class wxWebView; 42 43 namespace WebCore { 44 45 class AuthenticationChallenge; 46 class DocumentLoader; 47 class Element; 48 class FormState; 49 class NavigationAction; 50 class ResourceLoader; 51 52 struct LoadErrorResetToken; 53 54 class FrameLoaderClientWx : public FrameLoaderClient { 55 public: 56 FrameLoaderClientWx(); 57 ~FrameLoaderClientWx(); 58 void setFrame(wxWebFrame *frame); 59 void setWebView(wxWebView *webview); 60 61 virtual bool hasWebView() const; // mainly for assertions 62 63 virtual bool hasBackForwardList() const; 64 virtual void resetBackForwardList(); 65 66 virtual bool provisionalItemIsTarget() const; 67 68 virtual void makeRepresentation(DocumentLoader*); 69 virtual void forceLayout(); 70 virtual void forceLayoutForNonHTML(); 71 72 virtual void updateHistoryForCommit(); 73 74 virtual void updateHistoryForBackForwardNavigation(); 75 virtual void updateHistoryForReload(); 76 virtual void updateHistoryForStandardLoad(); 77 virtual void updateHistoryForInternalLoad(); 78 79 virtual void updateHistoryAfterClientRedirect(); 80 81 virtual void setCopiesOnScroll(); 82 83 virtual LoadErrorResetToken* tokenForLoadErrorReset(); 84 virtual void resetAfterLoadError(LoadErrorResetToken*); 85 virtual void doNotResetAfterLoadError(LoadErrorResetToken*); 86 87 virtual void willCloseDocument(); 88 89 virtual void detachedFromParent2(); 90 virtual void detachedFromParent3(); 91 92 virtual void frameLoaderDestroyed(); 93 virtual bool canHandleRequest(const ResourceRequest&) const; 94 95 virtual void dispatchDidHandleOnloadEvents(); 96 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); 97 virtual void dispatchDidCancelClientRedirect(); 98 virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate); 99 virtual void dispatchDidChangeLocationWithinPage(); 100 virtual void dispatchDidPushStateWithinPage(); 101 virtual void dispatchDidReplaceStateWithinPage(); 102 virtual void dispatchDidPopStateWithinPage(); 103 virtual void dispatchWillClose(); 104 virtual void dispatchDidReceiveIcon(); 105 virtual void dispatchDidStartProvisionalLoad(); 106 virtual void dispatchDidReceiveTitle(const StringWithDirection& title); 107 virtual void dispatchDidCommitLoad(); 108 virtual void dispatchDidFinishDocumentLoad(); 109 virtual void dispatchDidFinishLoad(); 110 virtual void dispatchDidFirstLayout(); 111 virtual void dispatchDidFirstVisuallyNonEmptyLayout(); 112 virtual void dispatchDidChangeIcons(); 113 114 virtual void dispatchShow(); 115 virtual void cancelPolicyCheck(); 116 dispatchWillSendSubmitEvent(HTMLFormElement *)117 virtual void dispatchWillSendSubmitEvent(HTMLFormElement*) { } 118 virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>); 119 120 virtual void dispatchDidLoadMainResource(DocumentLoader*); 121 virtual void revertToProvisionalState(DocumentLoader*); 122 123 virtual void postProgressStartedNotification(); 124 virtual void postProgressEstimateChangedNotification(); 125 virtual void postProgressFinishedNotification(); 126 127 virtual void progressStarted(); 128 virtual void progressCompleted(); 129 virtual void setMainFrameDocumentReady(bool); 130 virtual void willChangeTitle(DocumentLoader*); 131 virtual void didChangeTitle(DocumentLoader*); 132 virtual void finishedLoading(DocumentLoader*); 133 134 virtual bool canShowMIMEType(const String& MIMEType) const; 135 virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const; 136 virtual bool representationExistsForURLScheme(const String& URLScheme) const; 137 virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const; 138 139 virtual void frameLoadCompleted(); 140 virtual void saveViewStateToItem(HistoryItem*); 141 virtual void restoreViewState(); 142 virtual void restoreScrollPositionAndViewState(); 143 virtual void provisionalLoadStarted(); 144 virtual bool shouldTreatURLAsSameAsCurrent(const KURL&) const; 145 virtual void addHistoryItemForFragmentScroll(); 146 virtual void didFinishLoad(); 147 virtual void prepareForDataSourceReplacement(); 148 virtual void setTitle(const StringWithDirection&, const KURL&); 149 150 virtual String userAgent(const KURL&); 151 152 virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*); 153 virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*); 154 virtual void transitionToCommittedForNewPage(); 155 156 virtual void didSaveToPageCache(); 157 virtual void didRestoreFromPageCache(); 158 159 virtual void dispatchDidBecomeFrameset(bool); 160 161 virtual void updateGlobalHistory(); 162 virtual void updateGlobalHistoryRedirectLinks(); 163 virtual bool shouldGoToHistoryItem(HistoryItem*) const; 164 virtual bool shouldStopLoadingForHistoryItem(HistoryItem*) const; 165 virtual void dispatchDidAddBackForwardItem(HistoryItem*) const; 166 virtual void dispatchDidRemoveBackForwardItem(HistoryItem*) const; 167 virtual void dispatchDidChangeBackForwardIndex() const; 168 virtual void saveScrollPositionAndViewStateToItem(HistoryItem*); 169 virtual bool canCachePage() const; 170 171 virtual void didDisplayInsecureContent(); 172 virtual void didRunInsecureContent(SecurityOrigin*, const KURL&); 173 174 virtual void setMainDocumentError(DocumentLoader*, const ResourceError&); 175 virtual void committedLoad(DocumentLoader*, const char*, int); 176 virtual ResourceError cancelledError(const ResourceRequest&); 177 virtual ResourceError blockedError(const ResourceRequest&); 178 virtual ResourceError cannotShowURLError(const ResourceRequest&); 179 virtual ResourceError interruptForPolicyChangeError(const ResourceRequest&); 180 virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&); 181 virtual ResourceError fileDoesNotExistError(const ResourceResponse&); 182 virtual bool shouldFallBack(const ResourceError&); 183 virtual WTF::PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&); 184 virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&); 185 186 virtual void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&); 187 188 virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&); 189 virtual bool shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier); 190 virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&); 191 virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&); 192 virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse&); 193 virtual void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long, int); 194 virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long); 195 virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long, const ResourceError&); 196 virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int); 197 198 virtual void dispatchDidFailProvisionalLoad(const ResourceError&); 199 virtual void dispatchDidFailLoad(const ResourceError&); 200 virtual Frame* dispatchCreatePage(const WebCore::NavigationAction&); 201 virtual void dispatchDecidePolicyForResponse(FramePolicyFunction function, const ResourceResponse&, const ResourceRequest&); 202 virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String&); 203 virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>); 204 virtual void dispatchUnableToImplementPolicy(const ResourceError&); 205 206 virtual void startDownload(const ResourceRequest&); 207 208 // FIXME: This should probably not be here, but it's needed for the tests currently 209 virtual void partClearedInBegin(); 210 211 virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, 212 const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight); 213 virtual void didTransferChildFrameToNewDocument(Page*); 214 virtual void transferLoadingResourceFromPage(unsigned long, DocumentLoader*, const ResourceRequest&, Page*); 215 virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) ; 216 virtual void redirectDataToPlugin(Widget* pluginWidget); 217 virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&); 218 219 virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues); 220 221 virtual ObjectContentType objectContentType(const KURL&, const String& mimeType, bool shouldPreferPlugInsForImages); 222 virtual String overrideMediaType() const; 223 224 virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*); 225 virtual void documentElementAvailable(); 226 227 virtual void didPerformFirstNavigation() const; 228 229 virtual void registerForIconNotification(bool listen = true); 230 231 virtual bool shouldUsePluginDocument(const String &mimeType) const; 232 233 virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext(); 234 235 private: 236 wxWebFrame *m_webFrame; 237 Frame* m_frame; 238 wxWebView *m_webView; 239 PluginView* m_pluginView; 240 bool m_hasSentResponseToPlugin; 241 ResourceResponse m_response; 242 bool m_firstData; 243 }; 244 245 } 246 247 #endif 248