blob: e8d8142b363b4998bccf716b465e7d151de15a34 [file] [log] [blame]
Ben Murdoche69819b2013-07-17 14:56:49 +01001/*
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Apple 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 are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef FrameLoaderClientImpl_h
33#define FrameLoaderClientImpl_h
34
35#include "core/loader/FrameLoaderClient.h"
Torne (Richard Coles)51b29062013-11-28 11:56:03 +000036#include "platform/weborigin/KURL.h"
Ben Murdoche69819b2013-07-17 14:56:49 +010037#include "wtf/PassOwnPtr.h"
38#include "wtf/RefPtr.h"
39
Torne (Richard Coles)51b29062013-11-28 11:56:03 +000040namespace blink {
Ben Murdoche69819b2013-07-17 14:56:49 +010041
42class WebFrameImpl;
43class WebPluginContainerImpl;
44class WebPluginLoadObserver;
45
Torne (Richard Coles)09380292014-02-21 12:17:33 +000046class FrameLoaderClientImpl FINAL : public WebCore::FrameLoaderClient {
Ben Murdoche69819b2013-07-17 14:56:49 +010047public:
48 FrameLoaderClientImpl(WebFrameImpl* webFrame);
Torne (Richard Coles)09380292014-02-21 12:17:33 +000049 virtual ~FrameLoaderClientImpl();
Ben Murdoche69819b2013-07-17 14:56:49 +010050
51 WebFrameImpl* webFrame() const { return m_webFrame; }
52
53 // WebCore::FrameLoaderClient ----------------------------------------------
54
Ben Murdoche69819b2013-07-17 14:56:49 +010055 // Notifies the WebView delegate that the JS window object has been cleared,
56 // giving it a chance to bind native objects to the window before script
57 // parsing begins.
Ben Murdochf5f02c92014-04-01 10:55:29 +010058 virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld&) OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +000059 virtual void documentElementAvailable() OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +010060
Torne (Richard Coles)09380292014-02-21 12:17:33 +000061 virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) OVERRIDE;
62 virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +010063
64 // Returns true if we should allow the given V8 extension to be added to
65 // the script context at the currently loading page and given extension group.
Torne (Richard Coles)09380292014-02-21 12:17:33 +000066 virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +010067
Torne (Richard Coles)09380292014-02-21 12:17:33 +000068 virtual bool hasWebView() const OVERRIDE;
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000069 virtual WebCore::Frame* opener() const OVERRIDE;
70 virtual void setOpener(WebCore::Frame*) OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +000071 virtual WebCore::Frame* parent() const OVERRIDE;
72 virtual WebCore::Frame* top() const OVERRIDE;
73 virtual WebCore::Frame* previousSibling() const OVERRIDE;
74 virtual WebCore::Frame* nextSibling() const OVERRIDE;
75 virtual WebCore::Frame* firstChild() const OVERRIDE;
76 virtual WebCore::Frame* lastChild() const OVERRIDE;
77 virtual void detachedFromParent() OVERRIDE;
78 virtual void dispatchWillRequestAfterPreconnect(WebCore::ResourceRequest&) OVERRIDE;
79 virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse) OVERRIDE;
80 virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&) OVERRIDE;
Ben Murdoch07a852d2014-03-31 11:51:52 +010081 virtual void dispatchDidChangeResourcePriority(unsigned long identifier, WebCore::ResourceLoadPriority, int intraPriorityValue) OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +000082 virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier) OVERRIDE;
83 virtual void dispatchDidLoadResourceFromMemoryCache(const WebCore::ResourceRequest&, const WebCore::ResourceResponse&) OVERRIDE;
84 virtual void dispatchDidHandleOnloadEvents() OVERRIDE;
85 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() OVERRIDE;
86 virtual void dispatchDidNavigateWithinPage(WebCore::HistoryItem*, WebCore::HistoryCommitType) OVERRIDE;
87 virtual void dispatchWillClose() OVERRIDE;
88 virtual void dispatchDidStartProvisionalLoad() OVERRIDE;
89 virtual void dispatchDidReceiveTitle(const String&) OVERRIDE;
90 virtual void dispatchDidChangeIcons(WebCore::IconType) OVERRIDE;
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000091 virtual void dispatchDidCommitLoad(WebCore::LocalFrame*, WebCore::HistoryItem*, WebCore::HistoryCommitType) OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +000092 virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&) OVERRIDE;
93 virtual void dispatchDidFailLoad(const WebCore::ResourceError&) OVERRIDE;
94 virtual void dispatchDidFinishDocumentLoad() OVERRIDE;
95 virtual void dispatchDidFinishLoad() OVERRIDE;
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010096 virtual void dispatchDidFirstVisuallyNonEmptyLayout() OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +000097 virtual WebCore::NavigationPolicy decidePolicyForNavigation(const WebCore::ResourceRequest&, WebCore::DocumentLoader*, WebCore::NavigationPolicy) OVERRIDE;
98 virtual void dispatchWillRequestResource(WebCore::FetchRequest*) OVERRIDE;
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000099 virtual void dispatchWillSendSubmitEvent(WebCore::HTMLFormElement*) OVERRIDE;
100 virtual void dispatchWillSubmitForm(WebCore::HTMLFormElement*) OVERRIDE;
Ben Murdoch07a852d2014-03-31 11:51:52 +0100101 virtual void didStartLoading(WebCore::LoadStartType) OVERRIDE;
102 virtual void didStopLoading() OVERRIDE;
103 virtual void progressEstimateChanged(double progressEstimate) OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000104 virtual void loadURLExternally(const WebCore::ResourceRequest&, WebCore::NavigationPolicy, const String& suggestedName = String()) OVERRIDE;
105 virtual bool navigateBackForward(int offset) const OVERRIDE;
106 virtual void didAccessInitialDocument() OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000107 virtual void didDisplayInsecureContent() OVERRIDE;
108 virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL& insecureURL) OVERRIDE;
109 virtual void didDetectXSS(const WebCore::KURL&, bool didBlockEntirePage) OVERRIDE;
110 virtual void didDispatchPingLoader(const WebCore::KURL&) OVERRIDE;
111 virtual void selectorMatchChanged(const Vector<String>& addedSelectors, const Vector<String>& removedSelectors) OVERRIDE;
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000112 virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(WebCore::LocalFrame*, const WebCore::ResourceRequest&, const WebCore::SubstituteData&) OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000113 virtual WTF::String userAgent(const WebCore::KURL&) OVERRIDE;
114 virtual WTF::String doNotTrackValue() OVERRIDE;
115 virtual void transitionToCommittedForNewPage() OVERRIDE;
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000116 virtual PassRefPtr<WebCore::LocalFrame> createFrame(const WebCore::KURL&, const WTF::AtomicString& name, const WebCore::Referrer&, WebCore::HTMLFrameOwnerElement*) OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +0100117 virtual PassRefPtr<WebCore::Widget> createPlugin(
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000118 WebCore::HTMLPlugInElement*, const WebCore::KURL&,
Ben Murdoche69819b2013-07-17 14:56:49 +0100119 const Vector<WTF::String>&, const Vector<WTF::String>&,
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000120 const WTF::String&, bool loadManually, DetachedPluginPolicy) OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +0100121 virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(
Ben Murdoche69819b2013-07-17 14:56:49 +0100122 WebCore::HTMLAppletElement*,
123 const WebCore::KURL& /* base_url */,
124 const Vector<WTF::String>& paramNames,
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000125 const Vector<WTF::String>& paramValues) OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +0100126 virtual WebCore::ObjectContentType objectContentType(
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000127 const WebCore::KURL&, const WTF::String& mimeType, bool shouldPreferPlugInsForImages) OVERRIDE;
128 virtual void didChangeScrollOffset() OVERRIDE;
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000129 virtual void didUpdateCurrentHistoryItem() OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000130 virtual bool allowScript(bool enabledPerSettings) OVERRIDE;
131 virtual bool allowScriptFromSource(bool enabledPerSettings, const WebCore::KURL& scriptURL) OVERRIDE;
132 virtual bool allowPlugins(bool enabledPerSettings) OVERRIDE;
133 virtual bool allowImage(bool enabledPerSettings, const WebCore::KURL& imageURL) OVERRIDE;
134 virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&) OVERRIDE;
135 virtual bool allowRunningInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&) OVERRIDE;
136 virtual void didNotAllowScript() OVERRIDE;
137 virtual void didNotAllowPlugins() OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +0100138
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000139 virtual WebCookieJar* cookieJar() const OVERRIDE;
140 virtual bool willCheckAndDispatchMessageEvent(WebCore::SecurityOrigin* target, WebCore::MessageEvent*) const OVERRIDE;
141 virtual void didChangeName(const String&) OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +0100142
143 virtual void dispatchWillOpenSocketStream(WebCore::SocketStreamHandle*) OVERRIDE;
144
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000145 virtual void dispatchWillStartUsingPeerConnectionHandler(blink::WebRTCPeerConnectionHandler*) OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +0100146
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000147 virtual void didRequestAutocomplete(WebCore::HTMLFormElement*) OVERRIDE;
Ben Murdoche69819b2013-07-17 14:56:49 +0100148
149 virtual bool allowWebGL(bool enabledPerSettings) OVERRIDE;
150 virtual void didLoseWebGLContext(int arbRobustnessContextLostReason) OVERRIDE;
151
152 virtual void dispatchWillInsertBody() OVERRIDE;
153
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000154 virtual PassOwnPtr<WebServiceWorkerProvider> createServiceWorkerProvider() OVERRIDE;
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000155 virtual WebCore::SharedWorkerRepositoryClient* sharedWorkerRepositoryClient() OVERRIDE;
Torne (Richard Coles)06f816c2013-09-26 13:25:12 +0100156
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000157 virtual PassOwnPtr<WebApplicationCacheHost> createApplicationCacheHost(WebApplicationCacheHostClient*) OVERRIDE;
158
Torne (Richard Coles)06f816c2013-09-26 13:25:12 +0100159 virtual void didStopAllLoaders() OVERRIDE;
Torne (Richard Coles)9bbd2f52013-09-19 22:37:05 +0100160
Ben Murdoche69819b2013-07-17 14:56:49 +0100161private:
Torne (Richard Coles)1e202182013-10-18 15:46:42 +0100162 virtual bool isFrameLoaderClientImpl() const OVERRIDE { return true; }
163
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000164 PassOwnPtr<WebPluginLoadObserver> pluginLoadObserver(WebCore::DocumentLoader*);
Ben Murdoche69819b2013-07-17 14:56:49 +0100165
166 // The WebFrame that owns this object and manages its lifetime. Therefore,
167 // the web frame object is guaranteed to exist.
168 WebFrameImpl* m_webFrame;
169};
170
Torne (Richard Coles)09380292014-02-21 12:17:33 +0000171DEFINE_TYPE_CASTS(FrameLoaderClientImpl, WebCore::FrameLoaderClient, client, client->isFrameLoaderClientImpl(), client.isFrameLoaderClientImpl());
Torne (Richard Coles)1e202182013-10-18 15:46:42 +0100172
Torne (Richard Coles)51b29062013-11-28 11:56:03 +0000173} // namespace blink
Ben Murdoche69819b2013-07-17 14:56:49 +0100174
175#endif