|
1 /* |
|
2 * Copyright (C) 2009 Google Inc. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or without |
|
5 * modification, are permitted provided that the following conditions are |
|
6 * met: |
|
7 * |
|
8 * * Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * * Redistributions in binary form must reproduce the above |
|
11 * copyright notice, this list of conditions and the following disclaimer |
|
12 * in the documentation and/or other materials provided with the |
|
13 * distribution. |
|
14 * * Neither the name of Google Inc. nor the names of its |
|
15 * contributors may be used to endorse or promote products derived from |
|
16 * this software without specific prior written permission. |
|
17 * |
|
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 */ |
|
30 |
|
31 #ifndef FrameLoaderClientImpl_h |
|
32 #define FrameLoaderClientImpl_h |
|
33 |
|
34 #include "FrameLoaderClient.h" |
|
35 #include "KURL.h" |
|
36 #include "WebNavigationPolicy.h" |
|
37 #include <wtf/PassOwnPtr.h> |
|
38 #include <wtf/RefPtr.h> |
|
39 |
|
40 namespace WebKit { |
|
41 |
|
42 class WebFrameImpl; |
|
43 class WebPluginContainerImpl; |
|
44 class WebPluginLoadObserver; |
|
45 |
|
46 class FrameLoaderClientImpl : public WebCore::FrameLoaderClient { |
|
47 public: |
|
48 FrameLoaderClientImpl(WebFrameImpl* webFrame); |
|
49 ~FrameLoaderClientImpl(); |
|
50 |
|
51 WebFrameImpl* webFrame() const { return m_webFrame; } |
|
52 |
|
53 // WebCore::FrameLoaderClient ---------------------------------------------- |
|
54 |
|
55 virtual void frameLoaderDestroyed(); |
|
56 |
|
57 // Notifies the WebView delegate that the JS window object has been cleared, |
|
58 // giving it a chance to bind native objects to the window before script |
|
59 // parsing begins. |
|
60 virtual void dispatchDidClearWindowObjectInWorld(WebCore::DOMWrapperWorld*); |
|
61 virtual void documentElementAvailable(); |
|
62 |
|
63 // A frame's V8 context was created or destroyed. |
|
64 virtual void didCreateScriptContextForFrame(); |
|
65 virtual void didDestroyScriptContextForFrame(); |
|
66 |
|
67 // A context untied to a frame was created (through evaluateInIsolatedWorld). |
|
68 // This context is not tied to the lifetime of its frame, and is destroyed |
|
69 // in garbage collection. |
|
70 virtual void didCreateIsolatedScriptContext(); |
|
71 |
|
72 virtual bool hasWebView() const; |
|
73 virtual bool hasFrameView() const; |
|
74 virtual void makeRepresentation(WebCore::DocumentLoader*); |
|
75 virtual void forceLayout(); |
|
76 virtual void forceLayoutForNonHTML(); |
|
77 virtual void setCopiesOnScroll(); |
|
78 virtual void detachedFromParent2(); |
|
79 virtual void detachedFromParent3(); |
|
80 virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&); |
|
81 virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse); |
|
82 virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier); |
|
83 virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); |
|
84 virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); |
|
85 virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&); |
|
86 virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived); |
|
87 virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier); |
|
88 virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&); |
|
89 virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length); |
|
90 virtual void dispatchDidHandleOnloadEvents(); |
|
91 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(); |
|
92 virtual void dispatchDidCancelClientRedirect(); |
|
93 virtual void dispatchWillPerformClientRedirect(const WebCore::KURL&, double interval, double fireDate); |
|
94 virtual void dispatchDidNavigateWithinPage(); |
|
95 virtual void dispatchDidChangeLocationWithinPage(); |
|
96 virtual void dispatchDidPushStateWithinPage(); |
|
97 virtual void dispatchDidReplaceStateWithinPage(); |
|
98 virtual void dispatchDidPopStateWithinPage(); |
|
99 virtual void dispatchWillClose(); |
|
100 virtual void dispatchDidReceiveIcon(); |
|
101 virtual void dispatchDidStartProvisionalLoad(); |
|
102 virtual void dispatchDidReceiveTitle(const WebCore::String& title); |
|
103 virtual void dispatchDidChangeIcons(); |
|
104 virtual void dispatchDidCommitLoad(); |
|
105 virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&); |
|
106 virtual void dispatchDidFailLoad(const WebCore::ResourceError&); |
|
107 virtual void dispatchDidFinishDocumentLoad(); |
|
108 virtual void dispatchDidFinishLoad(); |
|
109 virtual void dispatchDidFirstLayout(); |
|
110 virtual void dispatchDidFirstVisuallyNonEmptyLayout(); |
|
111 virtual WebCore::Frame* dispatchCreatePage(); |
|
112 virtual void dispatchShow(); |
|
113 virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction function, const WebCore::String& mime_type, const WebCore::ResourceRequest&); |
|
114 virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState> form_state, const WebCore::String& frame_name); |
|
115 virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction function, const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, PassRefPtr<WebCore::FormState> form_state); |
|
116 virtual void cancelPolicyCheck(); |
|
117 virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); |
|
118 virtual void dispatchWillSendSubmitEvent(WebCore::HTMLFormElement*); |
|
119 virtual void dispatchWillSubmitForm(WebCore::FramePolicyFunction, PassRefPtr<WebCore::FormState>); |
|
120 virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); |
|
121 virtual void revertToProvisionalState(WebCore::DocumentLoader*); |
|
122 virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); |
|
123 virtual void willChangeEstimatedProgress() { } |
|
124 virtual void didChangeEstimatedProgress() { } |
|
125 virtual void postProgressStartedNotification(); |
|
126 virtual void postProgressEstimateChangedNotification(); |
|
127 virtual void postProgressFinishedNotification(); |
|
128 virtual void setMainFrameDocumentReady(bool); |
|
129 virtual void startDownload(const WebCore::ResourceRequest&); |
|
130 virtual void willChangeTitle(WebCore::DocumentLoader*); |
|
131 virtual void didChangeTitle(WebCore::DocumentLoader*); |
|
132 virtual void committedLoad(WebCore::DocumentLoader*, const char*, int); |
|
133 virtual void finishedLoading(WebCore::DocumentLoader*); |
|
134 virtual void updateGlobalHistory(); |
|
135 virtual void updateGlobalHistoryRedirectLinks(); |
|
136 virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const; |
|
137 virtual void dispatchDidAddBackForwardItem(WebCore::HistoryItem*) const; |
|
138 virtual void dispatchDidRemoveBackForwardItem(WebCore::HistoryItem*) const; |
|
139 virtual void dispatchDidChangeBackForwardIndex() const; |
|
140 virtual void didDisplayInsecureContent(); |
|
141 virtual void didRunInsecureContent(WebCore::SecurityOrigin*); |
|
142 virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&); |
|
143 virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&); |
|
144 virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&); |
|
145 virtual WebCore::ResourceError interruptForPolicyChangeError(const WebCore::ResourceRequest&); |
|
146 virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&); |
|
147 virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&); |
|
148 virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&); |
|
149 virtual bool shouldFallBack(const WebCore::ResourceError&); |
|
150 virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; |
|
151 virtual bool canShowMIMEType(const WebCore::String& MIMEType) const; |
|
152 virtual bool representationExistsForURLScheme(const WebCore::String& URLScheme) const; |
|
153 virtual WebCore::String generatedMIMETypeForURLScheme(const WebCore::String& URLScheme) const; |
|
154 virtual void frameLoadCompleted(); |
|
155 virtual void saveViewStateToItem(WebCore::HistoryItem*); |
|
156 virtual void restoreViewState(); |
|
157 virtual void provisionalLoadStarted(); |
|
158 virtual void didFinishLoad(); |
|
159 virtual void prepareForDataSourceReplacement(); |
|
160 virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader( |
|
161 const WebCore::ResourceRequest&, const WebCore::SubstituteData&); |
|
162 virtual void setTitle(const WebCore::String& title, const WebCore::KURL&); |
|
163 virtual WebCore::String userAgent(const WebCore::KURL&); |
|
164 virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*); |
|
165 virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*); |
|
166 virtual void transitionToCommittedForNewPage(); |
|
167 virtual bool canCachePage() const; |
|
168 virtual void download( |
|
169 WebCore::ResourceHandle*, const WebCore::ResourceRequest&, |
|
170 const WebCore::ResourceRequest& initialRequest, |
|
171 const WebCore::ResourceResponse&); |
|
172 virtual PassRefPtr<WebCore::Frame> createFrame( |
|
173 const WebCore::KURL& url, const WebCore::String& name, |
|
174 WebCore::HTMLFrameOwnerElement* ownerElement, |
|
175 const WebCore::String& referrer, bool allowsScrolling, |
|
176 int marginWidth, int marginHeight); |
|
177 virtual void didTransferChildFrameToNewDocument(); |
|
178 virtual PassRefPtr<WebCore::Widget> createPlugin( |
|
179 const WebCore::IntSize&, WebCore::HTMLPlugInElement*, const WebCore::KURL&, |
|
180 const Vector<WebCore::String>&, const Vector<WebCore::String>&, |
|
181 const WebCore::String&, bool loadManually); |
|
182 virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget); |
|
183 virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget( |
|
184 const WebCore::IntSize&, |
|
185 WebCore::HTMLAppletElement*, |
|
186 const WebCore::KURL& /* base_url */, |
|
187 const Vector<WebCore::String>& paramNames, |
|
188 const Vector<WebCore::String>& paramValues); |
|
189 virtual WebCore::ObjectContentType objectContentType( |
|
190 const WebCore::KURL& url, const WebCore::String& mimeType); |
|
191 virtual WebCore::String overrideMediaType() const; |
|
192 virtual void didPerformFirstNavigation() const; |
|
193 virtual void registerForIconNotification(bool listen = true); |
|
194 virtual void didChangeScrollOffset(); |
|
195 virtual bool allowJavaScript(bool enabledPerSettings); |
|
196 virtual bool allowPlugins(bool enabledPerSettings); |
|
197 virtual bool allowImages(bool enabledPerSettings); |
|
198 virtual void didNotAllowScript(); |
|
199 virtual void didNotAllowPlugins(); |
|
200 |
|
201 private: |
|
202 void makeDocumentView(); |
|
203 |
|
204 // Given a NavigationAction, determine the associated WebNavigationPolicy. |
|
205 // For example, a middle click means "open in background tab". |
|
206 static bool actionSpecifiesNavigationPolicy( |
|
207 const WebCore::NavigationAction& action, WebNavigationPolicy* policy); |
|
208 |
|
209 PassOwnPtr<WebPluginLoadObserver> pluginLoadObserver(); |
|
210 |
|
211 // The WebFrame that owns this object and manages its lifetime. Therefore, |
|
212 // the web frame object is guaranteed to exist. |
|
213 WebFrameImpl* m_webFrame; |
|
214 |
|
215 // True if makeRepresentation was called. We don't actually have a concept |
|
216 // of a "representation", but we need to know when we're expected to have one. |
|
217 // See finishedLoading(). |
|
218 bool m_hasRepresentation; |
|
219 |
|
220 // Used to help track client redirects. When a provisional load starts, it |
|
221 // has no redirects in its chain. But in the case of client redirects, we want |
|
222 // to add that initial load as a redirect. When we get a new provisional load |
|
223 // and the dest URL matches that load, we know that it was the result of a |
|
224 // previous client redirect and the source should be added as a redirect. |
|
225 // Both should be empty if unused. |
|
226 WebCore::KURL m_expectedClientRedirectSrc; |
|
227 WebCore::KURL m_expectedClientRedirectDest; |
|
228 |
|
229 // Contains a pointer to the plugin widget. |
|
230 RefPtr<WebPluginContainerImpl> m_pluginWidget; |
|
231 |
|
232 // Indicates if we need to send over the initial notification to the plugin |
|
233 // which specifies that the plugin should be ready to accept data. |
|
234 bool m_sentInitialResponseToPlugin; |
|
235 |
|
236 // The navigation policy to use for the next call to dispatchCreatePage. |
|
237 WebNavigationPolicy m_nextNavigationPolicy; |
|
238 }; |
|
239 |
|
240 } // namespace WebKit |
|
241 |
|
242 #endif |