~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/loader/FrameLoaderClient.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
 
3
 * Copyright (C) 2012 Google Inc. All rights reserved.
 
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
 *
 
9
 * 1.  Redistributions of source code must retain the above copyright
 
10
 *     notice, this list of conditions and the following disclaimer. 
 
11
 * 2.  Redistributions in binary form must reproduce the above copyright
 
12
 *     notice, this list of conditions and the following disclaimer in the
 
13
 *     documentation and/or other materials provided with the distribution. 
 
14
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 
15
 *     its contributors may be used to endorse or promote products derived
 
16
 *     from this software without specific prior written permission. 
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
21
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
28
 */
 
29
 
 
30
#ifndef FrameLoaderClient_h
 
31
#define FrameLoaderClient_h
 
32
 
 
33
#include "FrameLoaderTypes.h"
 
34
#include "IconURL.h"
 
35
#include "LayoutMilestones.h"
 
36
#include <wtf/Forward.h>
 
37
#include <wtf/Vector.h>
 
38
 
 
39
#if PLATFORM(MAC)
 
40
#ifdef __OBJC__ 
 
41
#import <Foundation/Foundation.h>
 
42
typedef id RemoteAXObjectRef;
 
43
#else
 
44
typedef void* RemoteAXObjectRef;
 
45
#endif
 
46
#endif
 
47
 
 
48
typedef class _jobject* jobject;
 
49
 
 
50
#if PLATFORM(MAC) && !defined(__OBJC__)
 
51
class NSCachedURLResponse;
 
52
class NSView;
 
53
#endif
 
54
 
 
55
#if USE(V8)
 
56
namespace v8 {
 
57
class Context;
 
58
template<class T> class Handle;
 
59
}
 
60
#endif
 
61
 
 
62
namespace WebCore {
 
63
 
 
64
    class AuthenticationChallenge;
 
65
    class CachedFrame;
 
66
    class CachedResourceRequest;
 
67
    class Color;
 
68
    class DOMWindowExtension;
 
69
    class DOMWrapperWorld;
 
70
    class DocumentLoader;
 
71
    class Element;
 
72
    class FormState;
 
73
    class Frame;
 
74
    class FrameLoader;
 
75
    class FrameNetworkingContext;
 
76
    class HistoryItem;
 
77
    class HTMLAppletElement;
 
78
    class HTMLFormElement;
 
79
    class HTMLFrameOwnerElement;
 
80
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 
81
    class HTMLMediaElement;
 
82
#endif
 
83
    class HTMLPlugInElement;
 
84
    class IntSize;
 
85
#if ENABLE(WEB_INTENTS)
 
86
    class IntentRequest;
 
87
#endif
 
88
    class KURL;
 
89
    class MessageEvent;
 
90
    class NavigationAction;
 
91
    class Page;
 
92
    class ProtectionSpace;
 
93
    class PluginView;
 
94
    class PolicyChecker;
 
95
    class ResourceError;
 
96
    class ResourceHandle;
 
97
    class ResourceLoader;
 
98
    class ResourceRequest;
 
99
    class ResourceResponse;
 
100
#if ENABLE(MEDIA_STREAM)
 
101
    class RTCPeerConnectionHandler;
 
102
#endif
 
103
    class SecurityOrigin;
 
104
    class SharedBuffer;
 
105
    class SocketStreamHandle;
 
106
    class StringWithDirection;
 
107
    class SubstituteData;
 
108
    class Widget;
 
109
 
 
110
    typedef void (PolicyChecker::*FramePolicyFunction)(PolicyAction);
 
111
 
 
112
    class FrameLoaderClient {
 
113
    public:
 
114
        // An inline function cannot be the first non-abstract virtual function declared
 
115
        // in the class as it results in the vtable being generated as a weak symbol.
 
116
        // This hurts performance (in Mac OS X at least, when loadig frameworks), so we
 
117
        // don't want to do it in WebKit.
 
118
        virtual bool hasHTMLView() const;
 
119
 
 
120
        virtual ~FrameLoaderClient() { }
 
121
 
 
122
        virtual void frameLoaderDestroyed() = 0;
 
123
 
 
124
        virtual bool hasWebView() const = 0; // mainly for assertions
 
125
 
 
126
        virtual void makeRepresentation(DocumentLoader*) = 0;
 
127
        virtual void forceLayout() = 0;
 
128
        virtual void forceLayoutForNonHTML() = 0;
 
129
 
 
130
        virtual void setCopiesOnScroll() = 0;
 
131
 
 
132
        virtual void detachedFromParent2() = 0;
 
133
        virtual void detachedFromParent3() = 0;
 
134
 
 
135
        virtual void assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&) = 0;
 
136
 
 
137
        virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse) = 0;
 
