|
1 /* |
|
2 * Copyright (C) 2006, 2007, 2008, 2009, 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 * |
|
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 #ifndef FrameLoaderClient_h |
|
30 #define FrameLoaderClient_h |
|
31 |
|
32 #include "FrameLoaderTypes.h" |
|
33 #include "ScrollTypes.h" |
|
34 #include <wtf/Forward.h> |
|
35 #include <wtf/Vector.h> |
|
36 |
|
37 typedef class _jobject* jobject; |
|
38 |
|
39 #if PLATFORM(MAC) && !defined(__OBJC__) |
|
40 class NSCachedURLResponse; |
|
41 class NSView; |
|
42 #endif |
|
43 |
|
44 namespace WebCore { |
|
45 |
|
46 class AuthenticationChallenge; |
|
47 class CachedFrame; |
|
48 class Color; |
|
49 class DOMWrapperWorld; |
|
50 class DocumentLoader; |
|
51 class Element; |
|
52 class FormState; |
|
53 class Frame; |
|
54 class FrameLoader; |
|
55 class HistoryItem; |
|
56 class HTMLAppletElement; |
|
57 class HTMLFormElement; |
|
58 class HTMLFrameOwnerElement; |
|
59 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) |
|
60 class HTMLMediaElement; |
|
61 #endif |
|
62 class HTMLPlugInElement; |
|
63 class IntSize; |
|
64 class KURL; |
|
65 class NavigationAction; |
|
66 class ProtectionSpace; |
|
67 class PluginView; |
|
68 class PolicyChecker; |
|
69 class ResourceError; |
|
70 class ResourceHandle; |
|
71 class ResourceLoader; |
|
72 class ResourceRequest; |
|
73 class ResourceResponse; |
|
74 class ScriptString; |
|
75 class SecurityOrigin; |
|
76 class SharedBuffer; |
|
77 class SubstituteData; |
|
78 class String; |
|
79 class Widget; |
|
80 |
|
81 typedef void (PolicyChecker::*FramePolicyFunction)(PolicyAction); |
|
82 |
|
83 class FrameLoaderClient { |
|
84 public: |
|
85 // An inline function cannot be the first non-abstract virtual function declared |
|
86 // in the class as it results in the vtable being generated as a weak symbol. |
|
87 // This hurts performance (in Mac OS X at least, when loadig frameworks), so we |
|
88 // don't want to do it in WebKit. |
|
89 virtual bool hasHTMLView() const; |
|
90 |
|
91 virtual ~FrameLoaderClient() { } |
|
92 |
|
93 virtual void frameLoaderDestroyed() = 0; |
|
94 |
|
95 virtual bool hasWebView() const = 0; // mainly for assertions |
|
96 |
|
97 virtual void makeRepresentation(DocumentLoader*) = 0; |
|
98 virtual void forceLayout() = 0; |
|
99 virtual void forceLayoutForNonHTML() = 0; |
|
100 |
|
101 virtual void setCopiesOnScroll() = 0; |
|
102 |
|
103 virtual void detachedFromParent2() = 0; |
|
104 virtual void detachedFromParent3() = 0; |
|
105 |
|
106 virtual void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&) = 0; |
|
107 |
|
108 virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse) = 0; |
|
109 virtual bool shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier) = 0; |
|
110 virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) = 0; |
|
111 virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) = 0; |
|
112 #if USE(PROTECTION_SPACE_AUTH_CALLBACK) |
|
113 virtual bool canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long identifier, const ProtectionSpace&) = 0; |
|
114 #endif |
|
115 virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&) = 0; |
|
116 virtual void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived) = 0; |
|
117 virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) = 0; |
|
118 virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&) = 0; |
|
119 virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) = 0; |
|
120 |
|
121 virtual void dispatchDidHandleOnloadEvents() = 0; |
|
122 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0; |
|
123 virtual void dispatchDidCancelClientRedirect() = 0; |
|
124 virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate) = 0; |
|
125 virtual void dispatchDidNavigateWithinPage() { } |
|
126 virtual void dispatchDidChangeLocationWithinPage() = 0; |
|
127 virtual void dispatchDidPushStateWithinPage() = 0; |
|
128 virtual void dispatchDidReplaceStateWithinPage() = 0; |
|
129 virtual void dispatchDidPopStateWithinPage() = 0; |
|
130 virtual void dispatchWillClose() = 0; |
|
131 virtual void dispatchDidReceiveIcon() = 0; |
|
132 virtual void dispatchDidStartProvisionalLoad() = 0; |
|
133 virtual void dispatchDidReceiveTitle(const String& title) = 0; |
|
134 virtual void dispatchDidChangeIcons() = 0; |
|
135 virtual void dispatchDidCommitLoad() = 0; |
|
136 virtual void dispatchDidFailProvisionalLoad(const ResourceError&) = 0; |
|
137 virtual void dispatchDidFailLoad(const ResourceError&) = 0; |
|
138 virtual void dispatchDidFinishDocumentLoad() = 0; |
|
139 virtual void dispatchDidFinishLoad() = 0; |
|
140 virtual void dispatchDidFirstLayout() = 0; |
|
141 virtual void dispatchDidFirstVisuallyNonEmptyLayout() = 0; |
|
142 |
|
143 virtual Frame* dispatchCreatePage() = 0; |
|
144 virtual void dispatchShow() = 0; |
|
145 |
|
146 virtual void dispatchDecidePolicyForMIMEType(FramePolicyFunction, const String& MIMEType, const ResourceRequest&) = 0; |
|
147 virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName) = 0; |
|
148 virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>) = 0; |
|
149 virtual void cancelPolicyCheck() = 0; |
|
150 |
|
151 virtual void dispatchUnableToImplementPolicy(const ResourceError&) = 0; |
|
152 |
|
153 virtual void dispatchWillSendSubmitEvent(HTMLFormElement*) = 0; |
|
154 virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>) = 0; |
|
155 |
|
156 virtual void dispatchDidLoadMainResource(DocumentLoader*) = 0; |
|
157 virtual void revertToProvisionalState(DocumentLoader*) = 0; |
|
158 virtual void setMainDocumentError(DocumentLoader*, const ResourceError&) = 0; |
|
159 |
|
160 // Maybe these should go into a ProgressTrackerClient some day |
|
161 virtual void willChangeEstimatedProgress() { } |
|
162 virtual void didChangeEstimatedProgress() { } |
|
163 virtual void postProgressStartedNotification() = 0; |
|
164 virtual void postProgressEstimateChangedNotification() = 0; |
|
165 virtual void postProgressFinishedNotification() = 0; |
|
166 |
|
167 virtual void setMainFrameDocumentReady(bool) = 0; |
|
168 |
|
169 virtual void startDownload(const ResourceRequest&) = 0; |
|
170 |
|
171 virtual void willChangeTitle(DocumentLoader*) = 0; |
|
172 virtual void didChangeTitle(DocumentLoader*) = 0; |
|
173 |
|
174 virtual void committedLoad(DocumentLoader*, const char*, int) = 0; |
|
175 virtual void finishedLoading(DocumentLoader*) = 0; |
|
176 |
|
177 virtual void updateGlobalHistory() = 0; |
|
178 virtual void updateGlobalHistoryRedirectLinks() = 0; |
|
179 |
|
180 virtual bool shouldGoToHistoryItem(HistoryItem*) const = 0; |
|
181 virtual void dispatchDidAddBackForwardItem(HistoryItem*) const = 0; |
|
182 virtual void dispatchDidRemoveBackForwardItem(HistoryItem*) const = 0; |
|
183 virtual void dispatchDidChangeBackForwardIndex() const = 0; |
|
184 |
|
185 // This frame has displayed inactive content (such as an image) from an |
|
186 // insecure source. Inactive content cannot spread to other frames. |
|
187 virtual void didDisplayInsecureContent() = 0; |
|
188 |
|
189 // The indicated security origin has run active content (such as a |
|
190 // script) from an insecure source. Note that the insecure content can |
|
191 // spread to other frames in the same origin. |
|
192 virtual void didRunInsecureContent(SecurityOrigin*) = 0; |
|
193 |
|
194 virtual ResourceError cancelledError(const ResourceRequest&) = 0; |
|
195 virtual ResourceError blockedError(const ResourceRequest&) = 0; |
|
196 virtual ResourceError cannotShowURLError(const ResourceRequest&) = 0; |
|
197 virtual ResourceError interruptForPolicyChangeError(const ResourceRequest&) = 0; |
|
198 |
|
199 virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) = 0; |
|
200 virtual ResourceError fileDoesNotExistError(const ResourceResponse&) = 0; |
|
201 virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&) = 0; |
|
202 |
|
203 virtual bool shouldFallBack(const ResourceError&) = 0; |
|
204 |
|
205 virtual bool canHandleRequest(const ResourceRequest&) const = 0; |
|
206 virtual bool canShowMIMEType(const String& MIMEType) const = 0; |
|
207 virtual bool representationExistsForURLScheme(const String& URLScheme) const = 0; |
|
208 virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const = 0; |
|
209 |
|
210 virtual void frameLoadCompleted() = 0; |
|
211 virtual void saveViewStateToItem(HistoryItem*) = 0; |
|
212 virtual void restoreViewState() = 0; |
|
213 virtual void provisionalLoadStarted() = 0; |
|
214 virtual void didFinishLoad() = 0; |
|
215 virtual void prepareForDataSourceReplacement() = 0; |
|
216 |
|
217 virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) = 0; |
|
218 virtual void setTitle(const String& title, const KURL&) = 0; |
|
219 |
|
220 virtual String userAgent(const KURL&) = 0; |
|
221 |
|
222 virtual void savePlatformDataToCachedFrame(CachedFrame*) = 0; |
|
223 virtual void transitionToCommittedFromCachedFrame(CachedFrame*) = 0; |
|
224 virtual void transitionToCommittedForNewPage() = 0; |
|
225 |
|
226 virtual bool canCachePage() const = 0; |
|
227 virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceRequest&, const ResourceResponse&) = 0; |
|
228 |
|
229 virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, |
|
230 const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) = 0; |
|
231 virtual void didTransferChildFrameToNewDocument() = 0; |
|
232 virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0; |
|
233 virtual void redirectDataToPlugin(Widget* pluginWidget) = 0; |
|
234 |
|
235 virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) = 0; |
|
236 |
|
237 virtual void dispatchDidFailToStartPlugin(const PluginView*) const { } |
|
238 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) |
|
239 virtual PassRefPtr<Widget> createMediaPlayerProxyPlugin(const IntSize&, HTMLMediaElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&) = 0; |
|
240 virtual void hideMediaPlayerProxyPlugin(Widget*) = 0; |
|
241 virtual void showMediaPlayerProxyPlugin(Widget*) = 0; |
|
242 #endif |
|
243 |
|
244 virtual ObjectContentType objectContentType(const KURL& url, const String& mimeType) = 0; |
|
245 virtual String overrideMediaType() const = 0; |
|
246 |
|
247 virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) = 0; |
|
248 virtual void documentElementAvailable() = 0; |
|
249 virtual void didPerformFirstNavigation() const = 0; // "Navigation" here means a transition from one page to another that ends up in the back/forward list. |
|
250 |
|
251 #if USE(V8) |
|
252 virtual void didCreateScriptContextForFrame() = 0; |
|
253 virtual void didDestroyScriptContextForFrame() = 0; |
|
254 virtual void didCreateIsolatedScriptContext() = 0; |
|
255 #endif |
|
256 |
|
257 virtual void registerForIconNotification(bool listen = true) = 0; |
|
258 |
|
259 #if PLATFORM(MAC) |
|
260 #if ENABLE(JAVA_BRIDGE) |
|
261 virtual jobject javaApplet(NSView*) { return 0; } |
|
262 #endif |
|
263 virtual NSCachedURLResponse* willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const = 0; |
|
264 #endif |
|
265 #if USE(CFNETWORK) |
|
266 virtual bool shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length) = 0; |
|
267 #endif |
|
268 |
|
269 virtual bool shouldUsePluginDocument(const String& /*mimeType*/) const { return false; } |
|
270 virtual bool shouldLoadMediaElementURL(const KURL&) const { return true; } |
|
271 |
|
272 virtual void didChangeScrollOffset() { } |
|
273 |
|
274 virtual bool allowJavaScript(bool enabledPerSettings) { return enabledPerSettings; } |
|
275 virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; } |
|
276 virtual bool allowImages(bool enabledPerSettings) { return enabledPerSettings; } |
|
277 |
|
278 // This callback notifies the client that the frame was about to run |
|
279 // JavaScript but did not because allowJavaScript returned false. We |
|
280 // have a separate callback here because there are a number of places |
|
281 // that need to know if JavaScript is enabled but are not necessarily |
|
282 // preparing to execute script. |
|
283 virtual void didNotAllowScript() { } |
|
284 // This callback is similar, but for plugins. |
|
285 virtual void didNotAllowPlugins() { } |
|
286 }; |
|
287 |
|
288 } // namespace WebCore |
|
289 |
|
290 #endif // FrameLoaderClient_h |