1 /* 2 * Copyright (C) 2010 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 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef WebFrameProxy_h 27 #define WebFrameProxy_h 28 29 #include "APIObject.h" 30 #include "ImmutableArray.h" 31 #include "GenericCallback.h" 32 #include "WebFrameListenerProxy.h" 33 #include <WebCore/FrameLoaderTypes.h> 34 #include <wtf/Forward.h> 35 #include <wtf/PassRefPtr.h> 36 #include <wtf/text/WTFString.h> 37 38 namespace CoreIPC { 39 class ArgumentDecoder; 40 class Connection; 41 class MessageID; 42 } 43 44 namespace WebKit { 45 46 class ImmutableArray; 47 class PlatformCertificateInfo; 48 class WebCertificateInfo; 49 class WebFormSubmissionListenerProxy; 50 class WebFramePolicyListenerProxy; 51 class WebPageProxy; 52 53 typedef GenericCallback<WKDataRef> DataCallback; 54 55 class WebFrameProxy : public APIObject { 56 public: 57 static const Type APIType = TypeFrame; 58 create(WebPageProxy * page,uint64_t frameID)59 static PassRefPtr<WebFrameProxy> create(WebPageProxy* page, uint64_t frameID) 60 { 61 return adoptRef(new WebFrameProxy(page, frameID)); 62 } 63 64 virtual ~WebFrameProxy(); 65 66 enum LoadState { 67 LoadStateProvisional, 68 LoadStateCommitted, 69 LoadStateFinished 70 }; 71 frameID()72 uint64_t frameID() const { return m_frameID; } page()73 WebPageProxy* page() { return m_page; } 74 parentFrame()75 WebFrameProxy* parentFrame() { return m_parentFrame; } nextSibling()76 WebFrameProxy* nextSibling() { return m_nextSibling; } previousSibling()77 WebFrameProxy* previousSibling() { return m_previousSibling; } firstChild()78 WebFrameProxy* firstChild() { return m_firstChild; } lastChild()79 WebFrameProxy* lastChild() { return m_lastChild; } 80 81 void disconnect(); 82 83 bool isMainFrame() const; 84 setIsFrameSet(bool value)85 void setIsFrameSet(bool value) { m_isFrameSet = value; } isFrameSet()86 bool isFrameSet() const { return m_isFrameSet; } 87 loadState()88 LoadState loadState() const { return m_loadState; } 89 90 void stopLoading() const; 91 url()92 const String& url() const { return m_url; } provisionalURL()93 const String& provisionalURL() const { return m_provisionalURL; } 94 setUnreachableURL(const String & unreachableURL)95 void setUnreachableURL(const String& unreachableURL) { m_unreachableURL = unreachableURL; } unreachableURL()96 const String& unreachableURL() const { return m_unreachableURL; } 97 mimeType()98 const String& mimeType() const { return m_MIMEType; } 99 title()100 const String& title() const { return m_title; } 101 certificateInfo()102 WebCertificateInfo* certificateInfo() const { return m_certificateInfo.get(); } 103 104 bool canProvideSource() const; 105 bool canShowMIMEType(const String& mimeType) const; 106 107 bool isDisplayingStandaloneImageDocument() const; 108 bool isDisplayingMarkupDocument() const; 109 110 void getWebArchive(PassRefPtr<DataCallback>); 111 void getMainResourceData(PassRefPtr<DataCallback>); 112 void getResourceData(WebURL*, PassRefPtr<DataCallback>); 113 114 void didStartProvisionalLoad(const String& url); 115 void didReceiveServerRedirectForProvisionalLoad(const String& url); 116 void didFailProvisionalLoad(); 117 void didCommitLoad(const String& contentType, const PlatformCertificateInfo&); 118 void didFinishLoad(); 119 void didFailLoad(); 120 void didSameDocumentNavigation(const String&); // eg. anchor navigation, session state change. 121 void didChangeTitle(const String&); 122 123 // Frame tree operations. 124 void appendChild(WebFrameProxy*); 125 void removeChild(WebFrameProxy*); 126 void didRemoveFromHierarchy(); 127 PassRefPtr<ImmutableArray> childFrames(); 128 bool isDescendantOf(const WebFrameProxy* ancestor) const; 129 void dumpFrameTreeToSTDOUT(unsigned indent = 0); 130 131 // Policy operations. 132 void receivedPolicyDecision(WebCore::PolicyAction, uint64_t listenerID); 133 WebFramePolicyListenerProxy* setUpPolicyListenerProxy(uint64_t listenerID); 134 WebFormSubmissionListenerProxy* setUpFormSubmissionListenerProxy(uint64_t listenerID); 135 136 private: 137 WebFrameProxy(WebPageProxy* page, uint64_t frameID); 138 type()139 virtual Type type() const { return APIType; } 140 141 WebPageProxy* m_page; 142 WebFrameProxy* m_parentFrame; 143 WebFrameProxy* m_nextSibling; 144 WebFrameProxy* m_previousSibling; 145 WebFrameProxy* m_firstChild; 146 WebFrameProxy* m_lastChild; 147 148 LoadState m_loadState; 149 String m_url; 150 String m_provisionalURL; 151 String m_unreachableURL; 152 String m_MIMEType; 153 String m_title; 154 bool m_isFrameSet; 155 RefPtr<WebCertificateInfo> m_certificateInfo; 156 RefPtr<WebFrameListenerProxy> m_activeListener; 157 uint64_t m_frameID; 158 }; 159 160 } // namespace WebKit 161 162 #endif // WebFrameProxy_h 163