138
        virtual bool shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier) = 0;
 
139
        virtual void dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) = 0;
 
140
        virtual void dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) = 0;        
 
141
#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
 
142
        virtual bool canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long identifier, const ProtectionSpace&) = 0;
 
143
#endif
 
144
        virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&) = 0;
 
145
        virtual void dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int dataLength) = 0;
 
146
        virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) = 0;
 
147
        virtual void dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&) = 0;
 
148
        virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) = 0;
 
149
 
 
150
        virtual void dispatchDidHandleOnloadEvents() = 0;
 
151
        virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0;
 
152
        virtual void dispatchDidCancelClientRedirect() = 0;
 
153
        virtual void dispatchWillPerformClientRedirect(const KURL&, double interval, double fireDate) = 0;
 
154
        virtual void dispatchDidNavigateWithinPage() { }
 
155
        virtual void dispatchDidChangeLocationWithinPage() = 0;
 
156
        virtual void dispatchDidPushStateWithinPage() = 0;
 
157
        virtual void dispatchDidReplaceStateWithinPage() = 0;
 
158
        virtual void dispatchDidPopStateWithinPage() = 0;
 
159
        virtual void dispatchWillClose() = 0;
 
160
        virtual void dispatchDidReceiveIcon() = 0;
 
161
        virtual void dispatchDidStartProvisionalLoad() = 0;
 
162
        virtual void dispatchDidReceiveTitle(const StringWithDirection&) = 0;
 
163
        virtual void dispatchDidChangeIcons(IconType) = 0;
 
164
        virtual void dispatchDidCommitLoad() = 0;
 
165
        virtual void dispatchDidFailProvisionalLoad(const ResourceError&) = 0;
 
166
        virtual void dispatchDidFailLoad(const ResourceError&) = 0;
 
167
        virtual void dispatchDidFinishDocumentLoad() = 0;
 
168
        virtual void dispatchDidFinishLoad() = 0;
 
169
 
 
170
        virtual void dispatchDidLayout() { }
 
171
        virtual void dispatchDidLayout(LayoutMilestones) { }
 
172
 
 
173
        virtual Frame* dispatchCreatePage(const NavigationAction&) = 0;
 
174
        virtual void dispatchShow() = 0;
 
175
 
 
176
        virtual void dispatchDecidePolicyForResponse(FramePolicyFunction, const ResourceResponse&, const ResourceRequest&) = 0;
 
177
        virtual void dispatchDecidePolicyForNewWindowAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String& frameName) = 0;
 
178
        virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>) = 0;
 
179
        virtual void cancelPolicyCheck() = 0;
 
180
 
 
181
        virtual void dispatchUnableToImplementPolicy(const ResourceError&) = 0;
 
182
 
 
183
        virtual void dispatchWillRequestResource(CachedResourceRequest*) { }
 
184
 
 
185
        virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) = 0;
 
186
        virtual void dispatchWillSubmitForm(FramePolicyFunction, PassRefPtr<FormState>) = 0;
 
187
 
 
188
        virtual void revertToProvisionalState(DocumentLoader*) = 0;
 
189
        virtual void setMainDocumentError(DocumentLoader*, const ResourceError&) = 0;
 
190
 
 
191
        // Maybe these should go into a ProgressTrackerClient some day
 
192
        virtual void willChangeEstimatedProgress() { }
 
193
        virtual void didChangeEstimatedProgress() { }
 
194
        virtual void postProgressStartedNotification() = 0;
 
195
        virtual void postProgressEstimateChangedNotification() = 0;
 
196
        virtual void postProgressFinishedNotification() = 0;
 
197
        
 
198
        virtual void setMainFrameDocumentReady(bool) = 0;
 
199
 
 
200
        virtual void startDownload(const ResourceRequest&, const String& suggestedName = String()) = 0;
 
201
 
 
202
        virtual void willChangeTitle(DocumentLoader*) = 0;
 
203
        virtual void didChangeTitle(DocumentLoader*) = 0;
 
204
 
 
205
        virtual void committedLoad(DocumentLoader*, const char*, int) = 0;
 
206
        virtual void finishedLoading(DocumentLoader*) = 0;
 
207
        
 
208
        virtual void updateGlobalHistory() = 0;
 
209
        virtual void updateGlobalHistoryRedirectLinks() = 0;
 
210
 
 
211
        virtual bool shouldGoToHistoryItem(HistoryItem*) const = 0;
 
212
        virtual bool shouldStopLoadingForHistoryItem(HistoryItem*) const = 0;
 
