0d41edbc1a9d2c2f537902a56d7d97e80bce01ae
[platform/framework/web/crosswalk-tizen.git] /
1 /*
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"
36 #include "platform/heap/Handle.h"
37 #include "platform/weborigin/KURL.h"
38 #include "public/platform/WebInsecureRequestPolicy.h"
39 #include "wtf/RefPtr.h"
40 #include <memory>
41
42 namespace blink {
43
44 class WebDevToolsAgentImpl;
45 class WebLocalFrameImpl;
46
47 class FrameLoaderClientImpl final : public FrameLoaderClient {
48  public:
49   static FrameLoaderClientImpl* create(WebLocalFrameImpl*);
50
51   ~FrameLoaderClientImpl() override;
52
53   DECLARE_VIRTUAL_TRACE();
54
55   WebLocalFrameImpl* webFrame() const { return m_webFrame.get(); }
56
57   // FrameLoaderClient ----------------------------------------------
58
59   void didCreateNewDocument() override;
60   // Notifies the WebView delegate that the JS window object has been cleared,
61   // giving it a chance to bind native objects to the window before script
62   // parsing begins.
63   void dispatchDidClearWindowObjectInMainWorld() override;
64   void documentElementAvailable() override;
65   void runScriptsAtDocumentElementAvailable() override;
66   void runScriptsAtDocumentReady(bool documentIsEmpty) override;
67
68   void didCreateScriptContext(v8::Local<v8::Context>,
69                               int extensionGroup,
70                               int worldId) override;
71   void willReleaseScriptContext(v8::Local<v8::Context>, int worldId) override;
72
73   // Returns true if we should allow the given V8 extension to be added to
74   // the script context at the currently loading page and given extension group.
75   bool allowScriptExtension(const String& extensionName,
76                             int extensionGroup,
77                             int worldId) override;
78
79   bool hasWebView() const override;
80   bool inShadowTree() const override;
81   Frame* opener() const override;
82   void setOpener(Frame*) override;
83   Frame* parent() const override;
84   Frame* top() const override;
85   Frame* nextSibling() const override;
86   Frame* firstChild() const override;
87   void willBeDetached() override;
88   void detached(FrameDetachType) override;
89   void dispatchWillSendRequest(ResourceRequest&) override;
90 #if defined(OS_TIZEN_TV_PRODUCT)
91   bool getFileDecryptedDataBuffer(const KURL& url, WebData& data) override;
92 #endif
93   void dispatchDidReceiveResponse(const ResourceResponse&) override;
94   void dispatchDidLoadResourceFromMemoryCache(const ResourceRequest&,
95                                               const ResourceResponse&) override;
96   void dispatchDidHandleOnloadEvents() override;
97   void dispatchDidReceiveServerRedirectForProvisionalLoad() override;
98   void dispatchDidNavigateWithinPage(HistoryItem*,
99                                      HistoryCommitType,
100                                      bool contentInitiated) override;
101   void dispatchWillCommitProvisionalLoad() override;
102   void dispatchDidStartProvisionalLoad() override;
103   void dispatchDidReceiveTitle(const String&) override;
104   void dispatchDidChangeIcons(IconType) override;
105   void dispatchDidCommitLoad(HistoryItem*, HistoryCommitType) override;
106   void dispatchDidFailProvisionalLoad(const ResourceError&,
107                                       HistoryCommitType) override;
108   void dispatchDidFailLoad(const ResourceError&, HistoryCommitType) override;
109   void dispatchDidFinishDocumentLoad() override;
110   void dispatchDidFinishLoad() override;
111
112   void dispatchDidChangeThemeColor() override;
113   NavigationPolicy decidePolicyForNavigation(const ResourceRequest&,
114                                              DocumentLoader*,
115                                              NavigationType,
116                                              NavigationPolicy,
117                                              bool shouldReplaceCurrentEntry,
118                                              bool isClientRedirect,
119                                              HTMLFormElement*) override;
120   void dispatchWillSendSubmitEvent(HTMLFormElement*) override;
121   void dispatchWillSubmitForm(HTMLFormElement*) override;
122 #if defined(S_TERRACE_SUPPORT)
123   void dispatchPasswordFormWasVisible(HTMLFormElement*) override;
124 #endif
125   void didStartLoading(LoadStartType) override;
126   void didStopLoading() override;
127   void progressEstimateChanged(double progressEstimate) override;
128   void loadURLExternally(const ResourceRequest&,
129                          NavigationPolicy,
130                          const String& suggestedName,
131                          bool shouldReplaceCurrentEntry) override;
132   bool navigateBackForward(int offset) const override;
133   void didAccessInitialDocument() override;
134   void didDisplayInsecureContent() override;
135   void didRunInsecureContent(SecurityOrigin*, const KURL& insecureURL) override;
136   void didDetectXSS(const KURL&, bool didBlockEntirePage) override;
137   void didDispatchPingLoader(const KURL&) override;
138   void didDisplayContentWithCertificateErrors(const KURL&) override;
139   void didRunContentWithCertificateErrors(const KURL&) override;
140   void didChangePerformanceTiming() override;
141   void didObserveLoadingBehavior(WebLoadingBehaviorFlag) override;
142   void selectorMatchChanged(const Vector<String>& addedSelectors,
143                             const Vector<String>& removedSelectors) override;
144   DocumentLoader* createDocumentLoader(LocalFrame*,
145                                        const ResourceRequest&,
146                                        const SubstituteData&,
147                                        ClientRedirectPolicy) override;
148   WTF::String userAgent() override;
149   WTF::String doNotTrackValue() override;
150   void transitionToCommittedForNewPage() override;
151   LocalFrame* createFrame(const FrameLoadRequest&,
152                           const WTF::AtomicString& name,
153                           HTMLFrameOwnerElement*) override;
154   virtual bool canCreatePluginWithoutRenderer(const String& mimeType) const;
155   Widget* createPlugin(HTMLPlugInElement*,
156                        const KURL&,
157                        const Vector<WTF::String>&,
158                        const Vector<WTF::String>&,
159                        const WTF::String&,
160                        bool loadManually,
161                        DetachedPluginPolicy) override;
162 #if defined(TIZEN_VIDEO_HOLE)
163   void setPresetDisableVideoHole(LocalFrame* frame, bool disable) override;
164 #endif
165   std::unique_ptr<WebMediaPlayer> createWebMediaPlayer(
166       HTMLMediaElement&,
167       const WebMediaPlayerSource&,
168       WebMediaPlayerClient*) override;
169   WebRemotePlaybackClient* createWebRemotePlaybackClient(
170       HTMLMediaElement&) override;
171   ObjectContentType getObjectContentType(
172       const KURL&,
173       const WTF::String& mimeType,
174       bool shouldPreferPlugInsForImages) override;
175   void didChangeScrollOffset() override;
176   void didUpdateCurrentHistoryItem() override;
177   bool allowScript(bool enabledPerSettings) override;
178   bool allowScriptFromSource(bool enabledPerSettings,
179                              const KURL& scriptURL) override;
180   bool allowPlugins(bool enabledPerSettings) override;
181   bool allowImage(bool enabledPerSettings, const KURL& imageURL) override;
182   bool allowRunningInsecureContent(bool enabledPerSettings,
183                                    SecurityOrigin*,
184                                    const KURL&) override;
185   bool allowAutoplay(bool defaultValue) override;
186   void passiveInsecureContentFound(const KURL&) override;
187   void didNotAllowScript() override;
188   void didNotAllowPlugins() override;
189   void didUseKeygen() override;
190
191   WebCookieJar* cookieJar() const override;
192   void frameFocused() const override;
193   void didChangeName(const String& name, const String& uniqueName) override;
194   void didEnforceInsecureRequestPolicy(WebInsecureRequestPolicy) override;
195   void didUpdateToUniqueOrigin() override;
196   void didChangeSandboxFlags(Frame* childFrame, SandboxFlags) override;
197   void didAddContentSecurityPolicy(const String& headerValue,
198                                    ContentSecurityPolicyHeaderType,
199                                    ContentSecurityPolicyHeaderSource) override;
200   void didChangeFrameOwnerProperties(HTMLFrameElementBase*) override;
201
202   void dispatchWillStartUsingPeerConnectionHandler(
203       WebRTCPeerConnectionHandler*) override;
204
205   bool allowWebGL(bool enabledPerSettings) override;
206
207   void dispatchWillInsertBody() override;
208
209   std::unique_ptr<WebServiceWorkerProvider> createServiceWorkerProvider()
210       override;
211   bool isControlledByServiceWorker(DocumentLoader&) override;
212   int64_t serviceWorkerID(DocumentLoader&) override;
213   SharedWorkerRepositoryClient* sharedWorkerRepositoryClient() override;
214
215   std::unique_ptr<WebApplicationCacheHost> createApplicationCacheHost(
216       WebApplicationCacheHostClient*) override;
217
218   void dispatchDidChangeManifest() override;
219
220   unsigned backForwardLength() override;
221
222   void suddenTerminationDisablerChanged(bool present,
223                                         SuddenTerminationDisablerType) override;
224
225   BlameContext* frameBlameContext() override;
226
227   LinkResource* createServiceWorkerLinkResource(HTMLLinkElement*) override;
228
229   WebEffectiveConnectionType getEffectiveConnectionType() override;
230
231   KURL overrideFlashEmbedWithHTML(const KURL&) override;
232
233 #if defined(TIZEN_VIDEO_MANUAL_ROTATION_SUPPORT)
234   void requestRotateWebMediaPlayer(LocalFrame*, WebMediaPlayerRotate) override;
235 #endif
236
237 #if defined(USE_EFL)
238   bool getWrtParsedUrl(const KURL& url, KURL& parsed_url) override;
239 #endif
240
241  private:
242   explicit FrameLoaderClientImpl(WebLocalFrameImpl*);
243
244   bool isFrameLoaderClientImpl() const override { return true; }
245   WebDevToolsAgentImpl* devToolsAgent();
246
247   // The WebFrame that owns this object and manages its lifetime. Therefore,
248   // the web frame object is guaranteed to exist.
249   Member<WebLocalFrameImpl> m_webFrame;
250
251   String m_userAgent;
252 };
253
254 DEFINE_TYPE_CASTS(FrameLoaderClientImpl,
255                   FrameLoaderClient,
256                   client,
257                   client->isFrameLoaderClientImpl(),
258                   client.isFrameLoaderClientImpl());
259
260 }  // namespace blink
261
262 #endif