Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / loader / FrameLoaderClient.h
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 "core/dom/IconURL.h"
34 #include "core/loader/FrameLoaderTypes.h"
35 #include "core/loader/NavigationPolicy.h"
36 #include "platform/network/ResourceLoadPriority.h"
37 #include "platform/weborigin/Referrer.h"
38 #include "wtf/Forward.h"
39 #include "wtf/Vector.h"
40
41 typedef class _jobject* jobject;
42
43 namespace v8 {
44 class Context;
45 template<class T> class Handle;
46 }
47
48 namespace blink {
49 class WebCookieJar;
50 class WebRTCPeerConnectionHandler;
51 class WebServiceWorkerProvider;
52 class WebServiceWorkerProviderClient;
53 }
54
55 namespace WebCore {
56
57     class Color;
58     class DOMWindowExtension;
59     class DOMWrapperWorld;
60     class DocumentLoader;
61     class Element;
62 class FetchRequest;
63     class FormState;
64     class Frame;
65     class FrameLoader;
66     class FrameNetworkingContext;
67     class HistoryItem;
68     class HTMLAppletElement;
69     class HTMLFormElement;
70     class HTMLFrameOwnerElement;
71     class HTMLPlugInElement;
72     class IntSize;
73     class KURL;
74     class MessageEvent;
75     class Page;
76     class PluginView;
77     class ResourceError;
78     class ResourceHandle;
79     class ResourceRequest;
80     class ResourceResponse;
81     class SecurityOrigin;
82     class SharedBuffer;
83     class SharedWorkerRepositoryClient;
84     class SocketStreamHandle;
85     class SubstituteData;
86     class Widget;
87
88     class FrameLoaderClient {
89     public:
90         virtual ~FrameLoaderClient() { }
91
92         virtual bool hasWebView() const = 0; // mainly for assertions
93
94         virtual Frame* parent() const = 0;
95         virtual Frame* top() const = 0;
96         virtual Frame* previousSibling() const = 0;
97         virtual Frame* nextSibling() const = 0;
98         virtual Frame* firstChild() const = 0;
99         virtual Frame* lastChild() const = 0;
100         virtual void detachedFromParent() = 0;
101
102         virtual void dispatchWillRequestAfterPreconnect(ResourceRequest&) { }
103         virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse) = 0;
104         virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long identifier, const ResourceResponse&) = 0;
105         virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) = 0;
106         virtual void dispatchDidLoadResourceFromMemoryCache(const ResourceRequest&, const ResourceResponse&) = 0;
107
108         virtual void dispatchDidHandleOnloadEvents() = 0;
109         virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0;
110         virtual void dispatchDidNavigateWithinPage(HistoryItem*, HistoryCommitType) { }
111         virtual void dispatchWillClose() = 0;
112         virtual void dispatchDidStartProvisionalLoad() = 0;
113         virtual void dispatchDidReceiveTitle(const String&) = 0;
114         virtual void dispatchDidChangeIcons(IconType) = 0;
115         virtual void dispatchDidCommitLoad(Frame*, HistoryItem*, HistoryCommitType) = 0;
116         virtual void dispatchDidFailProvisionalLoad(const ResourceError&) = 0;
117         virtual void dispatchDidFailLoad(const ResourceError&) = 0;
118         virtual void dispatchDidFinishDocumentLoad() = 0;
119         virtual void dispatchDidFinishLoad() = 0;
120         virtual void dispatchDidFirstVisuallyNonEmptyLayout() = 0;
121
122         virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, DocumentLoader*, NavigationPolicy) = 0;
123
124         virtual void dispatchWillRequestResource(FetchRequest*) { }
125
126         virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) = 0;
127         virtual void dispatchWillSubmitForm(PassRefPtr<FormState>) = 0;
128
129         // Maybe these should go into a ProgressTrackerClient some day
130         virtual void postProgressStartedNotification(LoadStartType) = 0;
131         virtual void postProgressEstimateChangedNotification() = 0;
132         virtual void postProgressFinishedNotification() = 0;
133
134         virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& suggestedName = String()) = 0;
135
136         virtual bool navigateBackForward(int offset) const = 0;
137
138         // Another page has accessed the initial empty document of this frame.
139         // It is no longer safe to display a provisional URL, since a URL spoof
140         // is now possible.
141         virtual void didAccessInitialDocument() { }
142
143         // This frame has set its opener to null, disowning it for the lifetime of the frame.
144         // See http://html.spec.whatwg.org/#dom-opener.
145         // FIXME: JSC should allow disowning opener. - <https://bugs.webkit.org/show_bug.cgi?id=103913>.
146         virtual void didDisownOpener() { }
147
148         // This frame has displayed inactive content (such as an image) from an
149         // insecure source.  Inactive content cannot spread to other frames.
150         virtual void didDisplayInsecureContent() = 0;
151
152         // The indicated security origin has run active content (such as a
153         // script) from an insecure source.  Note that the insecure content can
154         // spread to other frames in the same origin.
155         virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) = 0;
156         virtual void didDetectXSS(const KURL&, bool didBlockEntirePage) = 0;
157         virtual void didDispatchPingLoader(const KURL&) = 0;
158
159         // Transmits the change in the set of watched CSS selectors property
160         // that match any element on the frame.
161         virtual void selectorMatchChanged(const Vector<String>& addedSelectors, const Vector<String>& removedSelectors) = 0;
162
163         virtual PassRefPtr<DocumentLoader> createDocumentLoader(Frame*, const ResourceRequest&, const SubstituteData&) = 0;
164
165         virtual String userAgent(const KURL&) = 0;
166
167         virtual String doNotTrackValue() = 0;
168
169         virtual void transitionToCommittedForNewPage() = 0;
170
171         virtual PassRefPtr<Frame> createFrame(const KURL&, const AtomicString& name, const Referrer&, HTMLFrameOwnerElement*) = 0;
172         virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool loadManually) = 0;
173
174         virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL& baseURL, const Vector<String>& paramNames, const Vector<String>& paramValues) = 0;
175
176         virtual ObjectContentType objectContentType(const KURL&, const String& mimeType, bool shouldPreferPlugInsForImages) = 0;
177
178         virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) = 0;
179         virtual void documentElementAvailable() = 0;
180
181         virtual void didExhaustMemoryAvailableForScript() { };
182
183         virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) = 0;
184         virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) = 0;
185         virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) = 0;
186
187         virtual void didChangeScrollOffset() { }
188
189         virtual bool allowScript(bool enabledPerSettings) { return enabledPerSettings; }
190         virtual bool allowScriptFromSource(bool enabledPerSettings, const KURL&) { return enabledPerSettings; }
191         virtual bool allowPlugins(bool enabledPerSettings) { return enabledPerSettings; }
192         virtual bool allowImage(bool enabledPerSettings, const KURL&) { return enabledPerSettings; }
193         virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, SecurityOrigin*, const KURL&) { return enabledPerSettings; }
194         virtual bool allowRunningInsecureContent(bool enabledPerSettings, SecurityOrigin*, const KURL&) { return enabledPerSettings; }
195
196         // This callback notifies the client that the frame was about to run
197         // JavaScript but did not because allowScript returned false. We
198         // have a separate callback here because there are a number of places
199         // that need to know if JavaScript is enabled but are not necessarily
200         // preparing to execute script.
201         virtual void didNotAllowScript() { }
202         // This callback is similar, but for plugins.
203         virtual void didNotAllowPlugins() { }
204
205         virtual blink::WebCookieJar* cookieJar() const = 0;
206
207         // Returns true if the embedder intercepted the postMessage call
208         virtual bool willCheckAndDispatchMessageEvent(SecurityOrigin* /*target*/, MessageEvent*) const { return false; }
209
210         virtual void didChangeName(const String&) { }
211
212         virtual void dispatchWillOpenSocketStream(SocketStreamHandle*) { }
213
214         virtual void dispatchWillStartUsingPeerConnectionHandler(blink::WebRTCPeerConnectionHandler*) { }
215
216         virtual void didRequestAutocomplete(PassRefPtr<FormState>) = 0;
217
218         virtual bool allowWebGL(bool enabledPerSettings) { return enabledPerSettings; }
219         // Informs the embedder that a WebGL canvas inside this frame received a lost context
220         // notification with the given GL_ARB_robustness guilt/innocence code (see Extensions3D.h).
221         virtual void didLoseWebGLContext(int) { }
222
223         // If an HTML document is being loaded, informs the embedder that the document will have its <body> attached soon.
224         virtual void dispatchWillInsertBody() { }
225
226         virtual void dispatchDidChangeResourcePriority(unsigned long /*identifier*/, ResourceLoadPriority) { }
227
228         virtual PassOwnPtr<blink::WebServiceWorkerProvider> createServiceWorkerProvider(PassOwnPtr<blink::WebServiceWorkerProviderClient>) = 0;
229
230         virtual SharedWorkerRepositoryClient* sharedWorkerRepositoryClient() { return 0; }
231
232         virtual void didStopAllLoaders() { }
233
234         virtual bool isFrameLoaderClientImpl() const { return false; }
235     };
236
237 } // namespace WebCore
238
239 #endif // FrameLoaderClient_h