2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
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
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.
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.
32 #ifndef FrameLoaderClientImpl_h
33 #define FrameLoaderClientImpl_h
35 #include "core/loader/FrameLoaderClient.h"
36 #include "platform/weborigin/KURL.h"
37 #include "wtf/PassOwnPtr.h"
38 #include "wtf/RefPtr.h"
43 class WebPluginContainerImpl;
44 class WebPluginLoadObserver;
46 class FrameLoaderClientImpl FINAL : public WebCore::FrameLoaderClient {
48 FrameLoaderClientImpl(WebFrameImpl* webFrame);
49 virtual ~FrameLoaderClientImpl();
51 WebFrameImpl* webFrame() const { return m_webFrame; }
53 // WebCore::FrameLoaderClient ----------------------------------------------
55 // 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
58 virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*) OVERRIDE;
59 virtual void documentElementAvailable() OVERRIDE;
61 // Script in the page tried to allocate too much memory.
62 virtual void didExhaustMemoryAvailableForScript();
64 virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) OVERRIDE;
65 virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) OVERRIDE;
67 // Returns true if we should allow the given V8 extension to be added to
68 // the script context at the currently loading page and given extension group.
69 virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) OVERRIDE;
71 virtual bool hasWebView() const OVERRIDE;
72 virtual void detachedFromParent() OVERRIDE;
73 virtual void dispatchWillRequestAfterPreconnect(WebCore::ResourceRequest&) OVERRIDE;
74 virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse) OVERRIDE;
75 virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&) OVERRIDE;
76 virtual void dispatchDidChangeResourcePriority(unsigned long identifier, WebCore::ResourceLoadPriority) OVERRIDE;
77 virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier) OVERRIDE;
78 virtual void dispatchDidLoadResourceFromMemoryCache(const WebCore::ResourceRequest&, const WebCore::ResourceResponse&) OVERRIDE;
79 virtual void dispatchDidHandleOnloadEvents() OVERRIDE;
80 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() OVERRIDE;
81 virtual void dispatchDidNavigateWithinPage(WebCore::HistoryItem*, WebCore::HistoryCommitType) OVERRIDE;
82 virtual void dispatchWillClose() OVERRIDE;
83 virtual void dispatchDidStartProvisionalLoad() OVERRIDE;
84 virtual void dispatchDidReceiveTitle(const String&) OVERRIDE;
85 virtual void dispatchDidChangeIcons(WebCore::IconType) OVERRIDE;
86 virtual void dispatchDidCommitLoad(WebCore::Frame*, WebCore::HistoryItem*, WebCore::HistoryCommitType) OVERRIDE;
87 virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&) OVERRIDE;
88 virtual void dispatchDidFailLoad(const WebCore::ResourceError&) OVERRIDE;
89 virtual void dispatchDidFinishDocumentLoad() OVERRIDE;
90 virtual void dispatchDidFinishLoad() OVERRIDE;
91 virtual void dispatchDidFirstVisuallyNonEmptyLayout() OVERRIDE;
92 virtual WebCore::NavigationPolicy decidePolicyForNavigation(const WebCore::ResourceRequest&, WebCore::DocumentLoader*, WebCore::NavigationPolicy) OVERRIDE;
93 virtual void dispatchWillRequestResource(WebCore::FetchRequest*) OVERRIDE;
94 virtual void dispatchWillSendSubmitEvent(PassRefPtr<WebCore::FormState>) OVERRIDE;
95 virtual void dispatchWillSubmitForm(PassRefPtr<WebCore::FormState>) OVERRIDE;
96 virtual void postProgressStartedNotification(WebCore::LoadStartType) OVERRIDE;
97 virtual void postProgressEstimateChangedNotification() OVERRIDE;
98 virtual void postProgressFinishedNotification() OVERRIDE;
99 virtual void loadURLExternally(const WebCore::ResourceRequest&, WebCore::NavigationPolicy, const String& suggestedName = String()) OVERRIDE;
100 virtual bool navigateBackForward(int offset) const OVERRIDE;
101 virtual void didAccessInitialDocument() OVERRIDE;
102 virtual void didDisownOpener() OVERRIDE;
103 virtual void didDisplayInsecureContent() OVERRIDE;
104 virtual void didRunInsecureContent(WebCore::SecurityOrigin*, const WebCore::KURL& insecureURL) OVERRIDE;
105 virtual void didDetectXSS(const WebCore::KURL&, bool didBlockEntirePage) OVERRIDE;
106 virtual void didDispatchPingLoader(const WebCore::KURL&) OVERRIDE;
107 virtual void selectorMatchChanged(const Vector<String>& addedSelectors, const Vector<String>& removedSelectors) OVERRIDE;
108 virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(WebCore::Frame*, const WebCore::ResourceRequest&, const WebCore::SubstituteData&) OVERRIDE;
109 virtual WTF::String userAgent(const WebCore::KURL&) OVERRIDE;
110 virtual WTF::String doNotTrackValue() OVERRIDE;
111 virtual void transitionToCommittedForNewPage() OVERRIDE;
112 virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL&, const WTF::AtomicString& name, const WTF::String& referrer, WebCore::HTMLFrameOwnerElement*) OVERRIDE;
113 virtual PassRefPtr<WebCore::Widget> createPlugin(
114 const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&,
115 const Vector<WTF::String>&, const Vector<WTF::String>&,
116 const WTF::String&, bool loadManually) OVERRIDE;
117 virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(
118 const WebCore::IntSize&,
119 WebCore::HTMLAppletElement*,
120 const WebCore::KURL& /* base_url */,
121 const Vector<WTF::String>& paramNames,
122 const Vector<WTF::String>& paramValues) OVERRIDE;
123 virtual WebCore::ObjectContentType objectContentType(
124 const WebCore::KURL&, const WTF::String& mimeType, bool shouldPreferPlugInsForImages) OVERRIDE;
125 virtual void didChangeScrollOffset() OVERRIDE;
126 virtual bool allowScript(bool enabledPerSettings) OVERRIDE;
127 virtual bool allowScriptFromSource(bool enabledPerSettings, const WebCore::KURL& scriptURL) OVERRIDE;
128 virtual bool allowPlugins(bool enabledPerSettings) OVERRIDE;
129 virtual bool allowImage(bool enabledPerSettings, const WebCore::KURL& imageURL) OVERRIDE;
130 virtual bool allowDisplayingInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&) OVERRIDE;
131 virtual bool allowRunningInsecureContent(bool enabledPerSettings, WebCore::SecurityOrigin*, const WebCore::KURL&) OVERRIDE;
132 virtual void didNotAllowScript() OVERRIDE;
133 virtual void didNotAllowPlugins() OVERRIDE;
135 virtual WebCookieJar* cookieJar() const OVERRIDE;
136 virtual bool willCheckAndDispatchMessageEvent(WebCore::SecurityOrigin* target, WebCore::MessageEvent*) const OVERRIDE;
137 virtual void didChangeName(const String&) OVERRIDE;
139 virtual void dispatchWillOpenSocketStream(WebCore::SocketStreamHandle*) OVERRIDE;
141 virtual void dispatchWillStartUsingPeerConnectionHandler(blink::WebRTCPeerConnectionHandler*) OVERRIDE;
143 virtual void didRequestAutocomplete(PassRefPtr<WebCore::FormState>) OVERRIDE;
145 virtual bool allowWebGL(bool enabledPerSettings) OVERRIDE;
146 virtual void didLoseWebGLContext(int arbRobustnessContextLostReason) OVERRIDE;
147 virtual bool allowWebGLDebugRendererInfo() OVERRIDE;
149 virtual void dispatchWillInsertBody() OVERRIDE;
151 virtual PassOwnPtr<WebServiceWorkerProvider> createServiceWorkerProvider(PassOwnPtr<WebServiceWorkerProviderClient>) OVERRIDE;
152 virtual WebCore::SharedWorkerRepositoryClient* sharedWorkerRepositoryClient() OVERRIDE;
154 virtual void didStopAllLoaders() OVERRIDE;
157 virtual bool isFrameLoaderClientImpl() const OVERRIDE { return true; }
159 PassOwnPtr<WebPluginLoadObserver> pluginLoadObserver(WebCore::DocumentLoader*);
161 // The WebFrame that owns this object and manages its lifetime. Therefore,
162 // the web frame object is guaranteed to exist.
163 WebFrameImpl* m_webFrame;
166 DEFINE_TYPE_CASTS(FrameLoaderClientImpl, WebCore::FrameLoaderClient, client, client->isFrameLoaderClientImpl(), client.isFrameLoaderClientImpl());