FrameLoaderClientQt.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*
  2. * Copyright (C) 2006 Zack Rusin <zack@kde.org>
  3. * Copyright (C) 2006, 2011 Apple Inc. All rights reserved.
  4. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  5. * Copyright (C) 2008 Collabora Ltd. All rights reserved.
  6. *
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  19. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  22. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  26. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef FrameLoaderClientQt_h
  31. #define FrameLoaderClientQt_h
  32. #include "FormState.h"
  33. #include "Frame.h"
  34. #include "FrameLoader.h"
  35. #include "FrameLoaderClient.h"
  36. #include "HTMLFormElement.h"
  37. #include "KURL.h"
  38. #include "ResourceError.h"
  39. #include "ResourceResponse.h"
  40. #include "WebCore/plugins/PluginView.h"
  41. #include <QUrl>
  42. #include <qobject.h>
  43. #include <wtf/Forward.h>
  44. #include <wtf/OwnPtr.h>
  45. #include <wtf/RefCounted.h>
  46. QT_BEGIN_NAMESPACE
  47. class QNetworkReply;
  48. QT_END_NAMESPACE
  49. class QWebFrame;
  50. class QWebFrameAdapter;
  51. namespace WebCore {
  52. class AuthenticationChallenge;
  53. class DocumentLoader;
  54. class Element;
  55. class FormState;
  56. class NavigationAction;
  57. class FrameNetworkingContext;
  58. class ResourceLoader;
  59. struct LoadErrorResetToken;
  60. class FrameLoaderClientQt : public QObject, public FrameLoaderClient {
  61. Q_OBJECT
  62. friend class ::QWebFrameAdapter;
  63. void callPolicyFunction(FramePolicyFunction, PolicyAction);
  64. bool callErrorPageExtension(const ResourceError&);
  65. Q_SIGNALS:
  66. void loadProgress(int d);
  67. void titleChanged(const QString& title);
  68. void unsupportedContent(QNetworkReply*);
  69. public:
  70. FrameLoaderClientQt();
  71. ~FrameLoaderClientQt();
  72. virtual void frameLoaderDestroyed();
  73. void setFrame(QWebFrameAdapter*, Frame*);
  74. virtual bool hasWebView() const; // mainly for assertions
  75. virtual void makeRepresentation(DocumentLoader*) { }
  76. virtual void forceLayout();
  77. virtual void forceLayoutForNonHTML();
  78. virtual void setCopiesOnScroll();
  79. virtual void detachedFromParent2();
  80. virtual void detachedFromParent3();
  81. virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
  82. virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long, WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
  83. virtual bool shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier);
  84. virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&);
  85. virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&);
  86. virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long, const WebCore::ResourceResponse&);
  87. virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long, int);
  88. virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long);
  89. virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long, const WebCore::ResourceError&);
  90. virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int);
  91. virtual void dispatchDidHandleOnloadEvents();
  92. virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
  93. virtual void dispatchDidCancelClientRedirect();
  94. virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate);
  95. virtual void dispatchDidNavigateWithinPage() OVERRIDE;
  96. virtual void dispatchDidChangeLocationWithinPage();
  97. virtual void dispatchDidPushStateWithinPage();
  98. virtual void dispatchDidReplaceStateWithinPage();
  99. virtual void dispatchDidPopStateWithinPage();
  100. virtual void dispatchWillClose();
  101. virtual void dispatchDidReceiveIcon();
  102. virtual void dispatchDidStartProvisionalLoad();
  103. virtual void dispatchDidReceiveTitle(const StringWithDirection&);
  104. virtual void dispatchDidChangeIcons(WebCore::IconType);
  105. virtual void dispatchDidCommitLoad();
  106. virtual void dispatchDidFailProvisionalLoad(const ResourceError&);
  107. virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
  108. virtual void dispatchDidFinishDocumentLoad();
  109. virtual void dispatchDidFinishLoad();
  110. virtual void dispatchDidLayout(WebCore::LayoutMilestones);
  111. virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&);
  112. virtual void dispatchShow();
  113. virtual void dispatchDecidePolicyForResponse(FramePolicyFunction, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&);
  114. virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>, const WTF::String&);
  115. virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<FormState>);
  116. virtual void cancelPolicyCheck();
  117. virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&);
  118. virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) { }
  119. virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>);
  120. virtual void revertToProvisionalState(DocumentLoader*) { }
  121. virtual void setMainDocumentError(DocumentLoader*, const ResourceError&);
  122. virtual void postProgressStartedNotification();
  123. virtual void postProgressEstimateChangedNotification();
  124. virtual void postProgressFinishedNotification();
  125. virtual void setMainFrameDocumentReady(bool);
  126. virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String());
  127. virtual void willChangeTitle(DocumentLoader*);
  128. virtual void didChangeTitle(DocumentLoader*);
  129. virtual void committedLoad(WebCore::DocumentLoader*, const char*, int);
  130. virtual void finishedLoading(DocumentLoader*);
  131. virtual void updateGlobalHistory();
  132. virtual void updateGlobalHistoryRedirectLinks();
  133. virtual bool shouldGoToHistoryItem(HistoryItem*) const;
  134. virtual bool shouldStopLoadingForHistoryItem(HistoryItem*) const;
  135. virtual void didDisplayInsecureContent();
  136. virtual void didRunInsecureContent(SecurityOrigin*, const KURL&);
  137. virtual void didDetectXSS(const KURL&, bool didBlockEntirePage);
  138. virtual ResourceError cancelledError(const ResourceRequest&);
  139. virtual ResourceError blockedError(const ResourceRequest&);
  140. virtual ResourceError cannotShowURLError(const ResourceRequest&);
  141. virtual ResourceError interruptedForPolicyChangeError(const ResourceRequest&);
  142. virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&);
  143. virtual ResourceError fileDoesNotExistError(const ResourceResponse&);
  144. virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&);
  145. virtual bool shouldFallBack(const ResourceError&);
  146. virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
  147. virtual bool canShowMIMEType(const String& MIMEType) const;
  148. virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const;
  149. virtual bool representationExistsForURLScheme(const String& URLScheme) const;
  150. virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const;
  151. virtual void frameLoadCompleted();
  152. virtual void saveViewStateToItem(WebCore::HistoryItem*);
  153. virtual void restoreViewState();
  154. virtual void provisionalLoadStarted();
  155. virtual void didFinishLoad();
  156. virtual void prepareForDataSourceReplacement();
  157. virtual WTF::PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
  158. virtual void setTitle(const StringWithDirection&, const KURL&);
  159. virtual String userAgent(const WebCore::KURL&);
  160. virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*);
  161. virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*);
  162. virtual void transitionToCommittedForNewPage();
  163. virtual void didSaveToPageCache();
  164. virtual void didRestoreFromPageCache();
  165. virtual void dispatchDidBecomeFrameset(bool);
  166. virtual bool canCachePage() const;
  167. virtual void convertMainResourceLoadToDownload(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
  168. virtual PassRefPtr<Frame> createFrame(const KURL&, const String& name, HTMLFrameOwnerElement*, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
  169. virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool);
  170. virtual void recreatePlugin(Widget*) { }
  171. virtual void redirectDataToPlugin(Widget* pluginWidget);
  172. virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues);
  173. virtual ObjectContentType objectContentType(const KURL&, const String& mimeTypeIn, bool shouldPreferPlugInsForImages);
  174. virtual String overrideMediaType() const;
  175. virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
  176. virtual void documentElementAvailable();
  177. virtual void didPerformFirstNavigation() const;
  178. virtual void registerForIconNotification(bool);
  179. QString chooseFile(const QString& oldFile);
  180. virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext();
  181. const KURL& lastRequestedUrl() const { return m_lastRequestedUrl; }
  182. QWebFrameAdapter* webFrame() const;
  183. static bool dumpFrameLoaderCallbacks;
  184. static bool dumpProgressFinishedCallback;
  185. static bool dumpUserGestureInFrameLoaderCallbacks;
  186. static bool dumpResourceLoadCallbacks;
  187. static bool dumpResourceResponseMIMETypes;
  188. static bool dumpWillCacheResponseCallbacks;
  189. static QString dumpResourceLoadCallbacksPath;
  190. static bool sendRequestReturnsNullOnRedirect;
  191. static bool sendRequestReturnsNull;
  192. static QStringList sendRequestClearHeaders;
  193. static bool policyDelegateEnabled;
  194. static bool policyDelegatePermissive;
  195. static bool deferMainResourceDataLoad;
  196. static bool dumpHistoryCallbacks;
  197. static QMap<QString, QString> URLsToRedirect;
  198. private Q_SLOTS:
  199. void onIconLoadedForPageURL(const QString&);
  200. private:
  201. void emitLoadStarted();
  202. void emitLoadFinished(bool ok);
  203. Frame *m_frame;
  204. QWebFrameAdapter *m_webFrame;
  205. ResourceResponse m_response;
  206. // Plugin view to redirect data to
  207. WebCore::PluginView* m_pluginView;
  208. bool m_hasSentResponseToPlugin;
  209. KURL m_lastRequestedUrl;
  210. bool m_isOriginatingLoad;
  211. };
  212. }
  213. #endif