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