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