FrameLoaderClientManx.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*
  2. * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
  3. * Copyright (C) 2012 Sony Computer Entertainment Inc.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  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. *
  14. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  15. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  18. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  21. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  22. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef FrameLoaderClientManx_h
  27. #define FrameLoaderClientManx_h
  28. #include "FrameLoader.h"
  29. #include "FrameLoaderClient.h"
  30. #include "KURL.h"
  31. #include "ResourceError.h"
  32. #include "ResourceResponse.h"
  33. #include <JavaScriptCore/JSObjectRef.h>
  34. class FrameLoaderClientListener;
  35. class WebViewJavaScriptObject;
  36. namespace WebKit {
  37. class WebViewPrivate;
  38. }
  39. namespace WebCore {
  40. class AuthenticationChallenge;
  41. class DocumentLoader;
  42. class Element;
  43. class FormState;
  44. class NavigationAction;
  45. class ResourceLoader;
  46. struct LoadErrorResetToken;
  47. class FrameLoaderClientManx : public FrameLoaderClient {
  48. public:
  49. FrameLoaderClientManx(WebKit::WebViewPrivate*);
  50. ~FrameLoaderClientManx();
  51. void setFrame(WebCore::Frame* frame) { m_frame = frame; }
  52. WebCore::Frame* frame() { return m_frame; }
  53. virtual void frameLoaderDestroyed();
  54. virtual bool hasWebView() const;
  55. virtual void makeRepresentation(DocumentLoader*);
  56. virtual void forceLayout();
  57. virtual void forceLayoutForNonHTML();
  58. virtual void setCopiesOnScroll();
  59. virtual void detachedFromParent2();
  60. virtual void detachedFromParent3();
  61. virtual void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&);
  62. virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
  63. virtual bool shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier);
  64. virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&);
  65. virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&);
  66. virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&);
  67. virtual void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived);
  68. virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier);
  69. virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&);
  70. virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length);
  71. bool httpAuthenticationChallenge(const String& siteUrl, const String& message, String& user, String& password, bool& updatedSavedFlag);
  72. virtual void dispatchDidHandleOnloadEvents();
  73. virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
  74. virtual void dispatchDidCancelClientRedirect();
  75. virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate);
  76. virtual void dispatchDidNavigateWithinPage();
  77. virtual void dispatchDidChangeLocationWithinPage();
  78. virtual void dispatchDidPushStateWithinPage();
  79. virtual void dispatchDidReplaceStateWithinPage();
  80. virtual void dispatchDidPopStateWithinPage();
  81. virtual void dispatchWillClose();
  82. virtual void dispatchDidReceiveIcon();
  83. virtual void dispatchDidStartProvisionalLoad();
  84. virtual void dispatchDidReceiveTitle(const StringWithDirection& title);
  85. virtual void dispatchDidCommitLoad();
  86. virtual void dispatchDidFailProvisionalLoad(const ResourceError&);
  87. virtual void dispatchDidFailLoad(const ResourceError&);
  88. virtual void dispatchDidFinishDocumentLoad();
  89. virtual void dispatchDidFinishLoad();
  90. virtual void dispatchDidFirstLayout();
  91. virtual void dispatchDidFirstVisuallyNonEmptyLayout();
  92. virtual void dispatchDidChangeIcons(WebCore::IconType);
  93. virtual Frame* dispatchCreatePage(const WebCore::NavigationAction&);
  94. virtual void dispatchShow();
  95. virtual void dispatchDecidePolicyForResponse(WebCore::FramePolicyFunction, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&);
  96. virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName);
  97. virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>);
  98. virtual void cancelPolicyCheck();
  99. virtual void dispatchUnableToImplementPolicy(const ResourceError&);
  100. virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>);
  101. virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>);
  102. virtual void revertToProvisionalState(DocumentLoader*);
  103. virtual void setMainDocumentError(DocumentLoader*, const ResourceError&);
  104. // Maybe these should go into a ProgressTrackerClient some day
  105. virtual void postProgressStartedNotification();
  106. virtual void postProgressEstimateChangedNotification();
  107. virtual void postProgressFinishedNotification();
  108. virtual ObjectContentType objectContentType(const KURL&, const String& mimeType, bool shouldPreferPlugInsForImages);
  109. virtual void setMainFrameDocumentReady(bool);
  110. virtual void startDownload(const ResourceRequest&, const String& suggestedName);
  111. virtual void willChangeTitle(DocumentLoader*);
  112. virtual void didChangeTitle(DocumentLoader*);
  113. virtual void committedLoad(DocumentLoader*, const char*, int);
  114. virtual void finishedLoading(DocumentLoader*);
  115. virtual void updateGlobalHistory();
  116. virtual void updateGlobalHistoryRedirectLinks();
  117. virtual void updateGlobalHistoryItemForPage();
  118. virtual bool shouldGoToHistoryItem(HistoryItem*) const;
  119. virtual bool shouldStopLoadingForHistoryItem(HistoryItem*) const;
  120. // This frame has displayed inactive content (such as an image) from an
  121. // insecure source. Inactive content cannot spread to other frames.
  122. virtual void didDisplayInsecureContent();
  123. virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL&);
  124. virtual void didDetectXSS(const KURL&, bool didBlockEntirePage);
  125. virtual ResourceError cancelledError(const ResourceRequest&);
  126. virtual ResourceError blockedError(const ResourceRequest&);
  127. virtual ResourceError cannotShowURLError(const ResourceRequest&);
  128. virtual ResourceError interruptedForPolicyChangeError(const ResourceRequest&);
  129. virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&);
  130. virtual ResourceError fileDoesNotExistError(const ResourceResponse&);
  131. virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&);
  132. virtual bool shouldFallBack(const ResourceError&);
  133. virtual bool canHandleRequest(const ResourceRequest&) const;
  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. virtual void frameLoadCompleted();
  139. virtual void saveViewStateToItem(HistoryItem*);
  140. virtual void restoreViewState();
  141. virtual void provisionalLoadStarted();
  142. virtual void didFinishLoad();
  143. virtual void prepareForDataSourceReplacement();
  144. virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&);
  145. virtual void setTitle(const StringWithDirection& title, const KURL&);
  146. virtual String userAgent(const KURL&);
  147. virtual void savePlatformDataToCachedFrame(CachedFrame*);
  148. virtual void transitionToCommittedFromCachedFrame(CachedFrame*);
  149. virtual void transitionToCommittedForNewPage();
  150. virtual void didSaveToPageCache();
  151. virtual void didRestoreFromPageCache();
  152. virtual void dispatchDidBecomeFrameset(bool);
  153. virtual bool canCachePage() const;
  154. virtual void convertMainResourceLoadToDownload(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
  155. virtual PassRefPtr<Frame> createFrame(const KURL&, const String& name, HTMLFrameOwnerElement*,
  156. const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
  157. virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually);
  158. virtual void recreatePlugin(WebCore::Widget*) { }
  159. virtual void redirectDataToPlugin(Widget* pluginWidget);
  160. virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues);
  161. virtual String overrideMediaType() const;
  162. virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*);
  163. virtual void documentElementAvailable();
  164. virtual void didPerformFirstNavigation() const; // "Navigation" here means a transition from one page to another that ends up in the back/forward list.
  165. virtual void registerForIconNotification(bool listen = true);
  166. virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext();
  167. // for js callbak
  168. static JSValueRef jsFunctionCallbackWithDelegate(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
  169. static JSValueRef jsFunctionCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
  170. JSValueRef jsDelegate(JSContextRef ctx, JSObjectRef function, size_t argumentCount, const JSValueRef arguments[]);
  171. void setJSObject(WebViewJavaScriptObject* parentObj, JSObjectRef parentObjRef = 0);
  172. #if ENABLE(WEB_INTENTS)
  173. virtual void dispatchIntent(PassRefPtr<IntentRequest>) = 0;
  174. #endif
  175. void setFrameLoaderClientListener(FrameLoaderClientListener* listener) { m_listener = listener; }
  176. private:
  177. WebKit::WebViewPrivate* m_webView;
  178. WebCore::Frame* m_frame;
  179. bool m_hasRepresentation;
  180. int m_securityStatus;
  181. FrameLoaderClientListener* m_listener;
  182. void* m_cert;
  183. };
  184. }
  185. #endif // FrameLoaderClientManx_H