213
        virtual void updateGlobalHistoryItemForPage() { }
 
214
 
 
215
        // This frame has displayed inactive content (such as an image) from an
 
216
        // insecure source.  Inactive content cannot spread to other frames.
 
217
        virtual void didDisplayInsecureContent() = 0;
 
218
 
 
219
        // The indicated security origin has run active content (such as a
 
220
        // script) from an insecure source.  Note that the insecure content can
 
221
        // spread to other frames in the same origin.
 
222
        virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) = 0;
 
223
        virtual void didDetectXSS(const KURL&, bool didBlockEntirePage) = 0;
 
224
 
 
225
        virtual ResourceError cancelledError(const ResourceRequest&) = 0;
 
226
        virtual ResourceError blockedError(const ResourceRequest&) = 0;
 
227
        virtual ResourceError cannotShowURLError(const ResourceRequest&) = 0;
 
228
        virtual ResourceError interruptedForPolicyChangeError(const ResourceRequest&) = 0;
 
229
 
 
230
        virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) = 0;
 
231
        virtual ResourceError fileDoesNotExistError(const ResourceResponse&) = 0;
 
232
        virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&) = 0;
 
233
 
 
234
        virtual bool shouldFallBack(const ResourceError&) = 0;
 
235
 
 
236
        virtual bool canHandleRequest(const ResourceRequest&) const = 0;
 
237
        virtual bool canShowMIMEType(const String& MIMEType) const = 0;
 
238
        virtual bool canShowMIMETypeAsHTML(const String& MIMEType) const = 0;
 
239
        virtual bool representationExistsForURLScheme(const String& URLScheme) const = 0;
 
240
        virtual String generatedMIMETypeForURLScheme(const String& URLScheme) const = 0;
 
241
 
 
242
        virtual void frameLoadCompleted() = 0;
 
243
        virtual void saveViewStateToItem(HistoryItem*) = 0;
 
244
        virtual void restoreViewState() = 0;
 
245
        virtual void provisionalLoadStarted() = 0;
 
246
        virtual void didFinishLoad() = 0;
 
247
        virtual void prepareForDataSourceReplacement() = 0;
 
248
 
 
249
        virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) = 0;
 
250
        virtual void setTitle(const StringWithDirection&, const KURL&) = 0;
 
251
 
 
252
        virtual String userAgent(const KURL&) = 0;
 
253
        
 
254
        virtual void savePlatformDataToCachedFrame(CachedFrame*) = 0;
 
255
        virtual void transitionToCommittedFromCachedFrame(CachedFrame*) = 0;
 
256
        virtual void transitionToCommittedForNewPage() = 0;
 
257
 
 
258
        virtual void didSaveToPageCache() = 0;
 
259
        virtual void didRestoreFromPageCache() = 0;
 
260
 
 
261
        virtual void dispatchDidBecomeFrameset(bool) = 0; // Can change due to navigation or DOM modification.
 
262
 
 
263
        virtual bool canCachePage() const = 0;
 
264
        virtual void download(ResourceHandle*, const ResourceRequest&, const ResourceResponse&) = 0;
 
265
 
 
266
        virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) = 0;
 
267
        virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0;
 
268
        virtual void recreatePlugin(Widget*) = 0;
 
269
        virtual void redirectDataToPlugin(Widget* pluginWidget) = 0;
 
270
 
 
271
        virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) = 0;
 
272
 
 
273
        virtual void dispatchDidFailToStartPlugin(const PluginView*) const { }
 
274
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
 
275
        virtual PassRefPtr<Widget> createMediaPlayerProxyPlugin(const IntSize&, HTMLMediaElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&) = 0;
 
276
        virtual void hideMediaPlayerProxyPlugin(Widget*) = 0;
 
277
        virtual void showMediaPlayerProxyPlugin(Widget*) = 0;
 
278
#endif
 
279
 
 
280
        virtual ObjectContentType objectContentType(const KURL&, const String& mimeType, bool shouldPreferPlugInsForImages) = 0;
 
281
        virtual String overrideMediaType() const = 0;
 
282
 
 
283
        virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) = 0;
 
284
        virtual void documentElementAvailable() = 0;
 
285
        virtual void didPerformFirstNavigation() const = 0; // "Navigation" here means a transition from one page to another that ends up in the back/forward list.
 
286
 
 
287
        virtual void didExhaustMemoryAvailableForScript() { };
 
288
 
 
289
#if USE(V8)
 
290
        virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) = 0;
 
291
        virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) = 0;
 
292
        virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) = 0;
 
293
#endif
 
294
 
 
295
        virtual void registerForIconNotification(bool listen = true) = 0;
 
