• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006, 2007, 2008, 2011 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 #import <WebCore/FrameLoaderClient.h>
30 #import <WebCore/Timer.h>
31 #import <wtf/Forward.h>
32 #import <wtf/HashMap.h>
33 #import <wtf/RetainPtr.h>
34 
35 @class WebDownload;
36 @class WebFrame;
37 @class WebFramePolicyListener;
38 @class WebHistoryItem;
39 @class WebResource;
40 
41 namespace WebCore {
42     class AuthenticationChallenge;
43     class CachedFrame;
44     class HistoryItem;
45     class ProtectionSpace;
46     class ResourceLoader;
47     class ResourceRequest;
48 }
49 
50 typedef HashMap<RefPtr<WebCore::ResourceLoader>, RetainPtr<WebResource> > ResourceMap;
51 
52 class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
53 public:
54     WebFrameLoaderClient(WebFrame*);
55 
webFrame()56     WebFrame* webFrame() const { return m_webFrame.get(); }
57 
58     virtual void frameLoaderDestroyed();
59     void receivedPolicyDecison(WebCore::PolicyAction);
60 
61 private:
62     virtual bool hasWebView() const; // mainly for assertions
63 
64     virtual void makeRepresentation(WebCore::DocumentLoader*);
65     virtual bool hasHTMLView() const;
66     virtual void forceLayout();
67     virtual void forceLayoutForNonHTML();
68 
69     virtual void setCopiesOnScroll();
70 
71     virtual void detachedFromParent2();
72     virtual void detachedFromParent3();
73 
74     virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
75 
76     virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
77 
78     virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
79     virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier);
80     virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&);
81     virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&);
82 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
83     virtual bool canAuthenticateAgainstProtectionSpace(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ProtectionSpace&);
84 #endif
85     virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&);
86     virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int dataLength);
87     virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier);
88     virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&);
89 
90     virtual NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const;
91 
92     virtual void dispatchDidHandleOnloadEvents();
93     virtual void dispatchDidReceiveServerRedirectForProvisionalLoad();
94     virtual void dispatchDidCancelClientRedirect();
95     virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate);
96     virtual void dispatchDidChangeLocationWithinPage();
97     virtual void dispatchDidPushStateWithinPage();
98     virtual void dispatchDidReplaceStateWithinPage();
99     virtual void dispatchDidPopStateWithinPage();
100 
101     virtual void dispatchWillClose();
102     virtual void dispatchDidReceiveIcon();
103     virtual void dispatchDidStartProvisionalLoad();
104     virtual void dispatchDidReceiveTitle(const WebCore::StringWithDirection&);
105     virtual void dispatchDidChangeIcons();
106     virtual void dispatchDidCommitLoad();
107     virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
108     virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
109     virtual void dispatchDidFinishDocumentLoad();
110     virtual void dispatchDidFinishLoad();
111     virtual void dispatchDidFirstLayout();
112     virtual void dispatchDidFirstVisuallyNonEmptyLayout();
113 
114     virtual WebCore::Frame* dispatchCreatePage(const WebCore::NavigationAction&);
115     virtual void dispatchShow();
116 
117     virtual void dispatchDecidePolicyForResponse(WebCore::FramePolicyFunction,
118         const WebCore::ResourceResponse&, const WebCore::ResourceRequest&);
119     virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction,
120         const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>, const WTF::String& frameName);
121     virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction,
122         const WebCore::NavigationAction&, const WebCore::ResourceRequest&, PassRefPtr<WebCore::FormState>);
123     virtual void cancelPolicyCheck();
124 
125     virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&);
126 
dispatchWillSendSubmitEvent(WebCore::HTMLFormElement *)127     virtual void dispatchWillSendSubmitEvent(WebCore::HTMLFormElement*) { }
128     virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>);
129 
130     virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*);
131     virtual void revertToProvisionalState(WebCore::DocumentLoader*);
132     virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&);
133     virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length);
134 
135     virtual void willChangeEstimatedProgress();
136     virtual void didChangeEstimatedProgress();
137     virtual void postProgressStartedNotification();
138     virtual void postProgressEstimateChangedNotification();
139     virtual void postProgressFinishedNotification();
140 
141     virtual void setMainFrameDocumentReady(bool);
142 
143     virtual void startDownload(const WebCore::ResourceRequest&);
144 
145     virtual void willChangeTitle(WebCore::DocumentLoader*);
146     virtual void didChangeTitle(WebCore::DocumentLoader*);
147 
148     virtual void committedLoad(WebCore::DocumentLoader*, const char*, int);
149     virtual void finishedLoading(WebCore::DocumentLoader*);
150     virtual void updateGlobalHistory();
151     virtual void updateGlobalHistoryRedirectLinks();
152 
153     virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const;
154     virtual bool shouldStopLoadingForHistoryItem(WebCore::HistoryItem*) const;
155     virtual void dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const;
156     virtual void dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const;
157     virtual void dispatchDidChangeBackForwardIndex() const;
158     virtual void updateGlobalHistoryItemForPage();
159 
160     virtual void didDisplayInsecureContent();
161     virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL&);
162 
163     virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&);
164     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&);
165     virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&);
166     virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&);
167 
168     virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&);
169     virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&);
170     virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&);
171 
172     virtual bool shouldFallBack(const WebCore::ResourceError&);
173 
174     virtual WTF::String userAgent(const WebCore::KURL&);
175 
176     virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*);
177     virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*);
178     virtual void transitionToCommittedForNewPage();
179 
180     virtual void didSaveToPageCache();
181     virtual void didRestoreFromPageCache();
182 
183     virtual void dispatchDidBecomeFrameset(bool);
184 
185     virtual bool canHandleRequest(const WebCore::ResourceRequest&) const;
186     virtual bool canShowMIMEType(const WTF::String& MIMEType) const;
187     virtual bool canShowMIMETypeAsHTML(const WTF::String& MIMEType) const;
188     virtual bool representationExistsForURLScheme(const WTF::String& URLScheme) const;
189     virtual WTF::String generatedMIMETypeForURLScheme(const WTF::String& URLScheme) const;
190 
191     virtual void frameLoadCompleted();
192     virtual void saveViewStateToItem(WebCore::HistoryItem*);
193     virtual void restoreViewState();
194     virtual void provisionalLoadStarted();
195     virtual void didFinishLoad();
196     virtual void prepareForDataSourceReplacement();
197     virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
198 
199     virtual void setTitle(const WebCore::StringWithDirection&, const WebCore::KURL&);
200 
201     virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WTF::String& name, WebCore::HTMLFrameOwnerElement*,
202                                         const WTF::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
203     virtual void didTransferChildFrameToNewDocument(WebCore::Page* oldPage);
204     virtual void transferLoadingResourceFromPage(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&, WebCore::Page* oldPage);
205     virtual PassRefPtr<WebCore::Widget> createPlugin(const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, const Vector<WTF::String>&,
206                                           const Vector<WTF::String>&, const WTF::String&, bool);
207     virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
208 
209     virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL,
210                                                     const Vector<WTF::String>& paramNames, const Vector<WTF::String>& paramValues);
211 
212 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
213     virtual PassRefPtr<WebCore::Widget> createMediaPlayerProxyPlugin(const WebCore::IntSize&, WebCore::HTMLMediaElement*, const WebCore::KURL&,
214                                         const Vector<WTF::String>&, const Vector<WTF::String>&, const WTF::String&);
215     virtual void hideMediaPlayerProxyPlugin(WebCore::Widget*);
216     virtual void showMediaPlayerProxyPlugin(WebCore::Widget*);
217 #endif
218 
219     virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL&, const WTF::String& mimeType, bool shouldPreferPlugInsForImages);
220     virtual WTF::String overrideMediaType() const;
221 
222     virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*);
223     virtual void documentElementAvailable();
224     virtual void didPerformFirstNavigation() const;
225 
226     virtual void registerForIconNotification(bool listen);
227 
228 #if ENABLE(JAVA_BRIDGE)
229     virtual jobject javaApplet(NSView*);
230 #endif
231 
232 #if PLATFORM(MAC)
accessibilityRemoteObject()233     virtual RemoteAXObjectRef accessibilityRemoteObject() { return 0; }
234 #endif
235 
236     void setOriginalURLForDownload(WebDownload *, const WebCore::ResourceRequest&) const;
237 
238     RetainPtr<WebFramePolicyListener> setUpPolicyListener(WebCore::FramePolicyFunction);
239 
240     NSDictionary *actionDictionary(const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>) const;
241 
242     virtual bool canCachePage() const;
243 
244     virtual PassRefPtr<WebCore::FrameNetworkingContext> createNetworkingContext();
245 
246     virtual bool shouldPaintBrokenImage(const WebCore::KURL&) const;
247 
248     RetainPtr<WebFrame> m_webFrame;
249 
250     RetainPtr<WebFramePolicyListener> m_policyListener;
251     WebCore::FramePolicyFunction m_policyFunction;
252 };
253