summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/core/loader/FrameLoaderClient.h
blob: 4e0afcaf4c7332e4595acc2514f830989064bd66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*
 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
 * Copyright (C) 2012 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 *     its contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef FrameLoaderClient_h
#define FrameLoaderClient_h

#include "core/CoreExport.h"
#include "core/dom/Document.h"
#include "core/dom/IconURL.h"
#include "core/fetch/ResourceLoaderOptions.h"
#include "core/frame/FrameClient.h"
#include "core/html/LinkResource.h"
#include "core/loader/FrameLoaderTypes.h"
#include "core/loader/NavigationPolicy.h"
#include "platform/heap/Handle.h"
#include "platform/network/ResourceLoadPriority.h"
#include "platform/weborigin/Referrer.h"
#include "public/platform/WebMediaPlayer.h"
#include "wtf/Forward.h"
#include "wtf/Vector.h"
#include <v8.h>

namespace blink {

class Document;
class DocumentLoader;
class FetchRequest;
class HTMLFormElement;
class HTMLFrameElementBase;
class HTMLFrameOwnerElement;
class HTMLMediaElement;
class HTMLPlugInElement;
class HistoryItem;
class KURL;
class LocalFrame;
class ResourceError;
class ResourceRequest;
class ResourceResponse;
class SecurityOrigin;
class SharedWorkerRepositoryClient;
class SubstituteData;
class WebApplicationCacheHost;
class WebApplicationCacheHostClient;
class WebCookieJar;
class WebMediaPlayerClient;
class WebMediaSession;
class WebRTCPeerConnectionHandler;
class WebServiceWorkerProvider;
class WebSocketHandle;
class Widget;

class CORE_EXPORT FrameLoaderClient : public FrameClient {
public:
    ~FrameLoaderClient() override {}

    virtual bool hasWebView() const = 0; // mainly for assertions

    virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse) = 0;
    virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&) = 0;
    virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) = 0;
    virtual void dispatchDidLoadResourceFromMemoryCache(const ResourceRequest&, const ResourceResponse&) = 0;

    virtual void dispatchDidHandleOnloadEvents() = 0;
    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0;
    virtual void dispatchDidNavigateWithinPage(HistoryItem*, HistoryCommitType) { }
    virtual void dispatchWillClose() = 0;
    virtual void dispatchDidStartProvisionalLoad(double triggeringEventTime) = 0;
    virtual void dispatchDidReceiveTitle(const String&) = 0;
    virtual void dispatchDidChangeIcons(IconType) = 0;
    virtual void dispatchDidCommitLoad(HistoryItem*, HistoryCommitType) = 0;
    virtual void dispatchDidFailProvisionalLoad(const ResourceError&, HistoryCommitType) = 0;
    virtual void dispatchDidFailLoad(const ResourceError&, HistoryCommitType) = 0;
    virtual void dispatchDidFinishDocumentLoad() = 0;
    virtual void dispatchDidFinishLoad() = 0;
    virtual void dispatchDidChangeThemeColor() = 0;

    virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, DocumentLoader*, NavigationType, NavigationPolicy, bool shouldReplaceCurrentEntry, bool isClientRedirect) = 0;
    virtual bool hasPendingNavigation() = 0;

    virtual void dispatchWillSendSubmitEvent(HTMLFormElement*) = 0;
    virtual void dispatchWillSubmitForm(HTMLFormElement*) = 0;

    virtual void didStartLoading(LoadStartType) = 0;
    virtual void progressEstimateChanged(double progressEstimate) = 0;
    virtual void didStopLoading() = 0;

    virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& suggestedName, bool replacesCurrentHistoryItem) = 0;

    virtual bool navigateBackForward(int offset) const = 0;

    // Another page has accessed the initial empty document of this frame.
    // It is no longer safe to display a provisional URL, since a URL spoof
    // is now possible.
    virtual void didAccessInitialDocument() { }

    // This frame has displayed inactive content (such as an image) from an
    // insecure source.  Inactive content cannot spread to other frames.
    virtual void didDisplayInsecureContent() = 0;

    // The indicated security origin has run active content (such as a
    // script) from an insecure source.  Note that the insecure content can
    // spread to other frames in the same origin.
    virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) = 0;
    virtual void didDetectXSS(const KURL&, bool didBlockEntirePage) = 0;
    virtual void didDispatchPingLoader(const KURL&) = 0;

    // The given main resource displayed content with certificate errors
    // with the given URL and security info.
    virtual void didDisplayContentWithCertificateErrors(const KURL&, const CString& securityInfo, const WebURL& mainResourceUrl, const CString& mainResourceSecurityInfo) = 0;
    // The given main resource ran content with certificate errors with
    // the given URL and security info.
    virtual void didRunContentWithCertificateErrors(const KURL&, const CString& securityInfo, const WebURL& mainResourceUrl, const CString& mainResourceSecurityInfo) = 0;

    // Will be called when |PerformanceTiming| events are updated
    virtual void didChangePerformanceTiming() { }

    // Transmits the change in the set of watched CSS selectors property
    // that match any element on the frame.
    virtual void selectorMatchChanged(const Vector<String>& addedSelectors, const Vector<String>& removedSelectors) = 0;

    virtual PassRefPtrWillBeRawPtr<DocumentLoader> createDocumentLoader(LocalFrame*, const ResourceRequest&, const SubstituteData&) = 0;

    virtual String userAgent() = 0;

    virtual String doNotTrackValue() = 0;

    virtual void transitionToCommittedForNewPage() = 0;

    virtual PassRefPtrWillBeRawPtr<LocalFrame> createFrame(const FrameLoadRequest&, const AtomicString& name, HTMLFrameOwnerElement*) = 0;
    // Whether or not plugin creation should fail if the HTMLPlugInElement isn't in the DOM after plugin initialization.
    enum DetachedPluginPolicy {
        FailOnDetachedPlugin,
        AllowDetachedPlugin,
    };
    virtual bool canCreatePluginWithoutRenderer(const String& mimeType) const = 0;
    virtual PassRefPtrWillBeRawPtr<Widget> createPlugin(HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually, DetachedPluginPolicy) = 0;

    virtual PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, WebMediaPlayer::LoadType, const WebURL&, WebMediaPlayerClient*) = 0;

    virtual PassOwnPtr<WebMediaSession> createWebMediaSession() = 0;

    virtual ObjectContentType getObjectContentType(const KURL&, const String& mimeType, bool shouldPreferPlugInsForImages) = 0;

    virtual void didCreateNewDocument() = 0;
    virtual void dispatchDidClearWindowObjectInMainWorld() = 0;
    virtual void documentElementAvailable() = 0;
    virtual void runScriptsAtDocumentElementAvailable() = 0;
    virtual void runScriptsAtDocumentReady(bool documentIsEmpty) = 0;

    virtual v8::Local<v8::Value> createTestInterface(const AtomicString& name) = 0;

    virtual void didCreateScriptContext(v8::Local<v8::Context>, int extensionGroup, int worldId) = 0;
    virtual void willReleaseScriptContext(v8::Local<v8::Context>, int worldId) = 0;
    virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) = 0;

    virtual void didChangeScrollOffset() { }
    virtual void didUpdateCurrentHistoryItem() { }
    virtual void didRemoveAllPendingStylesheet() { }

    virtual bool allowScript(bool enabledPerSettings) { return enabledPerSettings; }
    virtual bool allowScriptFromSource(bool enabledPerSettings, const KURL&) { return enabledPerSettings; }
    virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; }
    virtual bool allowImage(bool enabledPerSettings, const KURL&) { return enabledPerSettings; }
    virtual bool allowMedia(const KURL&) { return true; }
    virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, const KURL&) { return enabledPerSettings; }
    virtual bool allowRunningInsecureContent(bool enabledPerSettings, SecurityOrigin*, const KURL&) { return enabledPerSettings; }

    // This callback notifies the client that the frame was about to run
    // JavaScript but did not because allowScript returned false. We
    // have a separate callback here because there are a number of places
    // that need to know if JavaScript is enabled but are not necessarily
    // preparing to execute script.
    virtual void didNotAllowScript() { }
    // This callback is similar, but for plugins.
    virtual void didNotAllowPlugins() { }

    // This callback notifies the client that the frame created a Keygen element.
    virtual void didUseKeygen() { }

    virtual WebCookieJar* cookieJar() const = 0;

    virtual void didChangeName(const String& name, const String& uniqueName) { }

    virtual void didEnforceStrictMixedContentChecking() {}

    virtual void didUpdateToUniqueOrigin() {}

    virtual void didChangeSandboxFlags(Frame* childFrame, SandboxFlags) { }

    virtual void didChangeFrameOwnerProperties(HTMLFrameElementBase*) { }

    virtual void dispatchWillOpenWebSocket(WebSocketHandle*) { }

    virtual void dispatchWillStartUsingPeerConnectionHandler(WebRTCPeerConnectionHandler*) { }

    virtual void didRequestAutocomplete(HTMLFormElement*) = 0;

    virtual bool allowWebGL(bool enabledPerSettings) { return enabledPerSettings; }
    // Informs the embedder that a WebGL canvas inside this frame received a lost context
    // notification with the given GL_ARB_robustness guilt/innocence code (see Extensions3D.h).
    virtual void didLoseWebGLContext(int) { }

    // If an HTML document is being loaded, informs the embedder that the document will have its <body> attached soon.
    virtual void dispatchWillInsertBody() { }

    virtual void dispatchDidChangeResourcePriority(unsigned long identifier, ResourceLoadPriority, int intraPriorityValue) { }

    virtual PassOwnPtr<WebServiceWorkerProvider> createServiceWorkerProvider() = 0;

    virtual bool isControlledByServiceWorker(DocumentLoader&) = 0;

    virtual int64_t serviceWorkerID(DocumentLoader&) = 0;

    virtual SharedWorkerRepositoryClient* sharedWorkerRepositoryClient() { return 0; }

    virtual PassOwnPtr<WebApplicationCacheHost> createApplicationCacheHost(WebApplicationCacheHostClient*) = 0;

    virtual void dispatchDidChangeManifest() { }

    virtual unsigned backForwardLength() { return 0; }

    virtual bool isFrameLoaderClientImpl() const { return false; }

    // Called when elements preventing the sudden termination of the frame
    // become present or stop being present. |type| is the type of element
    // (BeforeUnload handler, Unload handler).
    enum SuddenTerminationDisablerType {
        BeforeUnloadHandler,
        UnloadHandler,
    };
    virtual void suddenTerminationDisablerChanged(bool present, SuddenTerminationDisablerType) { }

    virtual PassOwnPtrWillBeRawPtr<LinkResource> createServiceWorkerLinkResource(HTMLLinkElement*) { return nullptr; }
};

} // namespace blink

#endif // FrameLoaderClient_h