296
        
 
297
#if PLATFORM(MAC)
 
298
        // Allow an accessibility object to retrieve a Frame parent if there's no PlatformWidget.
 
299
        virtual RemoteAXObjectRef accessibilityRemoteObject() = 0;
 
300
        virtual NSCachedURLResponse* willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const = 0;
 
301
#endif
 
302
#if PLATFORM(WIN) && USE(CFNETWORK)
 
303
        // FIXME: Windows should use willCacheResponse - <https://bugs.webkit.org/show_bug.cgi?id=57257>.
 
304
        virtual bool shouldCacheResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&, const unsigned char* data, unsigned long long length) = 0;
 
305
#endif
 
306
 
 
307
        virtual bool shouldUsePluginDocument(const String& /*mimeType*/) const { return false; }
 
308
        virtual bool shouldLoadMediaElementURL(const KURL&) const { return true; }
 
309
 
 
310
        virtual void didChangeScrollOffset() { }
 
311
 
 
312
        virtual bool allowScript(bool enabledPerSettings) { return enabledPerSettings; }
 
313
        virtual bool allowScriptFromSource(bool enabledPerSettings, const KURL&) { return enabledPerSettings; }
 
314
        virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; }
 
315
        virtual bool allowImage(bool enabledPerSettings, const KURL&) { return enabledPerSettings; }
 
316
        virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, SecurityOrigin*, const KURL&) { return enabledPerSettings; }
 
317
        virtual bool allowRunningInsecureContent(bool enabledPerSettings, SecurityOrigin*, const KURL&) { return enabledPerSettings; }
 
318
 
 
319
        // This callback notifies the client that the frame was about to run
 
320
        // JavaScript but did not because allowScript returned false. We
 
321
        // have a separate callback here because there are a number of places
 
322
        // that need to know if JavaScript is enabled but are not necessarily
 
323
        // preparing to execute script.
 
324
        virtual void didNotAllowScript() { }
 
325
        // This callback is similar, but for plugins.
 
326
        virtual void didNotAllowPlugins() { }
 
327
 
 
328
        // Clients that generally disallow universal access can make exceptions for particular URLs.
 
329
        virtual bool shouldForceUniversalAccessFromLocalURL(const KURL&) { return false; }
 
330
 
 
331
        virtual PassRefPtr<FrameNetworkingContext> createNetworkingContext() = 0;
 
332
 
 
333
        virtual bool shouldPaintBrokenImage(const KURL&) const { return true; }
 
334
 
 
335
        // Returns true if the embedder intercepted the postMessage call
 
336
        virtual bool willCheckAndDispatchMessageEvent(SecurityOrigin* /*target*/, MessageEvent*) const { return false; }
 
337
 
 
338
#if ENABLE(WEB_INTENTS)
 
339
        virtual void dispatchIntent(PassRefPtr<IntentRequest>) = 0;
 
340
#endif
 
341
#if ENABLE(WEB_INTENTS_TAG)
 
342
        virtual void registerIntentService(const String&, const String&, const KURL&, const String&, const String&) { }
 
343
#endif
 
344
 
 
345
        virtual void dispatchWillOpenSocketStream(SocketStreamHandle*) { }
 
346
 
 
347
        virtual void dispatchGlobalObjectAvailable(DOMWrapperWorld*) { }
 
348
        virtual void dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(DOMWindowExtension*) { }
 
349
        virtual void dispatchDidReconnectDOMWindowExtensionToGlobalObject(DOMWindowExtension*) { }
 
350
        virtual void dispatchWillDestroyGlobalObjectForDOMWindowExtension(DOMWindowExtension*) { }
 
351
 
 
352
#if ENABLE(MEDIA_STREAM)
 
353
        virtual void dispatchWillStartUsingPeerConnectionHandler(RTCPeerConnectionHandler*) { }
 
354
#endif
 
355
 
 
356
#if ENABLE(REQUEST_AUTOCOMPLETE)
 
357
        virtual void didRequestAutocomplete(PassRefPtr<FormState>) = 0;
 
358
#endif
 
359
 
 
360
#if ENABLE(WEBGL)
 
361
        virtual bool allowWebGL(bool enabledPerSettings) { return enabledPerSettings; }
 
362
        // Informs the embedder that a WebGL canvas inside this frame received a lost context
 
363
        // notification with the given GL_ARB_robustness guilt/innocence code (see Extensions3D.h).
 
364
        virtual void didLoseWebGLContext(int) { }
 
365
#endif
 
366
    };
 
367
 
 
368
} // namespace WebCore
 
369
 
 
370
#endif // FrameLoaderClient_h