OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 13 matching lines...) Expand all Loading... |
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef FrameLoaderClient_h | 31 #ifndef FrameLoaderClient_h |
32 #define FrameLoaderClient_h | 32 #define FrameLoaderClient_h |
33 | 33 |
34 #include <v8.h> | 34 #include "core/frame/LocalFrameClient.h" |
35 #include <memory> | |
36 #include "core/CoreExport.h" | |
37 #include "core/dom/Document.h" | |
38 #include "core/dom/IconURL.h" | |
39 #include "core/frame/FrameClient.h" | |
40 #include "core/frame/FrameTypes.h" | |
41 #include "core/html/LinkResource.h" | |
42 #include "core/loader/FrameLoadRequest.h" | |
43 #include "core/loader/FrameLoaderTypes.h" | |
44 #include "core/loader/NavigationPolicy.h" | |
45 #include "platform/heap/Handle.h" | |
46 #include "platform/loader/fetch/ResourceLoaderOptions.h" | |
47 #include "platform/network/ContentSecurityPolicyParsers.h" | |
48 #include "platform/network/ResourceLoadPriority.h" | |
49 #include "platform/weborigin/Referrer.h" | |
50 #include "public/platform/WebContentSecurityPolicyStruct.h" | |
51 #include "public/platform/WebEffectiveConnectionType.h" | |
52 #include "public/platform/WebFeaturePolicy.h" | |
53 #include "public/platform/WebInsecureRequestPolicy.h" | |
54 #include "public/platform/WebLoadingBehaviorFlag.h" | |
55 #include "wtf/Forward.h" | |
56 #include "wtf/Vector.h" | |
57 | 35 |
58 namespace blink { | 36 namespace blink { |
59 | 37 |
60 class Document; | 38 // TODO(slangley): Remove this file once all users are including |
61 class DocumentLoader; | 39 // LocalFrameClient.h instead. |
62 struct FrameLoadRequest; | |
63 class HTMLFormElement; | |
64 class HTMLFrameElementBase; | |
65 class HTMLFrameOwnerElement; | |
66 class HTMLMediaElement; | |
67 class HTMLPlugInElement; | |
68 class HistoryItem; | |
69 class KURL; | |
70 class LocalFrame; | |
71 class ResourceError; | |
72 class ResourceRequest; | |
73 class ResourceResponse; | |
74 class SecurityOrigin; | |
75 class SharedWorkerRepositoryClient; | |
76 class SubstituteData; | |
77 class WebApplicationCacheHost; | |
78 class WebApplicationCacheHostClient; | |
79 class WebCookieJar; | |
80 class WebMediaPlayer; | |
81 class WebMediaPlayerClient; | |
82 class WebMediaPlayerSource; | |
83 class WebRemotePlaybackClient; | |
84 class WebRTCPeerConnectionHandler; | |
85 class WebServiceWorkerProvider; | |
86 class Widget; | |
87 | 40 |
88 class CORE_EXPORT FrameLoaderClient : public FrameClient { | 41 using FrameLoaderClient = LocalFrameClient; |
89 public: | |
90 ~FrameLoaderClient() override {} | |
91 | |
92 virtual bool hasWebView() const = 0; // mainly for assertions | |
93 | |
94 virtual void dispatchWillSendRequest(ResourceRequest&) = 0; | |
95 virtual void dispatchDidReceiveResponse(const ResourceResponse&) = 0; | |
96 virtual void dispatchDidLoadResourceFromMemoryCache( | |
97 const ResourceRequest&, | |
98 const ResourceResponse&) = 0; | |
99 | |
100 virtual void dispatchDidHandleOnloadEvents() = 0; | |
101 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0; | |
102 virtual void dispatchDidNavigateWithinPage(HistoryItem*, | |
103 HistoryCommitType, | |
104 bool contentInitiated) {} | |
105 virtual void dispatchWillCommitProvisionalLoad() = 0; | |
106 virtual void dispatchDidStartProvisionalLoad(DocumentLoader*) = 0; | |
107 virtual void dispatchDidReceiveTitle(const String&) = 0; | |
108 virtual void dispatchDidChangeIcons(IconType) = 0; | |
109 virtual void dispatchDidCommitLoad(HistoryItem*, HistoryCommitType) = 0; | |
110 virtual void dispatchDidFailProvisionalLoad(const ResourceError&, | |
111 HistoryCommitType) = 0; | |
112 virtual void dispatchDidFailLoad(const ResourceError&, HistoryCommitType) = 0; | |
113 virtual void dispatchDidFinishDocumentLoad() = 0; | |
114 virtual void dispatchDidFinishLoad() = 0; | |
115 virtual void dispatchDidChangeThemeColor() = 0; | |
116 | |
117 virtual NavigationPolicy decidePolicyForNavigation( | |
118 const ResourceRequest&, | |
119 DocumentLoader*, | |
120 NavigationType, | |
121 NavigationPolicy, | |
122 bool shouldReplaceCurrentEntry, | |
123 bool isClientRedirect, | |
124 HTMLFormElement*) = 0; | |
125 | |
126 virtual void dispatchWillSendSubmitEvent(HTMLFormElement*) = 0; | |
127 virtual void dispatchWillSubmitForm(HTMLFormElement*) = 0; | |
128 | |
129 virtual void didStartLoading(LoadStartType) = 0; | |
130 virtual void progressEstimateChanged(double progressEstimate) = 0; | |
131 virtual void didStopLoading() = 0; | |
132 | |
133 virtual void loadURLExternally(const ResourceRequest&, | |
134 NavigationPolicy, | |
135 const String& suggestedName, | |
136 bool replacesCurrentHistoryItem) = 0; | |
137 virtual void loadErrorPage(int reason) = 0; | |
138 | |
139 virtual bool navigateBackForward(int offset) const = 0; | |
140 | |
141 // Another page has accessed the initial empty document of this frame. It is | |
142 // no longer safe to display a provisional URL, since a URL spoof is now | |
143 // possible. | |
144 virtual void didAccessInitialDocument() {} | |
145 | |
146 // This frame has displayed inactive content (such as an image) from an | |
147 // insecure source. Inactive content cannot spread to other frames. | |
148 virtual void didDisplayInsecureContent() = 0; | |
149 | |
150 // The indicated security origin has run active content (such as a script) | |
151 // from an insecure source. Note that the insecure content can spread to | |
152 // other frames in the same origin. | |
153 virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) = 0; | |
154 virtual void didDetectXSS(const KURL&, bool didBlockEntirePage) = 0; | |
155 virtual void didDispatchPingLoader(const KURL&) = 0; | |
156 | |
157 // The frame displayed content with certificate errors with given URL. | |
158 virtual void didDisplayContentWithCertificateErrors(const KURL&) = 0; | |
159 // The frame ran content with certificate errors with the given URL. | |
160 virtual void didRunContentWithCertificateErrors(const KURL&) = 0; | |
161 | |
162 // Will be called when |PerformanceTiming| events are updated | |
163 virtual void didChangePerformanceTiming() {} | |
164 | |
165 // Will be called when a particular loading code path has been used. This | |
166 // propogates renderer loading behavior to the browser process for histograms. | |
167 virtual void didObserveLoadingBehavior(WebLoadingBehaviorFlag) {} | |
168 | |
169 // Transmits the change in the set of watched CSS selectors property that | |
170 // match any element on the frame. | |
171 virtual void selectorMatchChanged(const Vector<String>& addedSelectors, | |
172 const Vector<String>& removedSelectors) = 0; | |
173 | |
174 virtual DocumentLoader* createDocumentLoader(LocalFrame*, | |
175 const ResourceRequest&, | |
176 const SubstituteData&, | |
177 ClientRedirectPolicy) = 0; | |
178 | |
179 virtual String userAgent() = 0; | |
180 | |
181 virtual String doNotTrackValue() = 0; | |
182 | |
183 virtual void transitionToCommittedForNewPage() = 0; | |
184 | |
185 virtual LocalFrame* createFrame(const FrameLoadRequest&, | |
186 const AtomicString& name, | |
187 HTMLFrameOwnerElement*) = 0; | |
188 // Whether or not plugin creation should fail if the HTMLPlugInElement isn't | |
189 // in the DOM after plugin initialization. | |
190 enum DetachedPluginPolicy { | |
191 FailOnDetachedPlugin, | |
192 AllowDetachedPlugin, | |
193 }; | |
194 virtual bool canCreatePluginWithoutRenderer(const String& mimeType) const = 0; | |
195 virtual Widget* createPlugin(HTMLPlugInElement*, | |
196 const KURL&, | |
197 const Vector<String>&, | |
198 const Vector<String>&, | |
199 const String&, | |
200 bool loadManually, | |
201 DetachedPluginPolicy) = 0; | |
202 | |
203 virtual std::unique_ptr<WebMediaPlayer> createWebMediaPlayer( | |
204 HTMLMediaElement&, | |
205 const WebMediaPlayerSource&, | |
206 WebMediaPlayerClient*) = 0; | |
207 virtual WebRemotePlaybackClient* createWebRemotePlaybackClient( | |
208 HTMLMediaElement&) = 0; | |
209 | |
210 virtual ObjectContentType getObjectContentType( | |
211 const KURL&, | |
212 const String& mimeType, | |
213 bool shouldPreferPlugInsForImages) = 0; | |
214 | |
215 virtual void didCreateNewDocument() = 0; | |
216 virtual void dispatchDidClearWindowObjectInMainWorld() = 0; | |
217 virtual void documentElementAvailable() = 0; | |
218 virtual void runScriptsAtDocumentElementAvailable() = 0; | |
219 virtual void runScriptsAtDocumentReady(bool documentIsEmpty) = 0; | |
220 | |
221 virtual void didCreateScriptContext(v8::Local<v8::Context>, | |
222 int worldId) = 0; | |
223 virtual void willReleaseScriptContext(v8::Local<v8::Context>, | |
224 int worldId) = 0; | |
225 virtual bool allowScriptExtensions() = 0; | |
226 | |
227 virtual void didChangeScrollOffset() {} | |
228 virtual void didUpdateCurrentHistoryItem() {} | |
229 | |
230 virtual bool allowScript(bool enabledPerSettings) { | |
231 return enabledPerSettings; | |
232 } | |
233 virtual bool allowScriptFromSource(bool enabledPerSettings, const KURL&) { | |
234 return enabledPerSettings; | |
235 } | |
236 virtual bool allowPlugins(bool enabledPerSettings) { | |
237 return enabledPerSettings; | |
238 } | |
239 virtual bool allowImage(bool enabledPerSettings, const KURL&) { | |
240 return enabledPerSettings; | |
241 } | |
242 virtual bool allowMedia(const KURL&) { return true; } | |
243 virtual bool allowRunningInsecureContent(bool enabledPerSettings, | |
244 SecurityOrigin*, | |
245 const KURL&) { | |
246 return enabledPerSettings; | |
247 } | |
248 virtual bool allowAutoplay(bool defaultValue) { return defaultValue; } | |
249 | |
250 // Reports that passive mixed content was found at the provided URL. It may or | |
251 // may not be actually displayed later, what would be flagged by | |
252 // didDisplayInsecureContent. | |
253 virtual void passiveInsecureContentFound(const KURL&) {} | |
254 | |
255 // This callback notifies the client that the frame was about to run | |
256 // JavaScript but did not because allowScript returned false. We have a | |
257 // separate callback here because there are a number of places that need to | |
258 // know if JavaScript is enabled but are not necessarily preparing to execute | |
259 // script. | |
260 virtual void didNotAllowScript() {} | |
261 // This callback is similar, but for plugins. | |
262 virtual void didNotAllowPlugins() {} | |
263 | |
264 virtual WebCookieJar* cookieJar() const = 0; | |
265 | |
266 virtual void didChangeName(const String& name, const String& uniqueName) {} | |
267 | |
268 virtual void didEnforceInsecureRequestPolicy(WebInsecureRequestPolicy) {} | |
269 | |
270 virtual void didUpdateToUniqueOrigin() {} | |
271 | |
272 virtual void didChangeSandboxFlags(Frame* childFrame, SandboxFlags) {} | |
273 | |
274 virtual void didSetFeaturePolicyHeader( | |
275 const WebParsedFeaturePolicyHeader& parsedHeader) {} | |
276 | |
277 // Called when a new Content Security Policy is added to the frame's document. | |
278 // This can be triggered by handling of HTTP headers, handling of <meta> | |
279 // element, or by inheriting CSP from the parent (in case of about:blank). | |
280 virtual void didAddContentSecurityPolicy( | |
281 const String& headerValue, | |
282 ContentSecurityPolicyHeaderType, | |
283 ContentSecurityPolicyHeaderSource, | |
284 const std::vector<WebContentSecurityPolicyPolicy>&) {} | |
285 | |
286 virtual void didChangeFrameOwnerProperties(HTMLFrameElementBase*) {} | |
287 | |
288 virtual void dispatchWillStartUsingPeerConnectionHandler( | |
289 WebRTCPeerConnectionHandler*) {} | |
290 | |
291 virtual bool allowWebGL(bool enabledPerSettings) { | |
292 return enabledPerSettings; | |
293 } | |
294 | |
295 // If an HTML document is being loaded, informs the embedder that the document | |
296 // will have its <body> attached soon. | |
297 virtual void dispatchWillInsertBody() {} | |
298 | |
299 virtual std::unique_ptr<WebServiceWorkerProvider> | |
300 createServiceWorkerProvider() = 0; | |
301 | |
302 virtual bool isControlledByServiceWorker(DocumentLoader&) = 0; | |
303 | |
304 virtual int64_t serviceWorkerID(DocumentLoader&) = 0; | |
305 | |
306 virtual SharedWorkerRepositoryClient* sharedWorkerRepositoryClient() { | |
307 return 0; | |
308 } | |
309 | |
310 virtual std::unique_ptr<WebApplicationCacheHost> createApplicationCacheHost( | |
311 WebApplicationCacheHostClient*) = 0; | |
312 | |
313 virtual void dispatchDidChangeManifest() {} | |
314 | |
315 virtual unsigned backForwardLength() { return 0; } | |
316 | |
317 virtual bool isFrameLoaderClientImpl() const { return false; } | |
318 | |
319 // Called when elements preventing the sudden termination of the frame become | |
320 // present or stop being present. |type| is the type of element (BeforeUnload | |
321 // handler, Unload handler). | |
322 enum SuddenTerminationDisablerType { | |
323 BeforeUnloadHandler, | |
324 UnloadHandler, | |
325 }; | |
326 virtual void suddenTerminationDisablerChanged(bool present, | |
327 SuddenTerminationDisablerType) { | |
328 } | |
329 | |
330 virtual LinkResource* createServiceWorkerLinkResource(HTMLLinkElement*) { | |
331 return nullptr; | |
332 } | |
333 | |
334 // Effective connection type when this frame was loaded. | |
335 virtual WebEffectiveConnectionType getEffectiveConnectionType() { | |
336 return WebEffectiveConnectionType::TypeUnknown; | |
337 } | |
338 | |
339 // Overwrites the given URL to use an HTML5 embed if possible. An empty URL is | |
340 // returned if the URL is not overriden. | |
341 virtual KURL overrideFlashEmbedWithHTML(const KURL&) { return KURL(); } | |
342 | |
343 virtual BlameContext* frameBlameContext() { return nullptr; } | |
344 | |
345 virtual void setHasReceivedUserGesture() {} | |
346 }; | |
347 | 42 |
348 } // namespace blink | 43 } // namespace blink |
349 | 44 |
350 #endif // FrameLoaderClient_h | 45 #endif // FrameLoaderClient_h |
OLD | NEW |