Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: webkit/api/src/FrameLoaderClientImpl.cpp

Issue 341030: Moves webview_impl.cc, webframe_impl.cc and webframeloaderclient_impl.cc into... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/api/src/FrameLoaderClientImpl.h ('k') | webkit/api/src/InspectorClientImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 /*
2 // Use of this source code is governed by a BSD-style license that can be 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 // found in the LICENSE file. 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 */
4 30
5 #include "config.h" 31 #include "config.h"
32 #include "FrameLoaderClientImpl.h"
6 33
7 #include "Chrome.h" 34 #include "Chrome.h"
8 #include "CString.h" 35 #include "CString.h"
9 #include "Document.h" 36 #include "Document.h"
10 #include "DocumentLoader.h" 37 #include "DocumentLoader.h"
11 #include "HTMLAppletElement.h" 38 #include "HTMLAppletElement.h"
12 #include "HTMLFormElement.h" // needed by FormState.h 39 #include "HTMLFormElement.h" // needed by FormState.h
13 #include "HTMLNames.h" 40 #include "HTMLNames.h"
14 #include "FormState.h" 41 #include "FormState.h"
15 #include "FrameLoader.h" 42 #include "FrameLoader.h"
16 #include "FrameLoadRequest.h" 43 #include "FrameLoadRequest.h"
17 #include "HitTestResult.h" 44 #include "HitTestResult.h"
18 #include "MIMETypeRegistry.h" 45 #include "MIMETypeRegistry.h"
19 #include "MouseEvent.h" 46 #include "MouseEvent.h"
20 #include "Page.h" 47 #include "Page.h"
21 #include "PlatformString.h" 48 #include "PlatformString.h"
22 #include "PluginData.h" 49 #include "PluginData.h"
23 #include "StringExtras.h" 50 #include "StringExtras.h"
51 #include "WebForm.h"
52 #include "WebFrameClient.h"
53 #include "WebFrameImpl.h"
54 #include "WebNode.h"
55 #include "WebPlugin.h"
56 #include "WebPluginParams.h"
57 #include "WebSecurityOrigin.h"
58 #include "WebURL.h"
59 #include "WebURLError.h"
60 #include "WebVector.h"
61 #include "WebViewClient.h"
62 #include "WebViewImpl.h"
63 #include "WebDataSourceImpl.h"
64 #include "WebPluginContainerImpl.h"
65 #include "WebPluginLoadObserver.h"
24 #include "WindowFeatures.h" 66 #include "WindowFeatures.h"
25 #undef LOG 67 #include "WrappedResourceRequest.h"
68 #include "WrappedResourceResponse.h"
26 69
70 // FIXME: remove these
71 #include "googleurl/src/gurl.h"
27 #include "net/base/mime_util.h" 72 #include "net/base/mime_util.h"
28 #include "webkit/api/public/WebForm.h"
29 #include "webkit/api/public/WebFrameClient.h"
30 #include "webkit/api/public/WebNode.h"
31 #include "webkit/api/public/WebPlugin.h"
32 #include "webkit/api/public/WebPluginParams.h"
33 #include "webkit/api/public/WebSecurityOrigin.h"
34 #include "webkit/api/public/WebURL.h"
35 #include "webkit/api/public/WebURLError.h"
36 #include "webkit/api/public/WebVector.h"
37 #include "webkit/api/public/WebViewClient.h"
38 #include "webkit/api/src/WebDataSourceImpl.h"
39 #include "webkit/api/src/WebPluginContainerImpl.h"
40 #include "webkit/api/src/WebPluginLoadObserver.h"
41 #include "webkit/api/src/WrappedResourceRequest.h"
42 #include "webkit/api/src/WrappedResourceResponse.h"
43 #include "webkit/glue/glue_util.h" 73 #include "webkit/glue/glue_util.h"
44 #include "webkit/glue/webdevtoolsagent_impl.h" 74 #include "webkit/glue/webdevtoolsagent_impl.h"
45 #include "webkit/glue/webframe_impl.h"
46 #include "webkit/glue/webframeloaderclient_impl.h"
47 #include "webkit/glue/webkit_glue.h" 75 #include "webkit/glue/webkit_glue.h"
48 #include "webkit/glue/webview_impl.h"
49 76
50 using namespace WebCore; 77 using namespace WebCore;
51 78
52 using WebKit::WebData; 79 namespace WebKit {
53 using WebKit::WebDataSourceImpl;
54 using WebKit::WebNavigationType;
55 using WebKit::WebNavigationPolicy;
56 using WebKit::WebNode;
57 using WebKit::WebPlugin;
58 using WebKit::WebPluginContainerImpl;
59 using WebKit::WebPluginLoadObserver;
60 using WebKit::WebPluginParams;
61 using WebKit::WebString;
62 using WebKit::WebURL;
63 using WebKit::WebURLError;
64 using WebKit::WebURLRequest;
65 using WebKit::WebVector;
66 using WebKit::WrappedResourceRequest;
67 using WebKit::WrappedResourceResponse;
68 80
69 // Domain for internal error codes. 81 // Domain for internal error codes.
70 static const char kInternalErrorDomain[] = "WebKit"; 82 static const char internalErrorDomain[] = "WebKit";
71 83
72 // An internal error code. Used to note a policy change error resulting from 84 // An internal error code. Used to note a policy change error resulting from
73 // dispatchDecidePolicyForMIMEType not passing the PolicyUse option. 85 // dispatchDecidePolicyForMIMEType not passing the PolicyUse option.
74 enum { 86 enum {
75 ERR_POLICY_CHANGE = -10000, 87 PolicyChangeError = -10000,
76 }; 88 };
77 89
78 static void CopyStringVector( 90 FrameLoaderClientImpl::FrameLoaderClientImpl(WebFrameImpl* frame)
79 const Vector<String>& input, WebVector<WebString>* output) { 91 : m_webFrame(frame)
80 WebVector<WebString> result(input.size()); 92 , m_hasRepresentation(false)
81 for (size_t i = 0; i < input.size(); ++i) 93 , m_sentInitialResponseToPlugin(false)
82 result[i] = webkit_glue::StringToWebString(input[i]); 94 , m_nextNavigationPolicy(WebNavigationPolicyIgnore) {
83 output->swap(result);
84 } 95 }
85 96
86 WebFrameLoaderClient::WebFrameLoaderClient(WebFrameImpl* frame) 97 FrameLoaderClientImpl::~FrameLoaderClientImpl() {
87 : webframe_(frame),
88 has_representation_(false),
89 sent_initial_response_to_plugin_(false),
90 next_navigation_policy_(WebKit::WebNavigationPolicyIgnore) {
91 } 98 }
92 99
93 WebFrameLoaderClient::~WebFrameLoaderClient() { 100 void FrameLoaderClientImpl::frameLoaderDestroyed()
101 {
102 // When the WebFrame was created, it had an extra reference given to it on
103 // behalf of the Frame. Since the WebFrame owns us, this extra ref also
104 // serves to keep us alive until the FrameLoader is done with us. The
105 // FrameLoader calls this method when it's going away. Therefore, we balance
106 // out that extra reference, which may cause 'this' to be deleted.
107 m_webFrame->closing();
108 m_webFrame->deref();
94 } 109 }
95 110
96 void WebFrameLoaderClient::frameLoaderDestroyed() { 111 void FrameLoaderClientImpl::windowObjectCleared()
97 // When the WebFrame was created, it had an extra reference given to it on 112 {
98 // behalf of the Frame. Since the WebFrame owns us, this extra ref also 113 if (m_webFrame->client())
99 // serves to keep us alive until the FrameLoader is done with us. The 114 m_webFrame->client()->didClearWindowObject(m_webFrame);
100 // FrameLoader calls this method when it's going away. Therefore, we balance 115
101 // out that extra reference, which may cause 'this' to be deleted. 116 WebViewImpl* webview = m_webFrame->viewImpl();
102 webframe_->Closing(); 117 if (webview) {
103 webframe_->deref(); 118 WebDevToolsAgentImpl* toolsAgent = webview->devToolsAgentImpl();
119 if (toolsAgent)
120 toolsAgent->WindowObjectCleared(m_webFrame);
121 }
104 } 122 }
105 123
106 void WebFrameLoaderClient::windowObjectCleared() { 124 void FrameLoaderClientImpl::documentElementAvailable()
107 if (webframe_->client()) 125 {
108 webframe_->client()->didClearWindowObject(webframe_); 126 if (m_webFrame->client())
109 127 m_webFrame->client()->didCreateDocumentElement(m_webFrame);
110 WebViewImpl* webview = webframe_->GetWebViewImpl();
111 if (webview) {
112 WebDevToolsAgentImpl* tools_agent = webview->GetWebDevToolsAgentImpl();
113 if (tools_agent)
114 tools_agent->WindowObjectCleared(webframe_);
115 }
116 } 128 }
117 129
118 void WebFrameLoaderClient::documentElementAvailable() { 130 void FrameLoaderClientImpl::didCreateScriptContextForFrame()
119 if (webframe_->client()) 131 {
120 webframe_->client()->didCreateDocumentElement(webframe_); 132 if (m_webFrame->client())
133 m_webFrame->client()->didCreateScriptContext(m_webFrame);
121 } 134 }
122 135
123 void WebFrameLoaderClient::didCreateScriptContextForFrame() { 136 void FrameLoaderClientImpl::didDestroyScriptContextForFrame()
124 if (webframe_->client()) 137 {
125 webframe_->client()->didCreateScriptContext(webframe_); 138 if (m_webFrame->client())
139 m_webFrame->client()->didDestroyScriptContext(m_webFrame);
126 } 140 }
127 141
128 void WebFrameLoaderClient::didDestroyScriptContextForFrame() { 142 void FrameLoaderClientImpl::didCreateIsolatedScriptContext()
129 if (webframe_->client()) 143 {
130 webframe_->client()->didDestroyScriptContext(webframe_); 144 if (m_webFrame->client())
145 m_webFrame->client()->didCreateIsolatedScriptContext(m_webFrame);
131 } 146 }
132 147
133 void WebFrameLoaderClient::didCreateIsolatedScriptContext() { 148 void FrameLoaderClientImpl::didPerformFirstNavigation() const
134 if (webframe_->client()) 149 {
135 webframe_->client()->didCreateIsolatedScriptContext(webframe_);
136 } 150 }
137 151
138 void WebFrameLoaderClient::didPerformFirstNavigation() const { 152 void FrameLoaderClientImpl::registerForIconNotification(bool)
153 {
139 } 154 }
140 155
141 void WebFrameLoaderClient::registerForIconNotification(bool listen){ 156 bool FrameLoaderClientImpl::hasWebView() const
157 {
158 return m_webFrame->viewImpl() != 0;
142 } 159 }
143 160
144 bool WebFrameLoaderClient::hasWebView() const { 161 bool FrameLoaderClientImpl::hasFrameView() const
145 return webframe_->GetWebViewImpl() != NULL; 162 {
163 // The Mac port has this notion of a WebFrameView, which seems to be
164 // some wrapper around an NSView. Since our equivalent is HWND, I guess
165 // we have a "frameview" whenever we have the toplevel HWND.
166 return m_webFrame->viewImpl() != 0;
146 } 167 }
147 168
148 bool WebFrameLoaderClient::hasFrameView() const { 169 void FrameLoaderClientImpl::makeDocumentView()
149 // The Mac port has this notion of a WebFrameView, which seems to be 170 {
150 // some wrapper around an NSView. Since our equivalent is HWND, I guess 171 m_webFrame->createFrameView();
151 // we have a "frameview" whenever we have the toplevel HWND.
152 return webframe_->GetWebViewImpl() != NULL;
153 } 172 }
154 173
155 void WebFrameLoaderClient::makeDocumentView() { 174 void FrameLoaderClientImpl::makeRepresentation(DocumentLoader*)
156 webframe_->CreateFrameView(); 175 {
176 m_hasRepresentation = true;
157 } 177 }
158 178
159 void WebFrameLoaderClient::makeRepresentation(DocumentLoader*) { 179 void FrameLoaderClientImpl::forceLayout()
160 has_representation_ = true; 180 {
181 // FIXME
161 } 182 }
162 183
163 void WebFrameLoaderClient::forceLayout() { 184 void FrameLoaderClientImpl::forceLayoutForNonHTML()
164 // FIXME 185 {
165 } 186 // FIXME
166 void WebFrameLoaderClient::forceLayoutForNonHTML() {
167 // FIXME
168 } 187 }
169 188
170 void WebFrameLoaderClient::setCopiesOnScroll() { 189 void FrameLoaderClientImpl::setCopiesOnScroll()
171 // FIXME 190 {
191 // FIXME
172 } 192 }
173 193
174 void WebFrameLoaderClient::detachedFromParent2() { 194 void FrameLoaderClientImpl::detachedFromParent2()
175 // Nothing to do here. 195 {
196 // Nothing to do here.
176 } 197 }
177 198
178 void WebFrameLoaderClient::detachedFromParent3() { 199 void FrameLoaderClientImpl::detachedFromParent3()
179 // Close down the proxy. The purpose of this change is to make the 200 {
180 // call to ScriptController::clearWindowShell a no-op when called from 201 // Close down the proxy. The purpose of this change is to make the
181 // Frame::pageDestroyed. Without this change, this call to clearWindowShell 202 // call to ScriptController::clearWindowShell a no-op when called from
182 // will cause a crash. If you remove/modify this, just ensure that you can 203 // Frame::pageDestroyed. Without this change, this call to clearWindowShell
183 // go to a page and then navigate to a new page without getting any asserts 204 // will cause a crash. If you remove/modify this, just ensure that you can
184 // or crashes. 205 // go to a page and then navigate to a new page without getting any asserts
185 webframe_->frame()->script()->proxy()->clearForClose(); 206 // or crashes.
207 m_webFrame->frame()->script()->proxy()->clearForClose();
186 } 208 }
187 209
188 // This function is responsible for associating the |identifier| with a given 210 // This function is responsible for associating the |identifier| with a given
189 // subresource load. The following functions that accept an |identifier| are 211 // subresource load. The following functions that accept an |identifier| are
190 // called for each subresource, so they should not be dispatched to the 212 // called for each subresource, so they should not be dispatched to the
191 // WebFrame. 213 // WebFrame.
192 void WebFrameLoaderClient::assignIdentifierToInitialRequest( 214 void FrameLoaderClientImpl::assignIdentifierToInitialRequest(
193 unsigned long identifier, DocumentLoader* loader, 215 unsigned long identifier, DocumentLoader* loader,
194 const ResourceRequest& request) { 216 const ResourceRequest& request)
195 if (webframe_->client()) { 217 {
196 WrappedResourceRequest webreq(request); 218 if (m_webFrame->client()) {
197 webframe_->client()->assignIdentifierToRequest( 219 WrappedResourceRequest webreq(request);
198 webframe_, identifier, webreq); 220 m_webFrame->client()->assignIdentifierToRequest(
199 } 221 m_webFrame, identifier, webreq);
222 }
200 } 223 }
201 224
202 // Determines whether the request being loaded by |loader| is a frame or a 225 // Determines whether the request being loaded by |loader| is a frame or a
203 // subresource. A subresource in this context is anything other than a frame -- 226 // subresource. A subresource in this context is anything other than a frame --
204 // this includes images and xmlhttp requests. It is important to note that a 227 // this includes images and xmlhttp requests. It is important to note that a
205 // subresource is NOT limited to stuff loaded through the frame's subresource 228 // subresource is NOT limited to stuff loaded through the frame's subresource
206 // loader. Synchronous xmlhttp requests for example, do not go through the 229 // loader. Synchronous xmlhttp requests for example, do not go through the
207 // subresource loader, but we still label them as TargetIsSubResource. 230 // subresource loader, but we still label them as TargetIsSubResource.
208 // 231 //
209 // The important edge cases to consider when modifying this function are 232 // The important edge cases to consider when modifying this function are
210 // how synchronous resource loads are treated during load/unload threshold. 233 // how synchronous resource loads are treated during load/unload threshold.
211 static ResourceRequest::TargetType DetermineTargetTypeFromLoader( 234 static ResourceRequest::TargetType determineTargetTypeFromLoader(
212 DocumentLoader* loader) { 235 DocumentLoader* loader)
213 if (loader == loader->frameLoader()->provisionalDocumentLoader()) { 236 {
214 if (loader->frameLoader()->isLoadingMainFrame()) { 237 if (loader == loader->frameLoader()->provisionalDocumentLoader()) {
215 return ResourceRequest::TargetIsMainFrame; 238 if (loader->frameLoader()->isLoadingMainFrame())
216 } else { 239 return ResourceRequest::TargetIsMainFrame;
217 return ResourceRequest::TargetIsSubFrame; 240 else
241 return ResourceRequest::TargetIsSubFrame;
218 } 242 }
219 } 243 return ResourceRequest::TargetIsSubResource;
220 return ResourceRequest::TargetIsSubResource;
221 } 244 }
222 245
223 void WebFrameLoaderClient::dispatchWillSendRequest( 246 void FrameLoaderClientImpl::dispatchWillSendRequest(
224 DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, 247 DocumentLoader* loader, unsigned long identifier, ResourceRequest& request,
225 const ResourceResponse& redirect_response) { 248 const ResourceResponse& redirectResponse)
249 {
250 if (loader) {
251 // We want to distinguish between a request for a document to be loaded into
252 // the main frame, a sub-frame, or the sub-objects in that document.
253 request.setTargetType(determineTargetTypeFromLoader(loader));
254 }
226 255
227 if (loader) { 256 // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document
228 // We want to distinguish between a request for a document to be loaded into 257 // with no URL. We don't like that, so we'll rename it to about:blank.
229 // the main frame, a sub-frame, or the sub-objects in that document. 258 if (request.url().isEmpty())
230 request.setTargetType(DetermineTargetTypeFromLoader(loader)); 259 request.setURL(KURL(ParsedURLString, "about:blank"));
231 } 260 if (request.firstPartyForCookies().isEmpty())
261 request.setFirstPartyForCookies(KURL(ParsedURLString, "about:blank"));
232 262
233 // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document 263 // Give the WebFrameClient a crack at the request.
234 // with no URL. We don't like that, so we'll rename it to about:blank. 264 if (m_webFrame->client()) {
235 if (request.url().isEmpty()) 265 WrappedResourceRequest webreq(request);
236 request.setURL(KURL(ParsedURLString, "about:blank")); 266 WrappedResourceResponse webresp(redirectResponse);
237 if (request.firstPartyForCookies().isEmpty()) 267 m_webFrame->client()->willSendRequest(
238 request.setFirstPartyForCookies(KURL(ParsedURLString, "about:blank")); 268 m_webFrame, identifier, webreq, webresp);
239 269 }
240 // Give the WebFrameClient a crack at the request.
241 if (webframe_->client()) {
242 WrappedResourceRequest webreq(request);
243 WrappedResourceResponse webresp(redirect_response);
244 webframe_->client()->willSendRequest(
245 webframe_, identifier, webreq, webresp);
246 }
247 } 270 }
248 271
249 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, 272 bool FrameLoaderClientImpl::shouldUseCredentialStorage(
250 unsigned long identifier) { 273 DocumentLoader*, unsigned long identifier)
251 // FIXME 274 {
252 // Intended to pass through to a method on the resource load delegate. 275 // FIXME
253 // If implemented, that method controls whether the browser should ask the 276 // Intended to pass through to a method on the resource load delegate.
254 // networking layer for a stored default credential for the page (say from 277 // If implemented, that method controls whether the browser should ask the
255 // the Mac OS keychain). If the method returns false, the user should be 278 // networking layer for a stored default credential for the page (say from
256 // presented with an authentication challenge whether or not the networking 279 // the Mac OS keychain). If the method returns false, the user should be
257 // layer has a credential stored. 280 // presented with an authentication challenge whether or not the networking
258 // This returns true for backward compatibility: the ability to override the 281 // layer has a credential stored.
259 // system credential store is new. (Actually, not yet fully implemented in 282 // This returns true for backward compatibility: the ability to override the
260 // WebKit, as of this writing.) 283 // system credential store is new. (Actually, not yet fully implemented in
261 return true; 284 // WebKit, as of this writing.)
285 return true;
262 } 286 }
263 287
264 void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge( 288 void FrameLoaderClientImpl::dispatchDidReceiveAuthenticationChallenge(
265 DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) { 289 DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
266 // FIXME 290 {
291 // FIXME
267 } 292 }
268 293
269 void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge( 294 void FrameLoaderClientImpl::dispatchDidCancelAuthenticationChallenge(
270 DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) { 295 DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
271 // FIXME 296 {
297 // FIXME
272 } 298 }
273 299
274 void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, 300 void FrameLoaderClientImpl::dispatchDidReceiveResponse(DocumentLoader* loader,
275 unsigned long identifier, 301 unsigned long identifier,
276 const ResourceResponse& response) { 302 const ResourceResponse& response)
277 if (webframe_->client()) { 303 {
278 WrappedResourceResponse webresp(response); 304 if (m_webFrame->client()) {
279 webframe_->client()->didReceiveResponse(webframe_, identifier, webresp); 305 WrappedResourceResponse webresp(response);
280 } 306 m_webFrame->client()->didReceiveResponse(m_webFrame, identifier, webresp);
307 }
281 } 308 }
282 309
283 void WebFrameLoaderClient::dispatchDidReceiveContentLength( 310 void FrameLoaderClientImpl::dispatchDidReceiveContentLength(
284 DocumentLoader* loader, 311 DocumentLoader* loader,
285 unsigned long identifier, 312 unsigned long identifier,
286 int length_received) { 313 int lengthReceived)
314 {
287 } 315 }
288 316
289 // Called when a particular resource load completes 317 // Called when a particular resource load completes
290 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, 318 void FrameLoaderClientImpl::dispatchDidFinishLoading(DocumentLoader* loader,
291 unsigned long identifier) { 319 unsigned long identifier)
292 if (webframe_->client()) 320 {
293 webframe_->client()->didFinishResourceLoad(webframe_, identifier); 321 if (m_webFrame->client())
322 m_webFrame->client()->didFinishResourceLoad(m_webFrame, identifier);
294 } 323 }
295 324
296 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, 325 void FrameLoaderClientImpl::dispatchDidFailLoading(DocumentLoader* loader,
297 unsigned long identifier, 326 unsigned long identifier,
298 const ResourceError& error) { 327 const ResourceError& error)
299 if (webframe_->client()) { 328 {
300 webframe_->client()->didFailResourceLoad( 329 if (m_webFrame->client())
301 webframe_, identifier, webkit_glue::ResourceErrorToWebURLError(error)); 330 m_webFrame->client()->didFailResourceLoad(m_webFrame, identifier, error);
302 }
303 } 331 }
304 332
305 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { 333 void FrameLoaderClientImpl::dispatchDidFinishDocumentLoad()
306 // A frame may be reused. This call ensures we don't hold on to our password 334 {
307 // listeners and their associated HTMLInputElements. 335 // A frame may be reused. This call ensures we don't hold on to our password
308 webframe_->ClearPasswordListeners(); 336 // listeners and their associated HTMLInputElements.
337 m_webFrame->clearPasswordListeners();
309 338
310 if (webframe_->client()) 339 if (m_webFrame->client())
311 webframe_->client()->didFinishDocumentLoad(webframe_); 340 m_webFrame->client()->didFinishDocumentLoad(m_webFrame);
312 } 341 }
313 342
314 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( 343 bool FrameLoaderClientImpl::dispatchDidLoadResourceFromMemoryCache(
315 DocumentLoader* loader, 344 DocumentLoader* loader,
316 const ResourceRequest& request, 345 const ResourceRequest& request,
317 const ResourceResponse& response, 346 const ResourceResponse& response,
318 int length) { 347 int length)
319 if (webframe_->client()) { 348 {
320 WrappedResourceRequest webreq(request); 349 if (m_webFrame->client()) {
321 WrappedResourceResponse webresp(response); 350 WrappedResourceRequest webreq(request);
322 webframe_->client()->didLoadResourceFromMemoryCache( 351 WrappedResourceResponse webresp(response);
323 webframe_, webreq, webresp); 352 m_webFrame->client()->didLoadResourceFromMemoryCache(
324 } 353 m_webFrame, webreq, webresp);
325 return false; // Do not suppress remaining notifications 354 }
355 return false; // Do not suppress remaining notifications
326 } 356 }
327 357
328 void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest( 358 void FrameLoaderClientImpl::dispatchDidLoadResourceByXMLHttpRequest(
329 unsigned long identifier, 359 unsigned long identifier,
330 const ScriptString& source) { 360 const ScriptString& source)
361 {
331 } 362 }
332 363
333 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() { 364 void FrameLoaderClientImpl::dispatchDidHandleOnloadEvents()
334 if (webframe_->client()) 365 {
335 webframe_->client()->didHandleOnloadEvents(webframe_); 366 if (m_webFrame->client())
367 m_webFrame->client()->didHandleOnloadEvents(m_webFrame);
336 } 368 }
337 369
338 // Redirect Tracking 370 // Redirect Tracking
339 // ================= 371 // =================
340 // We want to keep track of the chain of redirects that occur during page 372 // We want to keep track of the chain of redirects that occur during page
341 // loading. There are two types of redirects, server redirects which are HTTP 373 // loading. There are two types of redirects, server redirects which are HTTP
342 // response codes, and client redirects which are document.location= and meta 374 // response codes, and client redirects which are document.location= and meta
343 // refreshes. 375 // refreshes.
344 // 376 //
345 // This outlines the callbacks that we get in different redirect situations, 377 // This outlines the callbacks that we get in different redirect situations,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // -- click on anchor href 440 // -- click on anchor href
409 // dispatchDidCancelClientRedirect() -> clears expected redirect 441 // dispatchDidCancelClientRedirect() -> clears expected redirect
410 // dispatchDidStartProvisionalLoad() -> adds 1#anchor source 442 // dispatchDidStartProvisionalLoad() -> adds 1#anchor source
411 // dispatchDidCommitLoad() -> DISPATCHES 1#anchor 443 // dispatchDidCommitLoad() -> DISPATCHES 1#anchor
412 // dispatchWillPerformClientRedirect() -> saves exp. source (1#anchor) 444 // dispatchWillPerformClientRedirect() -> saves exp. source (1#anchor)
413 // -- redirect timer fires 445 // -- redirect timer fires
414 // dispatchDidStartProvisionalLoad() -> appends 1#anchor (src) and 1 (dest) 446 // dispatchDidStartProvisionalLoad() -> appends 1#anchor (src) and 1 (dest)
415 // dispatchDidCancelClientRedirect() -> clears expected redirect 447 // dispatchDidCancelClientRedirect() -> clears expected redirect
416 // dispatchDidCommitLoad() -> DISPATCHES 1#anchor + 1 448 // dispatchDidCommitLoad() -> DISPATCHES 1#anchor + 1
417 // 449 //
418 void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad() { 450 void FrameLoaderClientImpl::dispatchDidReceiveServerRedirectForProvisionalLoad()
419 WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); 451 {
420 if (!ds) { 452 WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl();
421 // Got a server redirect when there is no provisional DS! 453 if (!ds) {
422 ASSERT_NOT_REACHED(); 454 // Got a server redirect when there is no provisional DS!
423 return; 455 ASSERT_NOT_REACHED();
424 } 456 return;
425 457 }
426 // The server redirect may have been blocked. 458
427 if (ds->request().isNull()) 459 // The server redirect may have been blocked.
428 return; 460 if (ds->request().isNull())
429 461 return;
430 // A provisional load should have started already, which should have put an 462
431 // entry in our redirect chain. 463 // A provisional load should have started already, which should have put an
432 ASSERT(ds->hasRedirectChain()); 464 // entry in our redirect chain.
433 465 ASSERT(ds->hasRedirectChain());
434 // The URL of the destination is on the provisional data source. We also need 466
435 // to update the redirect chain to account for this addition (we do this 467 // The URL of the destination is on the provisional data source. We also need
436 // before the callback so the callback can look at the redirect chain to see 468 // to update the redirect chain to account for this addition (we do this
437 // what happened). 469 // before the callback so the callback can look at the redirect chain to see
438 ds->appendRedirect(webkit_glue::WebURLToKURL(ds->request().url())); 470 // what happened).
439 471 ds->appendRedirect(ds->request().url());
440 if (webframe_->client()) 472
441 webframe_->client()->didReceiveServerRedirectForProvisionalLoad(webframe_); 473 if (m_webFrame->client())
474 m_webFrame->client()->didReceiveServerRedirectForProvisionalLoad(m_webFrame);
442 } 475 }
443 476
444 // Called on both success and failure of a client redirect. 477 // Called on both success and failure of a client redirect.
445 void WebFrameLoaderClient::dispatchDidCancelClientRedirect() { 478 void FrameLoaderClientImpl::dispatchDidCancelClientRedirect()
446 // No longer expecting a client redirect. 479 {
447 if (webframe_->client()) { 480 // No longer expecting a client redirect.
448 expected_client_redirect_src_ = KURL(); 481 if (m_webFrame->client()) {
449 expected_client_redirect_dest_ = KURL(); 482 m_expectedClientRedirectSrc = KURL();
450 webframe_->client()->didCancelClientRedirect(webframe_); 483 m_expectedClientRedirectDest = KURL();
451 } 484 m_webFrame->client()->didCancelClientRedirect(m_webFrame);
452 485 }
453 // No need to clear the redirect chain, since that data source has already 486
454 // been deleted by the time this function is called. 487 // No need to clear the redirect chain, since that data source has already
455 } 488 // been deleted by the time this function is called.
456 489 }
457 void WebFrameLoaderClient::dispatchWillPerformClientRedirect( 490
491 void FrameLoaderClientImpl::dispatchWillPerformClientRedirect(
458 const KURL& url, 492 const KURL& url,
459 double interval, 493 double interval,
460 double fire_date) { 494 double fireDate)
461 // Tells dispatchDidStartProvisionalLoad that if it sees this item it is a 495 {
462 // redirect and the source item should be added as the start of the chain. 496 // Tells dispatchDidStartProvisionalLoad that if it sees this item it is a
463 expected_client_redirect_src_ = webkit_glue::WebURLToKURL(webframe_->url()); 497 // redirect and the source item should be added as the start of the chain.
464 expected_client_redirect_dest_ = url; 498 m_expectedClientRedirectSrc = m_webFrame->url();
465 499 m_expectedClientRedirectDest = url;
466 // TODO(timsteele): bug 1135512. Webkit does not properly notify us of 500
467 // cancelling http > file client redirects. Since the FrameLoader's policy 501 // FIXME: bug 1135512. Webkit does not properly notify us of cancelling
468 // is to never carry out such a navigation anyway, the best thing we can do 502 // http > file client redirects. Since the FrameLoader's policy is to never
469 // for now to not get confused is ignore this notification. 503 // carry out such a navigation anyway, the best thing we can do for now to
470 if (expected_client_redirect_dest_.isLocalFile() && 504 // not get confused is ignore this notification.
471 expected_client_redirect_src_.protocolInHTTPFamily()) { 505 if (m_expectedClientRedirectDest.isLocalFile()
472 expected_client_redirect_src_ = KURL(); 506 && m_expectedClientRedirectSrc.protocolInHTTPFamily()) {
473 expected_client_redirect_dest_ = KURL(); 507 m_expectedClientRedirectSrc = KURL();
474 return; 508 m_expectedClientRedirectDest = KURL();
475 } 509 return;
476 510 }
477 if (webframe_->client()) { 511
478 webframe_->client()->willPerformClientRedirect( 512 if (m_webFrame->client()) {
479 webframe_, 513 m_webFrame->client()->willPerformClientRedirect(
480 webkit_glue::KURLToWebURL(expected_client_redirect_src_), 514 m_webFrame,
481 webkit_glue::KURLToWebURL(expected_client_redirect_dest_), 515 m_expectedClientRedirectSrc,
482 static_cast<unsigned int>(interval), 516 m_expectedClientRedirectDest,
483 static_cast<unsigned int>(fire_date)); 517 static_cast<unsigned int>(interval),
484 } 518 static_cast<unsigned int>(fireDate));
485 } 519 }
486 520 }
487 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() { 521
488 // Anchor fragment navigations are not normal loads, so we need to synthesize 522 void FrameLoaderClientImpl::dispatchDidChangeLocationWithinPage()
489 // some events for our delegate. 523 {
490 WebViewImpl* webview = webframe_->GetWebViewImpl(); 524 // Anchor fragment navigations are not normal loads, so we need to synthesize
491 if (webview->client()) 525 // some events for our delegate.
492 webview->client()->didStartLoading(); 526 WebViewImpl* webView = m_webFrame->viewImpl();
493 527 if (webView->client())
494 WebDataSourceImpl* ds = webframe_->GetDataSourceImpl(); 528 webView->client()->didStartLoading();
495 ASSERT(ds); // Should not be null when navigating to a reference fragment! 529
496 if (ds) { 530 WebDataSourceImpl* ds = m_webFrame->dataSourceImpl();
497 KURL url = webkit_glue::WebURLToKURL(ds->request().url()); 531 ASSERT(ds); // Should not be null when navigating to a reference fragment!
498 KURL chain_end = ds->endOfRedirectChain(); 532 if (ds) {
499 ds->clearRedirectChain(); 533 KURL url = ds->request().url();
500 534 KURL chainEnd;
501 // Figure out if this location change is because of a JS-initiated client 535 if (ds->hasRedirectChain()) {
502 // redirect (e.g onload/setTimeout document.location.href=). 536 chainEnd = ds->endOfRedirectChain();
503 // TODO(timsteele): (bugs 1085325, 1046841) We don't get proper redirect 537 ds->clearRedirectChain();
504 // performed/cancelled notifications across anchor navigations, so the 538 }
505 // other redirect-tracking code in this class (see dispatch*ClientRedirect() 539
506 // and dispatchDidStartProvisionalLoad) is insufficient to catch and 540 // Figure out if this location change is because of a JS-initiated
507 // properly flag these transitions. Once a proper fix for this bug is 541 // client redirect (e.g onload/setTimeout document.location.href=).
508 // identified and applied the following block may no longer be required. 542 // FIXME: (bugs 1085325, 1046841) We don't get proper redirect
509 bool was_client_redirect = 543 // performed/cancelled notifications across anchor navigations, so the
510 (url == expected_client_redirect_dest_ && 544 // other redirect-tracking code in this class (see
511 chain_end == expected_client_redirect_src_) || 545 // dispatch*ClientRedirect() and dispatchDidStartProvisionalLoad) is
512 !webframe_->isProcessingUserGesture(); 546 // insufficient to catch and properly flag these transitions. Once a
513 547 // proper fix for this bug is identified and applied the following
514 if (was_client_redirect) { 548 // block may no longer be required.
515 if (webframe_->client()) { 549 bool wasClientRedirect =
516 webframe_->client()->didCompleteClientRedirect( 550 (url == m_expectedClientRedirectDest && chainEnd == m_expectedClientRedirectSrc)
517 webframe_, webkit_glue::KURLToWebURL(chain_end)); 551 || !m_webFrame->isProcessingUserGesture();
518 } 552
519 ds->appendRedirect(chain_end); 553 if (wasClientRedirect) {
520 // Make sure we clear the expected redirect since we just effectively 554 if (m_webFrame->client())
521 // completed it. 555 m_webFrame->client()->didCompleteClientRedirect(m_webFrame, chainEnd);
522 expected_client_redirect_src_ = KURL(); 556 ds->appendRedirect(chainEnd);
523 expected_client_redirect_dest_ = KURL(); 557 // Make sure we clear the expected redirect since we just effectively
524 } 558 // completed it.
525 559 m_expectedClientRedirectSrc = KURL();
526 // Regardless of how we got here, we are navigating to a URL so we need to 560 m_expectedClientRedirectDest = KURL();
527 // add it to the redirect chain. 561 }
562
563 // Regardless of how we got here, we are navigating to a URL so we need to
564 // add it to the redirect chain.
565 ds->appendRedirect(url);
566 }
567
568 bool isNewNavigation;
569 webView->didCommitLoad(&isNewNavigation);
570 if (m_webFrame->client())
571 m_webFrame->client()->didChangeLocationWithinPage(m_webFrame, isNewNavigation);
572
573 if (webView->client())
574 webView->client()->didStopLoading();
575 }
576
577 void FrameLoaderClientImpl::dispatchWillClose()
578 {
579 if (m_webFrame->client())
580 m_webFrame->client()->willClose(m_webFrame);
581 }
582
583 void FrameLoaderClientImpl::dispatchDidReceiveIcon()
584 {
585 // The icon database is disabled, so this should never be called.
586 ASSERT_NOT_REACHED();
587 }
588
589 void FrameLoaderClientImpl::dispatchDidStartProvisionalLoad() {
590 // In case a redirect occurs, we need this to be set so that the redirect
591 // handling code can tell where the redirect came from. Server redirects
592 // will occur on the provisional load, so we need to keep track of the most
593 // recent provisional load URL.
594 // See dispatchDidReceiveServerRedirectForProvisionalLoad.
595 WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl();
596 if (!ds) {
597 ASSERT_NOT_REACHED();
598 return;
599 }
600 KURL url = ds->request().url();
601
602 // Since the provisional load just started, we should have not gotten
603 // any redirects yet.
604 ASSERT(!ds->hasRedirectChain());
605
606 // If this load is what we expected from a client redirect, treat it as a
607 // redirect from that original page. The expected redirect urls will be
608 // cleared by DidCancelClientRedirect.
609 bool completingClientRedirect = false;
610 if (m_expectedClientRedirectSrc.isValid()) {
611 // m_expectedClientRedirectDest could be something like
612 // "javascript:history.go(-1)" thus we need to exclude url starts with
613 // "javascript:". See bug: 1080873
614 ASSERT(m_expectedClientRedirectDest.protocolIs("javascript")
615 || m_expectedClientRedirectDest == url);
616 ds->appendRedirect(m_expectedClientRedirectSrc);
617 completingClientRedirect = true;
618 }
528 ds->appendRedirect(url); 619 ds->appendRedirect(url);
529 } 620
530 621 if (m_webFrame->client()) {
531 bool is_new_navigation; 622 // Whatever information didCompleteClientRedirect contains should only
532 webview->DidCommitLoad(&is_new_navigation); 623 // be considered relevant until the next provisional load has started.
533 if (webframe_->client()) { 624 // So we first tell the client that the load started, and then tell it
534 webframe_->client()->didChangeLocationWithinPage( 625 // about the client redirect the load is responsible for completing.
535 webframe_, is_new_navigation); 626 m_webFrame->client()->didStartProvisionalLoad(m_webFrame);
536 } 627 if (completingClientRedirect) {
537 628 m_webFrame->client()->didCompleteClientRedirect(
538 if (webview->client()) 629 m_webFrame, m_expectedClientRedirectSrc);
539 webview->client()->didStopLoading(); 630 }
540 } 631 }
541 632 }
542 void WebFrameLoaderClient::dispatchWillClose() { 633
543 if (webframe_->client()) 634 void FrameLoaderClientImpl::dispatchDidReceiveTitle(const String& title)
544 webframe_->client()->willClose(webframe_); 635 {
545 } 636 if (m_webFrame->client())
546 637 m_webFrame->client()->didReceiveTitle(m_webFrame, title);
547 void WebFrameLoaderClient::dispatchDidReceiveIcon() { 638 }
548 // The icon database is disabled, so this should never be called. 639
549 ASSERT_NOT_REACHED(); 640 void FrameLoaderClientImpl::dispatchDidCommitLoad()
550 } 641 {
551 642 WebViewImpl* webview = m_webFrame->viewImpl();
552 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { 643 bool isNewNavigation;
553 // In case a redirect occurs, we need this to be set so that the redirect 644 webview->didCommitLoad(&isNewNavigation);
554 // handling code can tell where the redirect came from. Server redirects 645
555 // will occur on the provisional load, so we need to keep track of the most 646 if (m_webFrame->client())
556 // recent provisional load URL. 647 m_webFrame->client()->didCommitProvisionalLoad(m_webFrame, isNewNavigation);
557 // See dispatchDidReceiveServerRedirectForProvisionalLoad. 648
558 WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); 649 WebDevToolsAgentImpl* toolsAgent = webview->devToolsAgentImpl();
559 if (!ds) { 650 if (toolsAgent)
560 ASSERT_NOT_REACHED(); 651 toolsAgent->DidCommitLoadForFrame(webview, m_webFrame, isNewNavigation);
561 return; 652 }
562 } 653
563 KURL url = webkit_glue::WebURLToKURL(ds->request().url()); 654 void FrameLoaderClientImpl::dispatchDidFailProvisionalLoad(
564 655 const ResourceError& error)
565 // Since the provisional load just started, we should have not gotten 656 {
566 // any redirects yet. 657
567 ASSERT(!ds->hasRedirectChain()); 658 // If a policy change occured, then we do not want to inform the plugin
568 659 // delegate. See http://b/907789 for details. FIXME: This means the
569 // If this load is what we expected from a client redirect, treat it as a 660 // plugin won't receive NPP_URLNotify, which seems like it could result in
570 // redirect from that original page. The expected redirect urls will be 661 // a memory leak in the plugin!!
571 // cleared by DidCancelClientRedirect. 662 if (error.domain() == internalErrorDomain
572 bool completing_client_redirect = false; 663 && error.errorCode() == PolicyChangeError) {
573 if (expected_client_redirect_src_.isValid()) { 664 m_webFrame->didFail(cancelledError(error.failingURL()), true);
574 // expected_client_redirect_dest_ could be something like 665 return;
575 // "javascript:history.go(-1)" thus we need to exclude url starts with 666 }
576 // "javascript:". See bug: 1080873 667
577 ASSERT(expected_client_redirect_dest_.protocolIs("javascript") || 668 OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver();
578 expected_client_redirect_dest_ == url); 669 m_webFrame->didFail(error, true);
579 ds->appendRedirect(expected_client_redirect_src_); 670 if (observer)
580 completing_client_redirect = true; 671 observer->didFailLoading(error);
581 } 672 }
582 ds->appendRedirect(url); 673
583 674 void FrameLoaderClientImpl::dispatchDidFailLoad(const ResourceError& error)
584 if (webframe_->client()) { 675 {
585 // As the comment for DidCompleteClientRedirect in webview_delegate.h 676 OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver();
586 // points out, whatever information its invocation contains should only 677 m_webFrame->didFail(error, false);
587 // be considered relevant until the next provisional load has started. 678 if (observer)
588 // So we first tell the delegate that the load started, and then tell it 679 observer->didFailLoading(error);
589 // about the client redirect the load is responsible for completing. 680
590 webframe_->client()->didStartProvisionalLoad(webframe_); 681 // Don't clear the redirect chain, this will happen in the middle of client
591 if (completing_client_redirect) 682 // redirects, and we need the context. The chain will be cleared when the
592 webframe_->client()->didCompleteClientRedirect( 683 // provisional load succeeds or fails, not the "real" one.
593 webframe_, webkit_glue::KURLToWebURL(expected_client_redirect_src_)); 684 }
594 } 685
595 } 686 void FrameLoaderClientImpl::dispatchDidFinishLoad()
596 687 {
597 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) { 688 OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver();
598 if (webframe_->client()) { 689
599 webframe_->client()->didReceiveTitle( 690 if (m_webFrame->client())
600 webframe_, webkit_glue::StringToWebString(title)); 691 m_webFrame->client()->didFinishLoad(m_webFrame);
601 } 692
602 } 693 if (observer)
603 694 observer->didFinishLoading();
604 void WebFrameLoaderClient::dispatchDidCommitLoad() { 695
605 WebViewImpl* webview = webframe_->GetWebViewImpl(); 696 // Don't clear the redirect chain, this will happen in the middle of client
606 bool is_new_navigation; 697 // redirects, and we need the context. The chain will be cleared when the
607 webview->DidCommitLoad(&is_new_navigation); 698 // provisional load succeeds or fails, not the "real" one.
608 699 }
609 if (webframe_->client()) { 700
610 webframe_->client()->didCommitProvisionalLoad( 701 void FrameLoaderClientImpl::dispatchDidFirstLayout()
611 webframe_, is_new_navigation); 702 {
612 } 703 }
613 704
614 WebDevToolsAgentImpl* tools_agent = webview->GetWebDevToolsAgentImpl(); 705 void FrameLoaderClientImpl::dispatchDidFirstVisuallyNonEmptyLayout()
615 if (tools_agent) { 706 {
616 tools_agent->DidCommitLoadForFrame(webview, webframe_, is_new_navigation);
617 }
618 }
619
620 void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(
621 const ResourceError& error) {
622 // If a policy change occured, then we do not want to inform the plugin
623 // delegate. See bug 907789 for details.
624 // TODO(darin): This means the plugin won't receive NPP_URLNotify, which
625 // seems like it could result in a memory leak in the plugin!!
626 if (error.domain() == kInternalErrorDomain &&
627 error.errorCode() == ERR_POLICY_CHANGE) {
628 webframe_->DidFail(cancelledError(error.failingURL()), true);
629 return;
630 }
631
632 OwnPtr<WebPluginLoadObserver> plugin_load_observer = GetPluginLoadObserver();
633 webframe_->DidFail(error, true);
634 if (plugin_load_observer)
635 plugin_load_observer->didFailLoading(error);
636 }
637
638 void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error) {
639 OwnPtr<WebPluginLoadObserver> plugin_load_observer = GetPluginLoadObserver();
640 webframe_->DidFail(error, false);
641 if (plugin_load_observer)
642 plugin_load_observer->didFailLoading(error);
643
644 // Don't clear the redirect chain, this will happen in the middle of client
645 // redirects, and we need the context. The chain will be cleared when the
646 // provisional load succeeds or fails, not the "real" one.
647 }
648
649 void WebFrameLoaderClient::dispatchDidFinishLoad() {
650 OwnPtr<WebPluginLoadObserver> plugin_load_observer = GetPluginLoadObserver();
651
652 if (webframe_->client())
653 webframe_->client()->didFinishLoad(webframe_);
654
655 if (plugin_load_observer)
656 plugin_load_observer->didFinishLoading();
657
658 // Don't clear the redirect chain, this will happen in the middle of client
659 // redirects, and we need the context. The chain will be cleared when the
660 // provisional load succeeds or fails, not the "real" one.
661 }
662
663 void WebFrameLoaderClient::dispatchDidFirstLayout() {
664 }
665
666 void WebFrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout() {
667 // FIXME: called when webkit finished layout of a page that was visually 707 // FIXME: called when webkit finished layout of a page that was visually
668 // non-empty. 708 // non-empty.
669 // All resources have not necessarily finished loading. 709 // All resources have not necessarily finished loading.
670 } 710 }
671 711
672 Frame* WebFrameLoaderClient::dispatchCreatePage() { 712 Frame* FrameLoaderClientImpl::dispatchCreatePage()
673 struct WebCore::WindowFeatures features; 713 {
674 Page* new_page = webframe_->frame()->page()->chrome()->createWindow( 714 struct WindowFeatures features;
675 webframe_->frame(), FrameLoadRequest(), features); 715 Page* newPage = m_webFrame->frame()->page()->chrome()->createWindow(
676 716 m_webFrame->frame(), FrameLoadRequest(), features);
677 // Make sure that we have a valid disposition. This should have been set in 717
678 // the preceeding call to dispatchDecidePolicyForNewWindowAction. 718 // Make sure that we have a valid disposition. This should have been set in
679 ASSERT(next_navigation_policy_ != WebKit::WebNavigationPolicyIgnore); 719 // the preceeding call to dispatchDecidePolicyForNewWindowAction.
680 WebNavigationPolicy policy = next_navigation_policy_; 720 ASSERT(m_nextNavigationPolicy != WebNavigationPolicyIgnore);
681 next_navigation_policy_ = WebKit::WebNavigationPolicyIgnore; 721 WebNavigationPolicy policy = m_nextNavigationPolicy;
682 722 m_nextNavigationPolicy = WebNavigationPolicyIgnore;
683 // createWindow can return NULL (e.g., popup blocker denies the window). 723
684 if (!new_page) 724 // createWindow can return null (e.g., popup blocker denies the window).
685 return NULL; 725 if (!newPage)
686 726 return 0;
687 WebViewImpl::FromPage(new_page)->set_initial_navigation_policy(policy); 727
688 return new_page->mainFrame(); 728 WebViewImpl::fromPage(newPage)->setInitialNavigationPolicy(policy);
689 } 729 return newPage->mainFrame();
690 730 }
691 void WebFrameLoaderClient::dispatchShow() { 731
692 WebViewImpl* webview = webframe_->GetWebViewImpl(); 732 void FrameLoaderClientImpl::dispatchShow()
693 if (webview && webview->client()) 733 {
694 webview->client()->show(webview->initial_navigation_policy()); 734 WebViewImpl* webView = m_webFrame->viewImpl();
695 } 735 if (webView && webView->client())
696 736 webView->client()->show(webView->initialNavigationPolicy());
697 static bool TreatAsAttachment(const ResourceResponse& response) { 737 }
698 const String& content_disposition = 738
699 response.httpHeaderField("Content-Disposition"); 739 static bool shouldTreatAsAttachment(const ResourceResponse& response)
700 if (content_disposition.isEmpty()) 740 {
701 return false; 741 const String& contentDisposition =
702 742 response.httpHeaderField("Content-Disposition");
703 // Some broken sites just send 743 if (contentDisposition.isEmpty())
704 // Content-Disposition: ; filename="file" 744 return false;
705 // screen those out here. 745
706 if (content_disposition.startsWith(";")) 746 // Some broken sites just send
707 return false; 747 // Content-Disposition: ; filename="file"
708 748 // screen those out here.
709 if (content_disposition.startsWith("inline", false)) 749 if (contentDisposition.startsWith(";"))
710 return false; 750 return false;
711 751
712 // Some broken sites just send 752 if (contentDisposition.startsWith("inline", false))
713 // Content-Disposition: filename="file" 753 return false;
714 // without a disposition token... screen those out. 754
715 if (content_disposition.startsWith("filename", false)) 755 // Some broken sites just send
716 return false; 756 // Content-Disposition: filename="file"
717 757 // without a disposition token... screen those out.
718 // Also in use is Content-Disposition: name="file" 758 if (contentDisposition.startsWith("filename", false))
719 if (content_disposition.startsWith("name", false)) 759 return false;
720 return false; 760
721 761 // Also in use is Content-Disposition: name="file"
722 // We have a content-disposition of "attachment" or unknown. 762 if (contentDisposition.startsWith("name", false))
723 // RFC 2183, section 2.8 says that an unknown disposition 763 return false;
724 // value should be treated as "attachment" 764
725 return true; 765 // We have a content-disposition of "attachment" or unknown.
726 } 766 // RFC 2183, section 2.8 says that an unknown disposition
727 767 // value should be treated as "attachment"
728 void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType( 768 return true;
769 }
770
771 void FrameLoaderClientImpl::dispatchDecidePolicyForMIMEType(
729 FramePolicyFunction function, 772 FramePolicyFunction function,
730 const String& mime_type, 773 const String& mimeType,
731 const ResourceRequest&) { 774 const ResourceRequest&)
732 const ResourceResponse& response = 775 {
733 webframe_->frame()->loader()->activeDocumentLoader()->response(); 776 const ResourceResponse& response =
734 777 m_webFrame->frame()->loader()->activeDocumentLoader()->response();
735 PolicyAction action; 778
736 779 PolicyAction action;
737 int status_code = response.httpStatusCode(); 780
738 if (status_code == 204 || status_code == 205) { 781 int statusCode = response.httpStatusCode();
739 // The server does not want us to replace the page contents. 782 if (statusCode == 204 || statusCode == 205) {
740 action = PolicyIgnore; 783 // The server does not want us to replace the page contents.
741 } else if (TreatAsAttachment(response)) { 784 action = PolicyIgnore;
742 // The server wants us to download instead of replacing the page contents. 785 } else if (shouldTreatAsAttachment(response)) {
743 // Downloading is handled by the embedder, but we still get the initial 786 // The server wants us to download instead of replacing the page contents.
744 // response so that we can ignore it and clean up properly. 787 // Downloading is handled by the embedder, but we still get the initial
745 action = PolicyIgnore; 788 // response so that we can ignore it and clean up properly.
746 } else if (!canShowMIMEType(mime_type)) { 789 action = PolicyIgnore;
747 // Make sure that we can actually handle this type internally. 790 } else if (!canShowMIMEType(mimeType)) {
748 action = PolicyIgnore; 791 // Make sure that we can actually handle this type internally.
749 } else { 792 action = PolicyIgnore;
750 // OK, we will render this page. 793 } else {
751 action = PolicyUse; 794 // OK, we will render this page.
752 } 795 action = PolicyUse;
753 796 }
754 // NOTE: ERR_POLICY_CHANGE will be generated when action is not PolicyUse. 797
755 (webframe_->frame()->loader()->policyChecker()->*function)(action); 798 // NOTE: PolicyChangeError will be generated when action is not PolicyUse.
756 } 799 (m_webFrame->frame()->loader()->policyChecker()->*function)(action);
757 800 }
758 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction( 801
759 WebCore::FramePolicyFunction function, 802 void FrameLoaderClientImpl::dispatchDecidePolicyForNewWindowAction(
760 const WebCore::NavigationAction& action, 803 FramePolicyFunction function,
761 const WebCore::ResourceRequest& request, 804 const NavigationAction& action,
762 PassRefPtr<WebCore::FormState> form_state, 805 const ResourceRequest& request,
763 const WebCore::String& frame_name) { 806 PassRefPtr<FormState> formState,
764 WebNavigationPolicy navigation_policy; 807 const String& frameName)
765 if (!ActionSpecifiesNavigationPolicy(action, &navigation_policy)) 808 {
766 navigation_policy = WebKit::WebNavigationPolicyNewForegroundTab; 809 WebNavigationPolicy navigationPolicy;
767 810 if (!actionSpecifiesNavigationPolicy(action, &navigationPolicy))
768 PolicyAction policy_action; 811 navigationPolicy = WebNavigationPolicyNewForegroundTab;
769 if (navigation_policy == WebKit::WebNavigationPolicyDownload) { 812
770 policy_action = PolicyDownload; 813 PolicyAction policyAction;
771 } else { 814 if (navigationPolicy == WebNavigationPolicyDownload)
772 policy_action = PolicyUse; 815 policyAction = PolicyDownload;
773 816 else {
774 // Remember the disposition for when dispatchCreatePage is called. It is 817 policyAction = PolicyUse;
775 // unfortunate that WebCore does not provide us with any context when 818
776 // creating or showing the new window that would allow us to avoid having 819 // Remember the disposition for when dispatchCreatePage is called. It is
777 // to keep this state. 820 // unfortunate that WebCore does not provide us with any context when
778 next_navigation_policy_ = navigation_policy; 821 // creating or showing the new window that would allow us to avoid having
779 } 822 // to keep this state.
780 (webframe_->frame()->loader()->policyChecker()->*function)(policy_action); 823 m_nextNavigationPolicy = navigationPolicy;
781 } 824 }
782 825 (m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction);
783 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( 826 }
784 WebCore::FramePolicyFunction function, 827
785 const WebCore::NavigationAction& action, 828 void FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction(
786 const WebCore::ResourceRequest& request, 829 FramePolicyFunction function,
787 PassRefPtr<WebCore::FormState> form_state) { 830 const NavigationAction& action,
788 PolicyAction policy_action = PolicyIgnore; 831 const ResourceRequest& request,
789 832 PassRefPtr<FormState> formState) {
790 // It is valid for this function to be invoked in code paths where the 833 PolicyAction policyAction = PolicyIgnore;
791 // the webview is closed. 834
792 // The NULL check here is to fix a crash that seems strange 835 // It is valid for this function to be invoked in code paths where the
793 // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). 836 // the webview is closed.
794 if (webframe_->client() && !request.url().isNull()) { 837 // The null check here is to fix a crash that seems strange
795 WebNavigationPolicy navigation_policy = 838 // (see - https://bugs.webkit.org/show_bug.cgi?id=23554).
796 WebKit::WebNavigationPolicyCurrentTab; 839 if (m_webFrame->client() && !request.url().isNull()) {
797 ActionSpecifiesNavigationPolicy(action, &navigation_policy); 840 WebNavigationPolicy navigationPolicy = WebNavigationPolicyCurrentTab;
798 841 actionSpecifiesNavigationPolicy(action, &navigationPolicy);
799 // Give the delegate a chance to change the navigation policy. 842
800 const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); 843 // Give the delegate a chance to change the navigation policy.
801 if (ds) { 844 const WebDataSourceImpl* ds = m_webFrame->provisionalDataSourceImpl();
802 KURL url = webkit_glue::WebURLToKURL(ds->request().url()); 845 if (ds) {
803 if (url.protocolIs(WebKit::backForwardNavigationScheme)) { 846 KURL url = ds->request().url();
804 HandleBackForwardNavigation(url); 847 if (url.protocolIs(backForwardNavigationScheme)) {
805 navigation_policy = WebKit::WebNavigationPolicyIgnore; 848 handleBackForwardNavigation(url);
806 } else { 849 navigationPolicy = WebNavigationPolicyIgnore;
807 bool is_redirect = ds->hasRedirectChain(); 850 } else {
808 851 bool isRedirect = ds->hasRedirectChain();
809 WebNavigationType webnav_type = 852
810 WebDataSourceImpl::toWebNavigationType(action.type()); 853 WebNavigationType webnavType =
811 854 WebDataSourceImpl::toWebNavigationType(action.type());
812 RefPtr<WebCore::Node> node; 855
813 for (const Event* event = action.event(); event; 856 RefPtr<Node> node;
814 event = event->underlyingEvent()) { 857 for (const Event* event = action.event(); event; event = event->underlyingEvent()) {
815 if (event->isMouseEvent()) { 858 if (event->isMouseEvent()) {
816 const MouseEvent* mouse_event = 859 const MouseEvent* mouseEvent =
817 static_cast<const MouseEvent*>(event); 860 static_cast<const MouseEvent*>(event);
818 node = webframe_->frame()->eventHandler()->hitTestResultAtPoint( 861 node = m_webFrame->frame()->eventHandler()->hitTestResultAtPoint(
819 mouse_event->absoluteLocation(), false).innerNonSharedNode(); 862 mouseEvent->absoluteLocation(), false).innerNonSharedNode();
820 break; 863 break;
864 }
865 }
866 WebNode originatingNode(node);
867
868 navigationPolicy = m_webFrame->client()->decidePolicyForNavigation(
869 m_webFrame, ds->request(), webnavType, originatingNode,
870 navigationPolicy, isRedirect);
821 } 871 }
872 }
873
874 if (navigationPolicy == WebNavigationPolicyCurrentTab)
875 policyAction = PolicyUse;
876 else if (navigationPolicy == WebNavigationPolicyDownload)
877 policyAction = PolicyDownload;
878 else {
879 if (navigationPolicy != WebNavigationPolicyIgnore) {
880 WrappedResourceRequest webreq(request);
881 m_webFrame->client()->loadURLExternally(m_webFrame, webreq, navigationPolicy);
882 }
883 policyAction = PolicyIgnore;
884 }
885 }
886
887 (m_webFrame->frame()->loader()->policyChecker()->*function)(policyAction);
888 }
889
890 void FrameLoaderClientImpl::cancelPolicyCheck()
891 {
892 // FIXME
893 }
894
895 void FrameLoaderClientImpl::dispatchUnableToImplementPolicy(const ResourceError& error)
896 {
897 m_webFrame->client()->unableToImplementPolicyWithError(m_webFrame, error);
898 }
899
900 void FrameLoaderClientImpl::dispatchWillSubmitForm(FramePolicyFunction function,
901 PassRefPtr<FormState> formState)
902 {
903 if (m_webFrame->client())
904 m_webFrame->client()->willSubmitForm(m_webFrame, WebForm(formState->form()));
905 (m_webFrame->frame()->loader()->policyChecker()->*function)(PolicyUse);
906 }
907
908 void FrameLoaderClientImpl::dispatchDidLoadMainResource(DocumentLoader*)
909 {
910 // FIXME
911 }
912
913 void FrameLoaderClientImpl::revertToProvisionalState(DocumentLoader*)
914 {
915 m_hasRepresentation = true;
916 }
917
918 void FrameLoaderClientImpl::setMainDocumentError(DocumentLoader*,
919 const ResourceError& error)
920 {
921 if (m_pluginWidget.get()) {
922 if (m_sentInitialResponseToPlugin) {
923 m_pluginWidget->didFailLoading(error);
924 m_sentInitialResponseToPlugin = false;
822 } 925 }
823 WebNode originating_node = webkit_glue::NodeToWebNode(node); 926 m_pluginWidget = 0;
824 927 }
825 navigation_policy = webframe_->client()->decidePolicyForNavigation( 928 }
826 webframe_, ds->request(), webnav_type, originating_node, 929
827 navigation_policy, is_redirect); 930 void FrameLoaderClientImpl::postProgressStartedNotification()
828 } 931 {
829 } 932 WebViewImpl* webview = m_webFrame->viewImpl();
830 933 if (webview && webview->client())
831 if (navigation_policy == WebKit::WebNavigationPolicyCurrentTab) { 934 webview->client()->didStartLoading();
832 policy_action = PolicyUse; 935 }
833 } else if (navigation_policy == WebKit::WebNavigationPolicyDownload) { 936
834 policy_action = PolicyDownload; 937 void FrameLoaderClientImpl::postProgressEstimateChangedNotification()
835 } else { 938 {
836 if (navigation_policy != WebKit::WebNavigationPolicyIgnore) { 939 // FIXME
837 WrappedResourceRequest webreq(request); 940 }
838 webframe_->client()->loadURLExternally( 941
839 webframe_, webreq, navigation_policy); 942 void FrameLoaderClientImpl::postProgressFinishedNotification()
840 } 943 {
841 policy_action = PolicyIgnore; 944 // FIXME: why might the webview be null? http://b/1234461
842 } 945 WebViewImpl* webview = m_webFrame->viewImpl();
843 } 946 if (webview && webview->client())
844 947 webview->client()->didStopLoading();
845 (webframe_->frame()->loader()->policyChecker()->*function)(policy_action); 948 }
846 } 949
847 950 void FrameLoaderClientImpl::setMainFrameDocumentReady(bool ready)
848 void WebFrameLoaderClient::cancelPolicyCheck() { 951 {
849 // FIXME 952 // FIXME
850 }
851
852 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(
853 const ResourceError& error) {
854 WebKit::WebURLError url_error =
855 webkit_glue::ResourceErrorToWebURLError(error);
856 webframe_->client()->unableToImplementPolicyWithError(webframe_, url_error);
857 }
858
859 void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function,
860 PassRefPtr<FormState> form_ref) {
861 if (webframe_->client()) {
862 webframe_->client()->willSubmitForm(
863 webframe_, webkit_glue::HTMLFormElementToWebForm(form_ref->form()));
864 }
865 (webframe_->frame()->loader()->policyChecker()->*function)(PolicyUse);
866 }
867
868 void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*) {
869 // FIXME
870 }
871
872 void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*) {
873 has_representation_ = true;
874 }
875
876 void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*,
877 const ResourceError& error) {
878 if (plugin_widget_.get()) {
879 if (sent_initial_response_to_plugin_) {
880 plugin_widget_->didFailLoading(error);
881 sent_initial_response_to_plugin_ = false;
882 }
883 plugin_widget_ = NULL;
884 }
885 }
886
887 void WebFrameLoaderClient::postProgressStartedNotification() {
888 WebViewImpl* webview = webframe_->GetWebViewImpl();
889 if (webview && webview->client())
890 webview->client()->didStartLoading();
891 }
892
893 void WebFrameLoaderClient::postProgressEstimateChangedNotification() {
894 // FIXME
895 }
896
897 void WebFrameLoaderClient::postProgressFinishedNotification() {
898 // TODO(ericroman): why might the webview be null?
899 // http://b/1234461
900 WebViewImpl* webview = webframe_->GetWebViewImpl();
901 if (webview && webview->client())
902 webview->client()->didStopLoading();
903 }
904
905 void WebFrameLoaderClient::setMainFrameDocumentReady(bool ready) {
906 // FIXME
907 } 953 }
908 954
909 // Creates a new connection and begins downloading from that (contrast this 955 // Creates a new connection and begins downloading from that (contrast this
910 // with |download|). 956 // with |download|).
911 void WebFrameLoaderClient::startDownload(const ResourceRequest& request) { 957 void FrameLoaderClientImpl::startDownload(const ResourceRequest& request)
912 if (webframe_->client()) { 958 {
913 WrappedResourceRequest webreq(request); 959 if (m_webFrame->client()) {
914 webframe_->client()->loadURLExternally( 960 WrappedResourceRequest webreq(request);
915 webframe_, webreq, WebKit::WebNavigationPolicyDownload); 961 m_webFrame->client()->loadURLExternally(
916 } 962 m_webFrame, webreq, WebNavigationPolicyDownload);
917 } 963 }
918 964 }
919 void WebFrameLoaderClient::willChangeTitle(DocumentLoader*) { 965
920 // FIXME 966 void FrameLoaderClientImpl::willChangeTitle(DocumentLoader*)
921 } 967 {
922 968 // FIXME
923 void WebFrameLoaderClient::didChangeTitle(DocumentLoader*) { 969 }
924 // FIXME 970
971 void FrameLoaderClientImpl::didChangeTitle(DocumentLoader*)
972 {
973 // FIXME
925 } 974 }
926 975
927 // Called whenever data is received. 976 // Called whenever data is received.
928 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length) { 977 void FrameLoaderClientImpl::committedLoad(DocumentLoader* loader, const char* data, int length) {
929 if (!plugin_widget_.get()) { 978 if (!m_pluginWidget.get()) {
930 if (webframe_->client()) { 979 if (m_webFrame->client()) {
931 bool preventDefault = false; 980 bool preventDefault = false;
932 webframe_->client()->didReceiveDocumentData(webframe_, data, length, preventDefault); 981 m_webFrame->client()->didReceiveDocumentData(m_webFrame, data, length, preventDefault);
933 if (!preventDefault) 982 if (!preventDefault)
934 webframe_->commitDocumentData(data, length); 983 m_webFrame->commitDocumentData(data, length);
935 } 984 }
936 } 985 }
937 986
938 // If we are sending data to WebCore::MediaDocument, we should stop here 987 // If we are sending data to MediaDocument, we should stop here
939 // and cancel the request. 988 // and cancel the request.
940 if (webframe_->frame()->document() && 989 if (m_webFrame->frame()->document()
941 webframe_->frame()->document()->isMediaDocument()) { 990 && m_webFrame->frame()->document()->isMediaDocument())
942 loader->cancelMainResourceLoad( 991 loader->cancelMainResourceLoad(pluginWillHandleLoadError(loader->response()));
943 pluginWillHandleLoadError(loader->response())); 992
944 } 993 // The plugin widget could have been created in the m_webFrame->DidReceiveData
945 994 // function.
946 // The plugin widget could have been created in the webframe_->DidReceiveData 995 if (m_pluginWidget.get()) {
947 // function. 996 if (!m_sentInitialResponseToPlugin) {
948 if (plugin_widget_.get()) { 997 m_sentInitialResponseToPlugin = true;
949 if (!sent_initial_response_to_plugin_) { 998 m_pluginWidget->didReceiveResponse(
950 sent_initial_response_to_plugin_ = true; 999 m_webFrame->frame()->loader()->activeDocumentLoader()->response());
951 plugin_widget_->didReceiveResponse( 1000 }
952 webframe_->frame()->loader()->activeDocumentLoader()->response()); 1001 m_pluginWidget->didReceiveData(data, length);
953 } 1002 }
954 plugin_widget_->didReceiveData(data, length); 1003 }
955 } 1004
956 } 1005 void FrameLoaderClientImpl::finishedLoading(DocumentLoader* dl)
957 1006 {
958 void WebFrameLoaderClient::finishedLoading(DocumentLoader* dl) { 1007 if (m_pluginWidget.get()) {
959 if (plugin_widget_.get()) { 1008 m_pluginWidget->didFinishLoading();
960 plugin_widget_->didFinishLoading(); 1009 m_pluginWidget = 0;
961 plugin_widget_ = NULL; 1010 m_sentInitialResponseToPlugin = false;
962 sent_initial_response_to_plugin_ = false; 1011 } else {
963 } else { 1012 // This is necessary to create an empty document. See bug 634004.
964 // This is necessary to create an empty document. See bug 634004. 1013 // However, we only want to do this if makeRepresentation has been called, to
965 // However, we only want to do this if makeRepresentation has been called, to 1014 // match the behavior on the Mac.
966 // match the behavior on the Mac. 1015 if (m_hasRepresentation)
967 if (has_representation_) 1016 dl->frameLoader()->setEncoding("", false);
968 dl->frameLoader()->setEncoding("", false); 1017 }
969 } 1018 }
970 } 1019
971 1020 void FrameLoaderClientImpl::updateGlobalHistory()
972 void WebFrameLoaderClient::updateGlobalHistory() { 1021 {
973 } 1022 }
974 1023
975 void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks() { 1024 void FrameLoaderClientImpl::updateGlobalHistoryRedirectLinks()
976 } 1025 {
977 1026 }
978 bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem*) const { 1027
979 // FIXME 1028 bool FrameLoaderClientImpl::shouldGoToHistoryItem(HistoryItem*) const
980 return true; 1029 {
981 } 1030 // FIXME
982 1031 return true;
983 void WebFrameLoaderClient::didDisplayInsecureContent() { 1032 }
984 if (webframe_->client()) 1033
985 webframe_->client()->didDisplayInsecureContent(webframe_); 1034 void FrameLoaderClientImpl::didDisplayInsecureContent()
986 } 1035 {
987 1036 if (m_webFrame->client())
988 void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin* origin) { 1037 m_webFrame->client()->didDisplayInsecureContent(m_webFrame);
989 if (webframe_->client()) { 1038 }
990 webframe_->client()->didRunInsecureContent(webframe_, 1039
991 webkit_glue::SecurityOriginToWebSecurityOrigin(origin)); 1040 void FrameLoaderClientImpl::didRunInsecureContent(SecurityOrigin* origin)
992 } 1041 {
993 } 1042 if (m_webFrame->client())
994 1043 m_webFrame->client()->didRunInsecureContent(m_webFrame, WebSecurityOrigin(origin));
995 ResourceError WebFrameLoaderClient::blockedError(const WebCore::ResourceRequest&) { 1044 }
996 // FIXME 1045
997 return ResourceError(); 1046 ResourceError FrameLoaderClientImpl::blockedError(const ResourceRequest&)
998 } 1047 {
999 1048 // FIXME
1000 ResourceError WebFrameLoaderClient::cancelledError(
1001 const ResourceRequest& request) {
1002 if (!webframe_->client())
1003 return ResourceError(); 1049 return ResourceError();
1004 1050 }
1005 return webkit_glue::WebURLErrorToResourceError( 1051
1006 webframe_->client()->cancelledError( 1052 ResourceError FrameLoaderClientImpl::cancelledError(const ResourceRequest& request)
1007 webframe_, WrappedResourceRequest(request))); 1053 {
1008 } 1054 if (!m_webFrame->client())
1009 1055 return ResourceError();
1010 ResourceError WebFrameLoaderClient::cannotShowURLError( 1056
1011 const ResourceRequest& request) { 1057 return m_webFrame->client()->cancelledError(
1012 if (!webframe_->client()) 1058 m_webFrame, WrappedResourceRequest(request));
1059 }
1060
1061 ResourceError FrameLoaderClientImpl::cannotShowURLError(const ResourceRequest& request)
1062 {
1063 if (!m_webFrame->client())
1064 return ResourceError();
1065
1066 return m_webFrame->client()->cannotHandleRequestError(
1067 m_webFrame, WrappedResourceRequest(request));
1068 }
1069
1070 ResourceError FrameLoaderClientImpl::interruptForPolicyChangeError(
1071 const ResourceRequest& request)
1072 {
1073 return ResourceError(internalErrorDomain, PolicyChangeError,
1074 request.url().string(), String());
1075 }
1076
1077 ResourceError FrameLoaderClientImpl::cannotShowMIMETypeError(const ResourceResponse&)
1078 {
1079 // FIXME
1013 return ResourceError(); 1080 return ResourceError();
1014 1081 }
1015 return webkit_glue::WebURLErrorToResourceError( 1082
1016 webframe_->client()->cannotHandleRequestError( 1083 ResourceError FrameLoaderClientImpl::fileDoesNotExistError(const ResourceResponse&)
1017 webframe_, WrappedResourceRequest(request))); 1084 {
1018 } 1085 // FIXME
1019 1086 return ResourceError();
1020 ResourceError WebFrameLoaderClient::interruptForPolicyChangeError( 1087 }
1021 const ResourceRequest& request) { 1088
1022 return ResourceError(kInternalErrorDomain, ERR_POLICY_CHANGE, 1089 ResourceError FrameLoaderClientImpl::pluginWillHandleLoadError(const ResourceResponse&)
1023 request.url().string(), String()); 1090 {
1024 } 1091 // FIXME
1025 1092 return ResourceError();
1026 ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse&) { 1093 }
1027 // FIXME 1094
1028 return ResourceError(); 1095 bool FrameLoaderClientImpl::shouldFallBack(const ResourceError& error)
1029 } 1096 {
1030 1097 // This method is called when we fail to load the URL for an <object> tag
1031 ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse&) { 1098 // that has fallback content (child elements) and is being loaded as a frame.
1032 // FIXME 1099 // The error parameter indicates the reason for the load failure.
1033 return ResourceError(); 1100 // We should let the fallback content load only if this wasn't a cancelled
1034 } 1101 // request.
1035 1102 // Note: The mac version also has a case for "WebKitErrorPluginWillHandleLoad"
1036 ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const WebCore::ResourceResponse&) { 1103 ResourceError c = cancelledError(ResourceRequest());
1037 // FIXME 1104 return error.errorCode() != c.errorCode() || error.domain() != c.domain();
1038 return ResourceError(); 1105 }
1039 } 1106
1040 1107 bool FrameLoaderClientImpl::canHandleRequest(const ResourceRequest& request) const
1041 bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error) { 1108 {
1042 // This method is called when we fail to load the URL for an <object> tag 1109 return m_webFrame->client()->canHandleRequest(
1043 // that has fallback content (child elements) and is being loaded as a frame. 1110 m_webFrame, WrappedResourceRequest(request));
1044 // The error parameter indicates the reason for the load failure. 1111 }
1045 // We should let the fallback content load only if this wasn't a cancelled 1112
1046 // request. 1113 bool FrameLoaderClientImpl::canShowMIMEType(const String& mimeType) const
1047 // Note: The mac version also has a case for "WebKitErrorPluginWillHandleLoad" 1114 {
1048 ResourceError cancelled_error = cancelledError(ResourceRequest()); 1115 // This method is called to determine if the media type can be shown
1049 return error.errorCode() != cancelled_error.errorCode() || 1116 // "internally" (i.e. inside the browser) regardless of whether or not the
1050 error.domain() != cancelled_error.domain(); 1117 // browser or a plugin is doing the rendering.
1051 } 1118
1052 1119 // mimeType strings are supposed to be ASCII, but if they are not for some
1053 bool WebFrameLoaderClient::canHandleRequest( 1120 // reason, then it just means that the mime type will fail all of these "is
1054 const ResourceRequest& request) const { 1121 // supported" checks and go down the path of an unhandled mime type.
1055 return webframe_->client()->canHandleRequest( 1122 if (net::IsSupportedMimeType(mimeType.latin1().data()))
1056 webframe_, WrappedResourceRequest(request)); 1123 return true;
1057 } 1124
1058 1125 // If Chrome is started with the --disable-plugins switch, pluginData is null.
1059 bool WebFrameLoaderClient::canShowMIMEType(const String& mime_type) const { 1126 PluginData* pluginData = m_webFrame->frame()->page()->pluginData();
1060 // This method is called to determine if the media type can be shown 1127
1061 // "internally" (i.e. inside the browser) regardless of whether or not the 1128 // See if the type is handled by an installed plugin, if so, we can show it.
1062 // browser or a plugin is doing the rendering. 1129 // FIXME: (http://b/1085524) This is the place to stick a preference to
1063 1130 // disable full page plugins (optionally for certain types!)
1064 // mime_type strings are supposed to be ASCII, but if they are not for some 1131 return !mimeType.isEmpty() && pluginData && pluginData->supportsMimeType(mimeType);
1065 // reason, then it just means that the mime type will fail all of these "is 1132 }
1066 // supported" checks and go down the path of an unhandled mime type. 1133
1067 if (net::IsSupportedMimeType( 1134 bool FrameLoaderClientImpl::representationExistsForURLScheme(const String&) const
1068 webkit_glue::CStringToStdString(mime_type.latin1()))) 1135 {
1069 return true; 1136 // FIXME
1070 1137 return false;
1071 // If Chrome is started with the --disable-plugins switch, pluginData is null. 1138 }
1072 WebCore::PluginData* plugin_data = webframe_->frame()->page()->pluginData(); 1139
1073 1140 String FrameLoaderClientImpl::generatedMIMETypeForURLScheme(const String& scheme) const
1074 // See if the type is handled by an installed plugin, if so, we can show it. 1141 {
1075 // TODO(beng): (http://b/1085524) This is the place to stick a preference to 1142 // This appears to generate MIME types for protocol handlers that are handled
1076 // disable full page plugins (optionally for certain types!) 1143 // internally. The only place I can find in the WebKit code that uses this
1077 return !mime_type.isEmpty() && plugin_data && plugin_data->supportsMimeType(mime_type); 1144 // function is WebView::registerViewClass, where it is used as part of the
1078 } 1145 // process by which custom view classes for certain document representations
1079 1146 // are registered.
1080 bool WebFrameLoaderClient::representationExistsForURLScheme(const String& URLScheme) const { 1147 String mimeType("x-apple-web-kit/");
1081 // FIXME 1148 mimeType.append(scheme.lower());
1082 return false; 1149 return mimeType;
1083 } 1150 }
1084 1151
1085 String WebFrameLoaderClient::generatedMIMETypeForURLScheme(const String& URLScheme) const { 1152 void FrameLoaderClientImpl::frameLoadCompleted()
1086 // This appears to generate MIME types for protocol handlers that are handled 1153 {
1087 // internally. The only place I can find in the WebKit code that uses this 1154 // FIXME: the mac port also conditionally calls setDrawsBackground:YES on
1088 // function is WebView::registerViewClass, where it is used as part of the 1155 // it's ScrollView here.
1089 // process by which custom view classes for certain document representations 1156
1090 // are registered. 1157 // This comment from the Mac port:
1091 String mimetype("x-apple-web-kit/"); 1158 // Note: Can be called multiple times.
1092 mimetype.append(URLScheme.lower()); 1159 // Even if already complete, we might have set a previous item on a frame that
1093 return mimetype; 1160 // didn't do any data loading on the past transaction. Make sure to clear these out.
1094 } 1161
1095 1162 // FIXME: setPreviousHistoryItem() no longer exists. http://crbug.com/8566
1096 void WebFrameLoaderClient::frameLoadCompleted() { 1163 // m_webFrame->frame()->loader()->setPreviousHistoryItem(0);
1097 // FIXME: the mac port also conditionally calls setDrawsBackground:YES on 1164 }
1098 // it's ScrollView here. 1165
1099 1166 void FrameLoaderClientImpl::saveViewStateToItem(HistoryItem*)
1100 // This comment from the Mac port: 1167 {
1101 // Note: Can be called multiple times. 1168 // FIXME
1102 // Even if already complete, we might have set a previous item on a frame that 1169 }
1103 // didn't do any data loading on the past transaction. Make sure to clear these out. 1170
1104 1171 void FrameLoaderClientImpl::restoreViewState()
1105 // FIXME: setPreviousHistoryItem() no longer exists. http://crbug.com/8566 1172 {
1106 // webframe_->frame()->loader()->setPreviousHistoryItem(0); 1173 // FIXME: probably scrolls to last position when you go back or forward
1107 } 1174 }
1108 1175
1109 void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*) { 1176 void FrameLoaderClientImpl::provisionalLoadStarted()
1110 // FIXME 1177 {
1111 } 1178 // FIXME: On mac, this does various caching stuff
1112 1179 }
1113 1180
1114 void WebFrameLoaderClient::restoreViewState() { 1181 void FrameLoaderClientImpl::didFinishLoad()
1115 // FIXME: probably scrolls to last position when you go back or forward 1182 {
1116 } 1183 OwnPtr<WebPluginLoadObserver> observer = pluginLoadObserver();
1117 1184 if (observer)
1118 void WebFrameLoaderClient::provisionalLoadStarted() { 1185 observer->didFinishLoading();
1119 // FIXME: On mac, this does various caching stuff 1186 }
1120 } 1187
1121 1188 void FrameLoaderClientImpl::prepareForDataSourceReplacement()
1122 void WebFrameLoaderClient::didFinishLoad() { 1189 {
1123 OwnPtr<WebPluginLoadObserver> plugin_load_observer = GetPluginLoadObserver(); 1190 // FIXME
1124 if (plugin_load_observer) 1191 }
1125 plugin_load_observer->didFinishLoading(); 1192
1126 } 1193 PassRefPtr<DocumentLoader> FrameLoaderClientImpl::createDocumentLoader(
1127
1128 void WebFrameLoaderClient::prepareForDataSourceReplacement() {
1129 // FIXME
1130 }
1131
1132 PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(
1133 const ResourceRequest& request, 1194 const ResourceRequest& request,
1134 const SubstituteData& data) { 1195 const SubstituteData& data)
1135 RefPtr<WebDataSourceImpl> ds = WebDataSourceImpl::create(request, data); 1196 {
1136 if (webframe_->client()) 1197 RefPtr<WebDataSourceImpl> ds = WebDataSourceImpl::create(request, data);
1137 webframe_->client()->didCreateDataSource(webframe_, ds.get()); 1198 if (m_webFrame->client())
1138 return ds.release(); 1199 m_webFrame->client()->didCreateDataSource(m_webFrame, ds.get());
1139 } 1200 return ds.release();
1140 1201 }
1141 void WebFrameLoaderClient::setTitle(const String& title, const KURL& url) { 1202
1142 // FIXME: monitor for changes in WebFrameLoaderClient.mm 1203 void FrameLoaderClientImpl::setTitle(const String& title, const KURL& url)
1143 // FIXME: Set the title of the current history item. HistoryItemImpl's setter 1204 {
1144 // will notify its clients (e.g. the history database) that the title 1205 // FIXME: inform consumer of changes to the title.
1145 // has changed. 1206 }
1146 // 1207
1147 // e.g.: 1208 String FrameLoaderClientImpl::userAgent(const KURL& url)
1148 // WebHistoryItem* item = 1209 {
1149 // webframe_->GetWebViewImpl()->GetBackForwardList()->GetCurrentItem(); 1210 // FIXME: Convert this to a WebKitClient callback.
1150 // WebHistoryItemImpl* item_impl = static_cast<WebHistoryItemImpl*>(item); 1211 return webkit_glue::StdStringToString(
1151 // 1212 webkit_glue::GetUserAgent(webkit_glue::KURLToGURL(url)));
1152 // item_impl->SetTitle(webkit_glue::StringToStdWString(title)); 1213 }
1153 } 1214
1154 1215 void FrameLoaderClientImpl::savePlatformDataToCachedFrame(CachedFrame*)
1155 String WebFrameLoaderClient::userAgent(const KURL& url) { 1216 {
1156 return webkit_glue::StdStringToString( 1217 // The page cache should be disabled.
1157 webkit_glue::GetUserAgent(webkit_glue::KURLToGURL(url))); 1218 ASSERT_NOT_REACHED();
1158 } 1219 }
1159 1220
1160 void WebFrameLoaderClient::savePlatformDataToCachedFrame(WebCore::CachedFrame*) { 1221 void FrameLoaderClientImpl::transitionToCommittedFromCachedFrame(CachedFrame*)
1161 // The page cache should be disabled. 1222 {
1162 ASSERT_NOT_REACHED(); 1223 ASSERT_NOT_REACHED();
1163 }
1164
1165 void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) {
1166 ASSERT_NOT_REACHED();
1167 } 1224 }
1168 1225
1169 // Called when the FrameLoader goes into a state in which a new page load 1226 // Called when the FrameLoader goes into a state in which a new page load
1170 // will occur. 1227 // will occur.
1171 void WebFrameLoaderClient::transitionToCommittedForNewPage() { 1228 void FrameLoaderClientImpl::transitionToCommittedForNewPage()
1172 makeDocumentView(); 1229 {
1173 } 1230 makeDocumentView();
1174 1231 }
1175 bool WebFrameLoaderClient::canCachePage() const { 1232
1176 // Since we manage the cache, always report this page as non-cacheable to 1233 bool FrameLoaderClientImpl::canCachePage() const
1177 // FrameLoader. 1234 {
1178 return false; 1235 // Since we manage the cache, always report this page as non-cacheable to
1236 // FrameLoader.
1237 return false;
1179 } 1238 }
1180 1239
1181 // Downloading is handled in the browser process, not WebKit. If we get to this 1240 // Downloading is handled in the browser process, not WebKit. If we get to this
1182 // point, our download detection code in the ResourceDispatcherHost is broken! 1241 // point, our download detection code in the ResourceDispatcherHost is broken!
1183 void WebFrameLoaderClient::download(ResourceHandle* handle, 1242 void FrameLoaderClientImpl::download(ResourceHandle* handle,
1184 const ResourceRequest& request, 1243 const ResourceRequest& request,
1185 const ResourceRequest& initialRequest, 1244 const ResourceRequest& initialRequest,
1186 const ResourceResponse& response) { 1245 const ResourceResponse& response)
1187 ASSERT_NOT_REACHED(); 1246 {
1188 } 1247 ASSERT_NOT_REACHED();
1189 1248 }
1190 PassRefPtr<Frame> WebFrameLoaderClient::createFrame( 1249
1250 PassRefPtr<Frame> FrameLoaderClientImpl::createFrame(
1191 const KURL& url, 1251 const KURL& url,
1192 const String& name, 1252 const String& name,
1193 HTMLFrameOwnerElement* owner_element, 1253 HTMLFrameOwnerElement* ownerElement,
1194 const String& referrer, 1254 const String& referrer,
1195 bool allows_scrolling, 1255 bool allowsScrolling,
1196 int margin_width, 1256 int marginWidth,
1197 int margin_height) { 1257 int marginHeight)
1198 FrameLoadRequest frame_request(ResourceRequest(url, referrer), name); 1258 {
1199 return webframe_->CreateChildFrame(frame_request, owner_element); 1259 FrameLoadRequest frameRequest(ResourceRequest(url, referrer), name);
1200 } 1260 return m_webFrame->createChildFrame(frameRequest, ownerElement);
1201 1261 }
1202 PassRefPtr<Widget> WebFrameLoaderClient::createPlugin( 1262
1203 const IntSize& size, // TODO(erikkay): how do we use this? 1263 PassRefPtr<Widget> FrameLoaderClientImpl::createPlugin(
1264 const IntSize& size, // FIXME: how do we use this?
1204 HTMLPlugInElement* element, 1265 HTMLPlugInElement* element,
1205 const KURL& url, 1266 const KURL& url,
1206 const Vector<String>& param_names, 1267 const Vector<String>& paramNames,
1207 const Vector<String>& param_values, 1268 const Vector<String>& paramValues,
1208 const String& mime_type, 1269 const String& mimeType,
1209 bool load_manually) { 1270 bool loadManually)
1271 {
1210 #if !PLATFORM(WIN_OS) 1272 #if !PLATFORM(WIN_OS)
1211 // WebCore asks us to make a plugin even if we don't have a 1273 // WebCore asks us to make a plugin even if we don't have a
1212 // registered handler, with a comment saying it's so we can display 1274 // registered handler, with a comment saying it's so we can display
1213 // the broken plugin icon. In Chromium, we normally register a 1275 // the broken plugin icon. In Chromium, we normally register a
1214 // fallback plugin handler that allows you to install a missing 1276 // fallback plugin handler that allows you to install a missing
1215 // plugin. Since we don't yet have a default plugin handler, we 1277 // plugin. Since we don't yet have a default plugin handler, we
1216 // need to return NULL here rather than going through all the 1278 // need to return null here rather than going through all the
1217 // plugin-creation IPCs only to discover we don't have a plugin 1279 // plugin-creation IPCs only to discover we don't have a plugin
1218 // registered, which causes a crash. 1280 // registered, which causes a crash.
1219 // TODO(evanm): remove me once we have a default plugin. 1281 // FIXME: remove me once we have a default plugin.
1220 if (objectContentType(url, mime_type) != ObjectContentNetscapePlugin) 1282 if (objectContentType(url, mimeType) != ObjectContentNetscapePlugin)
1221 return NULL; 1283 return 0;
1222 #endif 1284 #endif
1223 1285
1224 if (!webframe_->client()) 1286 if (!m_webFrame->client())
1225 return NULL; 1287 return 0;
1226 1288
1227 WebPluginParams params; 1289 WebPluginParams params;
1228 params.url = webkit_glue::KURLToWebURL(url); 1290 params.url = url;
1229 params.mimeType = webkit_glue::StringToWebString(mime_type); 1291 params.mimeType = mimeType;
1230 CopyStringVector(param_names, &params.attributeNames); 1292 params.attributeNames = paramNames;
1231 CopyStringVector(param_values, &params.attributeValues); 1293 params.attributeValues = paramValues;
1232 params.loadManually = load_manually; 1294 params.loadManually = loadManually;
1233 1295
1234 WebPlugin* webplugin = webframe_->client()->createPlugin(webframe_, params); 1296 WebPlugin* webPlugin = m_webFrame->client()->createPlugin(m_webFrame, params);
1235 if (!webplugin) 1297 if (!webPlugin)
1236 return NULL; 1298 return 0;
1237 1299
1238 // The container takes ownership of the WebPlugin. 1300 // The container takes ownership of the WebPlugin.
1239 RefPtr<WebPluginContainerImpl> container = 1301 RefPtr<WebPluginContainerImpl> container =
1240 WebPluginContainerImpl::create(element, webplugin); 1302 WebPluginContainerImpl::create(element, webPlugin);
1241 1303
1242 if (!webplugin->initialize(container.get())) 1304 if (!webPlugin->initialize(container.get()))
1243 return NULL; 1305 return 0;
1244 1306
1245 // The element might have been removed during plugin initialization! 1307 // The element might have been removed during plugin initialization!
1246 if (!element->renderer()) 1308 if (!element->renderer())
1247 return NULL; 1309 return 0;
1248 1310
1249 return container; 1311 return container;
1250 } 1312 }
1251 1313
1252 // This method gets called when a plugin is put in place of html content 1314 // This method gets called when a plugin is put in place of html content
1253 // (e.g., acrobat reader). 1315 // (e.g., acrobat reader).
1254 void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) { 1316 void FrameLoaderClientImpl::redirectDataToPlugin(Widget* pluginWidget) {
1255 plugin_widget_ = static_cast<WebPluginContainerImpl*>(pluginWidget); 1317 m_pluginWidget = static_cast<WebPluginContainerImpl*>(pluginWidget);
1256 ASSERT(plugin_widget_.get()); 1318 ASSERT(m_pluginWidget.get());
1257 } 1319 }
1258 1320
1259 PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget( 1321 PassRefPtr<Widget> FrameLoaderClientImpl::createJavaAppletWidget(
1260 const IntSize& size, 1322 const IntSize& size,
1261 HTMLAppletElement* element, 1323 HTMLAppletElement* element,
1262 const KURL& /* base_url */, 1324 const KURL& /* baseURL */,
1263 const Vector<String>& param_names, 1325 const Vector<String>& paramNames,
1264 const Vector<String>& param_values) { 1326 const Vector<String>& paramValues)
1265 return createPlugin(size, element, KURL(), param_names, param_values, 1327 {
1266 "application/x-java-applet", false); 1328 return createPlugin(size, element, KURL(), paramNames, paramValues,
1267 } 1329 "application/x-java-applet", false);
1268 1330 }
1269 ObjectContentType WebFrameLoaderClient::objectContentType( 1331
1332 ObjectContentType FrameLoaderClientImpl::objectContentType(
1270 const KURL& url, 1333 const KURL& url,
1271 const String& explicit_mime_type) { 1334 const String& explicitMimeType)
1272 // This code is based on Apple's implementation from 1335 {
1273 // WebCoreSupport/WebFrameBridge.mm. 1336 // This code is based on Apple's implementation from
1274 1337 // WebCoreSupport/WebFrameBridge.mm.
1275 String mime_type = explicit_mime_type; 1338
1276 if (mime_type.isEmpty()) { 1339 String mimeType = explicitMimeType;
1277 // Try to guess the MIME type based off the extension. 1340 if (mimeType.isEmpty()) {
1278 String filename = url.lastPathComponent(); 1341 // Try to guess the MIME type based off the extension.
1279 int extension_pos = filename.reverseFind('.'); 1342 String filename = url.lastPathComponent();
1280 if (extension_pos >= 0) 1343 int extensionPos = filename.reverseFind('.');
1281 mime_type = MIMETypeRegistry::getMIMETypeForPath(url.path()); 1344 if (extensionPos >= 0)
1282 1345 mimeType = MIMETypeRegistry::getMIMETypeForPath(url.path());
1283 if (mime_type.isEmpty()) 1346
1284 return ObjectContentFrame; 1347 if (mimeType.isEmpty())
1285 } 1348 return ObjectContentFrame;
1286 1349 }
1287 if (MIMETypeRegistry::isSupportedImageMIMEType(mime_type)) 1350
1288 return ObjectContentImage; 1351 if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
1289 1352 return ObjectContentImage;
1290 // If Chrome is started with the --disable-plugins switch, pluginData is null. 1353
1291 PluginData* plugin_data = webframe_->frame()->page()->pluginData(); 1354 // If Chrome is started with the --disable-plugins switch, pluginData is 0.
1292 if (plugin_data && plugin_data->supportsMimeType(mime_type)) 1355 PluginData* pluginData = m_webFrame->frame()->page()->pluginData();
1293 return ObjectContentNetscapePlugin; 1356 if (pluginData && pluginData->supportsMimeType(mimeType))
1294 1357 return ObjectContentNetscapePlugin;
1295 if (MIMETypeRegistry::isSupportedNonImageMIMEType(mime_type)) 1358
1296 return ObjectContentFrame; 1359 if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
1297 1360 return ObjectContentFrame;
1298 return ObjectContentNone; 1361
1299 } 1362 return ObjectContentNone;
1300 1363 }
1301 String WebFrameLoaderClient::overrideMediaType() const { 1364
1302 // FIXME 1365 String FrameLoaderClientImpl::overrideMediaType() const
1303 return String(); 1366 {
1304 } 1367 // FIXME
1305 1368 return String();
1306 bool WebFrameLoaderClient::ActionSpecifiesNavigationPolicy( 1369 }
1307 const WebCore::NavigationAction& action, 1370
1308 WebNavigationPolicy* policy) { 1371 bool FrameLoaderClientImpl::actionSpecifiesNavigationPolicy(
1309 if ((action.type() != NavigationTypeLinkClicked) || 1372 const NavigationAction& action,
1310 !action.event()->isMouseEvent()) 1373 WebNavigationPolicy* policy)
1311 return false; 1374 {
1312 1375 if ((action.type() != NavigationTypeLinkClicked) || !action.event()->isMouseEvent())
1313 const MouseEvent* event = static_cast<const MouseEvent*>(action.event()); 1376 return false;
1314 return WebViewImpl::NavigationPolicyFromMouseEvent(event->button(), 1377
1315 event->ctrlKey(), event->shiftKey(), event->altKey(), event->metaKey(), 1378 const MouseEvent* event = static_cast<const MouseEvent*>(action.event());
1316 policy); 1379 return WebViewImpl::navigationPolicyFromMouseEvent(
1317 } 1380 event->button(), event->ctrlKey(), event->shiftKey(), event->altKey(),
1318 1381 event->metaKey(), policy);
1319 void WebFrameLoaderClient::HandleBackForwardNavigation(const KURL& url) { 1382 }
1320 ASSERT(url.protocolIs(WebKit::backForwardNavigationScheme)); 1383
1321 1384 void FrameLoaderClientImpl::handleBackForwardNavigation(const KURL& url)
1322 bool ok; 1385 {
1323 int offset = url.lastPathComponent().toIntStrict(&ok); 1386 ASSERT(url.protocolIs(backForwardNavigationScheme));
1324 if (!ok) 1387
1325 return; 1388 bool ok;
1326 1389 int offset = url.lastPathComponent().toIntStrict(&ok);
1327 WebViewImpl* webview = webframe_->GetWebViewImpl(); 1390 if (!ok)
1328 if (webview->client()) 1391 return;
1329 webview->client()->navigateBackForwardSoon(offset); 1392
1330 } 1393 WebViewImpl* webview = m_webFrame->viewImpl();
1331 1394 if (webview->client())
1332 PassOwnPtr<WebPluginLoadObserver> WebFrameLoaderClient::GetPluginLoadObserver() { 1395 webview->client()->navigateBackForwardSoon(offset);
1333 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader( 1396 }
1334 webframe_->frame()->loader()->activeDocumentLoader()); 1397
1335 return ds->releasePluginLoadObserver(); 1398 PassOwnPtr<WebPluginLoadObserver> FrameLoaderClientImpl::pluginLoadObserver()
1336 } 1399 {
1400 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader(
1401 m_webFrame->frame()->loader()->activeDocumentLoader());
1402 return ds->releasePluginLoadObserver();
1403 }
1404
1405 } // namespace WebKit
OLDNEW
« no previous file with comments | « webkit/api/src/FrameLoaderClientImpl.h ('k') | webkit/api/src/InspectorClientImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698