OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "Chrome.h" | 10 #include "Chrome.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "StringExtras.h" | 25 #include "StringExtras.h" |
26 #include "WindowFeatures.h" | 26 #include "WindowFeatures.h" |
27 #undef LOG | 27 #undef LOG |
28 | 28 |
29 #include "base/basictypes.h" | 29 #include "base/basictypes.h" |
30 #include "base/logging.h" | 30 #include "base/logging.h" |
31 #include "base/string_util.h" | 31 #include "base/string_util.h" |
32 #include "net/base/mime_util.h" | 32 #include "net/base/mime_util.h" |
33 #include "net/base/net_errors.h" | 33 #include "net/base/net_errors.h" |
34 #include "webkit/api/public/WebForm.h" | 34 #include "webkit/api/public/WebForm.h" |
| 35 #include "webkit/api/public/WebFrameClient.h" |
35 #include "webkit/api/public/WebPlugin.h" | 36 #include "webkit/api/public/WebPlugin.h" |
36 #include "webkit/api/public/WebPluginParams.h" | 37 #include "webkit/api/public/WebPluginParams.h" |
37 #include "webkit/api/public/WebURL.h" | 38 #include "webkit/api/public/WebURL.h" |
38 #include "webkit/api/public/WebURLError.h" | 39 #include "webkit/api/public/WebURLError.h" |
39 #include "webkit/api/public/WebVector.h" | 40 #include "webkit/api/public/WebVector.h" |
40 #include "webkit/api/src/WebDataSourceImpl.h" | 41 #include "webkit/api/src/WebDataSourceImpl.h" |
41 #include "webkit/api/src/WebPluginContainerImpl.h" | 42 #include "webkit/api/src/WebPluginContainerImpl.h" |
42 #include "webkit/api/src/WebPluginLoadObserver.h" | 43 #include "webkit/api/src/WebPluginLoadObserver.h" |
43 #include "webkit/api/src/WrappedResourceRequest.h" | 44 #include "webkit/api/src/WrappedResourceRequest.h" |
44 #include "webkit/api/src/WrappedResourceResponse.h" | 45 #include "webkit/api/src/WrappedResourceResponse.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // When the WebFrame was created, it had an extra reference given to it on | 104 // When the WebFrame was created, it had an extra reference given to it on |
104 // behalf of the Frame. Since the WebFrame owns us, this extra ref also | 105 // behalf of the Frame. Since the WebFrame owns us, this extra ref also |
105 // serves to keep us alive until the FrameLoader is done with us. The | 106 // serves to keep us alive until the FrameLoader is done with us. The |
106 // FrameLoader calls this method when it's going away. Therefore, we balance | 107 // FrameLoader calls this method when it's going away. Therefore, we balance |
107 // out that extra reference, which may cause 'this' to be deleted. | 108 // out that extra reference, which may cause 'this' to be deleted. |
108 webframe_->Closing(); | 109 webframe_->Closing(); |
109 webframe_->Release(); | 110 webframe_->Release(); |
110 } | 111 } |
111 | 112 |
112 void WebFrameLoaderClient::windowObjectCleared() { | 113 void WebFrameLoaderClient::windowObjectCleared() { |
| 114 if (webframe_->client()) |
| 115 webframe_->client()->didClearWindowObject(webframe_); |
| 116 |
113 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 117 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
114 WebViewDelegate* d = webview->delegate(); | 118 if (webview) { |
115 if (d) | 119 WebDevToolsAgentImpl* tools_agent = webview->GetWebDevToolsAgentImpl(); |
116 d->WindowObjectCleared(webframe_); | 120 if (tools_agent) |
117 | 121 tools_agent->WindowObjectCleared(webframe_); |
118 WebDevToolsAgentImpl* tools_agent = webview->GetWebDevToolsAgentImpl(); | 122 } |
119 if (tools_agent) | |
120 tools_agent->WindowObjectCleared(webframe_); | |
121 } | 123 } |
122 | 124 |
123 void WebFrameLoaderClient::documentElementAvailable() { | 125 void WebFrameLoaderClient::documentElementAvailable() { |
124 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 126 if (webframe_->client()) |
125 WebViewDelegate* d = webview->delegate(); | 127 webframe_->client()->didCreateDocumentElement(webframe_); |
126 if (d) | |
127 d->DocumentElementAvailable(webframe_); | |
128 } | 128 } |
129 | 129 |
130 void WebFrameLoaderClient::didCreateScriptContextForFrame() { | 130 void WebFrameLoaderClient::didCreateScriptContextForFrame() { |
131 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 131 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
132 WebViewDelegate* d = webview->delegate(); | 132 WebViewDelegate* d = webview->delegate(); |
133 if (d) | 133 if (d) |
134 d->DidCreateScriptContextForFrame(webframe_); | 134 d->DidCreateScriptContextForFrame(webframe_); |
135 } | 135 } |
136 | 136 |
137 void WebFrameLoaderClient::didDestroyScriptContextForFrame() { | 137 void WebFrameLoaderClient::didDestroyScriptContextForFrame() { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 | 190 |
191 void WebFrameLoaderClient::detachedFromParent3() { | 191 void WebFrameLoaderClient::detachedFromParent3() { |
192 // Close down the proxy. The purpose of this change is to make the | 192 // Close down the proxy. The purpose of this change is to make the |
193 // call to ScriptController::clearWindowShell a no-op when called from | 193 // call to ScriptController::clearWindowShell a no-op when called from |
194 // Frame::pageDestroyed. Without this change, this call to clearWindowShell | 194 // Frame::pageDestroyed. Without this change, this call to clearWindowShell |
195 // will cause a crash. If you remove/modify this, just ensure that you can | 195 // will cause a crash. If you remove/modify this, just ensure that you can |
196 // go to a page and then navigate to a new page without getting any asserts | 196 // go to a page and then navigate to a new page without getting any asserts |
197 // or crashes. | 197 // or crashes. |
198 webframe_->frame()->script()->proxy()->clearForClose(); | 198 webframe_->frame()->script()->proxy()->clearForClose(); |
| 199 |
| 200 // Drop any reference to the client since it may shortly become invalid. |
| 201 webframe_->drop_client(); |
199 } | 202 } |
200 | 203 |
201 // This function is responsible for associating the |identifier| with a given | 204 // This function is responsible for associating the |identifier| with a given |
202 // subresource load. The following functions that accept an |identifier| are | 205 // subresource load. The following functions that accept an |identifier| are |
203 // called for each subresource, so they should not be dispatched to the | 206 // called for each subresource, so they should not be dispatched to the |
204 // WebFrame. | 207 // WebFrame. |
205 void WebFrameLoaderClient::assignIdentifierToInitialRequest( | 208 void WebFrameLoaderClient::assignIdentifierToInitialRequest( |
206 unsigned long identifier, DocumentLoader* loader, | 209 unsigned long identifier, DocumentLoader* loader, |
207 const ResourceRequest& request) { | 210 const ResourceRequest& request) { |
208 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); | 211 if (webframe_->client()) { |
209 if (d) { | |
210 WrappedResourceRequest webreq(request); | 212 WrappedResourceRequest webreq(request); |
211 d->AssignIdentifierToRequest(webframe_, identifier, webreq); | 213 webframe_->client()->assignIdentifierToRequest( |
| 214 webframe_, identifier, webreq); |
212 } | 215 } |
213 } | 216 } |
214 | 217 |
215 // Determines whether the request being loaded by |loader| is a frame or a | 218 // Determines whether the request being loaded by |loader| is a frame or a |
216 // subresource. A subresource in this context is anything other than a frame -- | 219 // subresource. A subresource in this context is anything other than a frame -- |
217 // this includes images and xmlhttp requests. It is important to note that a | 220 // this includes images and xmlhttp requests. It is important to note that a |
218 // subresource is NOT limited to stuff loaded through the frame's subresource | 221 // subresource is NOT limited to stuff loaded through the frame's subresource |
219 // loader. Synchronous xmlhttp requests for example, do not go through the | 222 // loader. Synchronous xmlhttp requests for example, do not go through the |
220 // subresource loader, but we still label them as TargetIsSubResource. | 223 // subresource loader, but we still label them as TargetIsSubResource. |
221 // | 224 // |
(...skipping 21 matching lines...) Expand all Loading... |
243 request.setTargetType(DetermineTargetTypeFromLoader(loader)); | 246 request.setTargetType(DetermineTargetTypeFromLoader(loader)); |
244 } | 247 } |
245 | 248 |
246 // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document | 249 // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document |
247 // with no URL. We don't like that, so we'll rename it to about:blank. | 250 // with no URL. We don't like that, so we'll rename it to about:blank. |
248 if (request.url().isEmpty()) | 251 if (request.url().isEmpty()) |
249 request.setURL(KURL(ParsedURLString, "about:blank")); | 252 request.setURL(KURL(ParsedURLString, "about:blank")); |
250 if (request.firstPartyForCookies().isEmpty()) | 253 if (request.firstPartyForCookies().isEmpty()) |
251 request.setFirstPartyForCookies(KURL(ParsedURLString, "about:blank")); | 254 request.setFirstPartyForCookies(KURL(ParsedURLString, "about:blank")); |
252 | 255 |
253 // Give the delegate a crack at the request. | 256 // Give the WebFrameClient a crack at the request. |
254 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); | 257 if (webframe_->client()) { |
255 if (d) { | |
256 WrappedResourceRequest webreq(request); | 258 WrappedResourceRequest webreq(request); |
257 WrappedResourceResponse webresp(redirect_response); | 259 WrappedResourceResponse webresp(redirect_response); |
258 d->WillSendRequest(webframe_, identifier, &webreq, webresp); | 260 webframe_->client()->willSendRequest( |
| 261 webframe_, identifier, webreq, webresp); |
259 } | 262 } |
260 } | 263 } |
261 | 264 |
262 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, | 265 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, |
263 unsigned long identifier) { | 266 unsigned long identifier) { |
264 // FIXME | 267 // FIXME |
265 // Intended to pass through to a method on the resource load delegate. | 268 // Intended to pass through to a method on the resource load delegate. |
266 // If implemented, that method controls whether the browser should ask the | 269 // If implemented, that method controls whether the browser should ask the |
267 // networking layer for a stored default credential for the page (say from | 270 // networking layer for a stored default credential for the page (say from |
268 // the Mac OS keychain). If the method returns false, the user should be | 271 // the Mac OS keychain). If the method returns false, the user should be |
(...skipping 11 matching lines...) Expand all Loading... |
280 } | 283 } |
281 | 284 |
282 void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge( | 285 void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge( |
283 DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) { | 286 DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) { |
284 // FIXME | 287 // FIXME |
285 } | 288 } |
286 | 289 |
287 void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, | 290 void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, |
288 unsigned long identifier, | 291 unsigned long identifier, |
289 const ResourceResponse& re
sponse) { | 292 const ResourceResponse& re
sponse) { |
290 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); | 293 if (webframe_->client()) { |
291 if (d) { | |
292 WrappedResourceResponse webresp(response); | 294 WrappedResourceResponse webresp(response); |
293 d->DidReceiveResponse(webframe_, identifier, webresp); | 295 webframe_->client()->didReceiveResponse(webframe_, identifier, webresp); |
294 } | 296 } |
295 } | 297 } |
296 | 298 |
297 void WebFrameLoaderClient::dispatchDidReceiveContentLength( | 299 void WebFrameLoaderClient::dispatchDidReceiveContentLength( |
298 DocumentLoader* loader, | 300 DocumentLoader* loader, |
299 unsigned long identifier, | 301 unsigned long identifier, |
300 int length_received) { | 302 int length_received) { |
301 } | 303 } |
302 | 304 |
303 // Called when a particular resource load completes | 305 // Called when a particular resource load completes |
304 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, | 306 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, |
305 unsigned long identifier) { | 307 unsigned long identifier) { |
306 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); | 308 if (webframe_->client()) |
307 if (d) | 309 webframe_->client()->didFinishResourceLoad(webframe_, identifier); |
308 d->DidFinishLoading(webframe_, identifier); | |
309 } | 310 } |
310 | 311 |
311 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, | 312 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, |
312 unsigned long identifier, | 313 unsigned long identifier, |
313 const ResourceError& error) { | 314 const ResourceError& error) { |
314 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 315 if (webframe_->client()) { |
315 if (webview && webview->delegate()) { | 316 webframe_->client()->didFailResourceLoad( |
316 webview->delegate()->DidFailLoadingWithError( | |
317 webframe_, identifier, webkit_glue::ResourceErrorToWebURLError(error)); | 317 webframe_, identifier, webkit_glue::ResourceErrorToWebURLError(error)); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { | 321 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { |
322 WebViewImpl* webview = webframe_->GetWebViewImpl(); | |
323 DocumentLoader* documentLoader = | |
324 webframe_->frame()->loader()->activeDocumentLoader(); | |
325 WebDataSourceImpl* data_source = | |
326 WebDataSourceImpl::fromDocumentLoader(documentLoader); | |
327 | |
328 // A frame may be reused. This call ensures we don't hold on to our password | 322 // A frame may be reused. This call ensures we don't hold on to our password |
329 // listeners and their associated HTMLInputElements. | 323 // listeners and their associated HTMLInputElements. |
330 webframe_->ClearPasswordListeners(); | 324 webframe_->ClearPasswordListeners(); |
331 | 325 |
332 if (webview && webview->delegate()) | 326 if (webframe_->client()) |
333 webview->delegate()->DidFinishDocumentLoadForFrame(webview, webframe_); | 327 webframe_->client()->didFinishDocumentLoad(webframe_); |
334 } | 328 } |
335 | 329 |
336 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( | 330 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( |
337 DocumentLoader* loader, | 331 DocumentLoader* loader, |
338 const ResourceRequest& request, | 332 const ResourceRequest& request, |
339 const ResourceResponse& response, | 333 const ResourceResponse& response, |
340 int length) { | 334 int length) { |
341 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 335 if (webframe_->client()) { |
342 WebViewDelegate* d = webview->delegate(); | |
343 | |
344 bool result = false; | |
345 if (d) { | |
346 WrappedResourceRequest webreq(request); | 336 WrappedResourceRequest webreq(request); |
347 WrappedResourceResponse webresp(response); | 337 WrappedResourceResponse webresp(response); |
348 result = d->DidLoadResourceFromMemoryCache(webview, webreq, webresp, | 338 webframe_->client()->didLoadResourceFromMemoryCache( |
349 webframe_); | 339 webframe_, webreq, webresp); |
350 } | 340 } |
351 return result; | 341 return false; // Do not suppress remaining notifications |
352 } | 342 } |
353 | 343 |
354 void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest( | 344 void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest( |
355 unsigned long identifier, | 345 unsigned long identifier, |
356 const ScriptString& source) { | 346 const ScriptString& source) { |
357 } | 347 } |
358 | 348 |
359 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() { | 349 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() { |
360 // During the onload event of a subframe, the subframe can be removed. In | 350 if (webframe_->client()) |
361 // that case, it has no page. This is covered by | 351 webframe_->client()->didHandleOnloadEvents(webframe_); |
362 // LayoutTests/fast/dom/replaceChild.html | |
363 if (!webframe_->frame()->page()) | |
364 return; | |
365 WebViewImpl* webview = webframe_->GetWebViewImpl(); | |
366 WebViewDelegate* d = webview->delegate(); | |
367 if (d) | |
368 d->DidHandleOnloadEventsForFrame(webview, webframe_); | |
369 } | 352 } |
370 | 353 |
371 // Redirect Tracking | 354 // Redirect Tracking |
372 // ================= | 355 // ================= |
373 // We want to keep track of the chain of redirects that occur during page | 356 // We want to keep track of the chain of redirects that occur during page |
374 // loading. There are two types of redirects, server redirects which are HTTP | 357 // loading. There are two types of redirects, server redirects which are HTTP |
375 // response codes, and client redirects which are document.location= and meta | 358 // response codes, and client redirects which are document.location= and meta |
376 // refreshes. | 359 // refreshes. |
377 // | 360 // |
378 // This outlines the callbacks that we get in different redirect situations, | 361 // This outlines the callbacks that we get in different redirect situations, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 // A provisional load should have started already, which should have put an | 445 // A provisional load should have started already, which should have put an |
463 // entry in our redirect chain. | 446 // entry in our redirect chain. |
464 DCHECK(ds->hasRedirectChain()); | 447 DCHECK(ds->hasRedirectChain()); |
465 | 448 |
466 // The URL of the destination is on the provisional data source. We also need | 449 // The URL of the destination is on the provisional data source. We also need |
467 // to update the redirect chain to account for this addition (we do this | 450 // to update the redirect chain to account for this addition (we do this |
468 // before the callback so the callback can look at the redirect chain to see | 451 // before the callback so the callback can look at the redirect chain to see |
469 // what happened). | 452 // what happened). |
470 ds->appendRedirect(ds->request().url()); | 453 ds->appendRedirect(ds->request().url()); |
471 | 454 |
472 // Dispatch callback | 455 if (webframe_->client()) |
473 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 456 webframe_->client()->didReceiveServerRedirectForProvisionalLoad(webframe_); |
474 WebViewDelegate* d = webview->delegate(); | |
475 if (d) | |
476 d->DidReceiveProvisionalLoadServerRedirect(webview, webframe_); | |
477 } | 457 } |
478 | 458 |
479 // Called on both success and failure of a client redirect. | 459 // Called on both success and failure of a client redirect. |
480 void WebFrameLoaderClient::dispatchDidCancelClientRedirect() { | 460 void WebFrameLoaderClient::dispatchDidCancelClientRedirect() { |
481 // No longer expecting a client redirect. | 461 // No longer expecting a client redirect. |
482 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 462 if (webframe_->client()) { |
483 WebViewDelegate* d = webview ? webview->delegate() : NULL; | |
484 if (d) { | |
485 expected_client_redirect_src_ = GURL(); | 463 expected_client_redirect_src_ = GURL(); |
486 expected_client_redirect_dest_ = GURL(); | 464 expected_client_redirect_dest_ = GURL(); |
487 | 465 webframe_->client()->didCancelClientRedirect(webframe_); |
488 d->DidCancelClientRedirect(webview, webframe_); | |
489 } | 466 } |
490 | 467 |
491 // No need to clear the redirect chain, since that data source has already | 468 // No need to clear the redirect chain, since that data source has already |
492 // been deleted by the time this function is called. | 469 // been deleted by the time this function is called. |
493 } | 470 } |
494 | 471 |
495 void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const KURL& url, | 472 void WebFrameLoaderClient::dispatchWillPerformClientRedirect( |
496 double interval, | 473 const KURL& url, |
497 double fire_date) { | 474 double interval, |
| 475 double fire_date) { |
498 // Tells dispatchDidStartProvisionalLoad that if it sees this item it is a | 476 // Tells dispatchDidStartProvisionalLoad that if it sees this item it is a |
499 // redirect and the source item should be added as the start of the chain. | 477 // redirect and the source item should be added as the start of the chain. |
500 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 478 if (webframe_->client()) { |
501 WebViewDelegate* d = webview ? webview->delegate() : NULL; | |
502 if (d) { | |
503 expected_client_redirect_src_ = webframe_->url(); | 479 expected_client_redirect_src_ = webframe_->url(); |
504 expected_client_redirect_dest_ = webkit_glue::KURLToGURL(url); | 480 expected_client_redirect_dest_ = webkit_glue::KURLToGURL(url); |
505 | 481 |
506 // TODO(timsteele): bug 1135512. Webkit does not properly notify us of | 482 // TODO(timsteele): bug 1135512. Webkit does not properly notify us of |
507 // cancelling http > file client redirects. Since the FrameLoader's policy | 483 // cancelling http > file client redirects. Since the FrameLoader's policy |
508 // is to never carry out such a navigation anyway, the best thing we can do | 484 // is to never carry out such a navigation anyway, the best thing we can do |
509 // for now to not get confused is ignore this notification. | 485 // for now to not get confused is ignore this notification. |
510 if (expected_client_redirect_dest_.SchemeIsFile() && | 486 if (expected_client_redirect_dest_.SchemeIsFile() && |
511 (expected_client_redirect_src_.SchemeIs("http") || | 487 (expected_client_redirect_src_.SchemeIs("http") || |
512 expected_client_redirect_src_.SchemeIsSecure())) { | 488 expected_client_redirect_src_.SchemeIsSecure())) { |
513 expected_client_redirect_src_ = GURL(); | 489 expected_client_redirect_src_ = GURL(); |
514 expected_client_redirect_dest_ = GURL(); | 490 expected_client_redirect_dest_ = GURL(); |
515 return; | 491 return; |
516 } | 492 } |
517 | 493 |
518 d->WillPerformClientRedirect(webview, | 494 webframe_->client()->willPerformClientRedirect( |
519 webframe_, | 495 webframe_, |
520 expected_client_redirect_src_, | 496 expected_client_redirect_src_, |
521 expected_client_redirect_dest_, | 497 expected_client_redirect_dest_, |
522 static_cast<unsigned int>(interval), | 498 static_cast<unsigned int>(interval), |
523 static_cast<unsigned int>(fire_date)); | 499 static_cast<unsigned int>(fire_date)); |
524 } | 500 } |
525 } | 501 } |
526 | 502 |
527 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() { | 503 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() { |
528 // Anchor fragment navigations are not normal loads, so we need to synthesize | 504 // Anchor fragment navigations are not normal loads, so we need to synthesize |
529 // some events for our delegate. | 505 // some events for our delegate. |
530 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 506 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
531 WebViewDelegate* d = webview->delegate(); | 507 WebViewDelegate* d = webview->delegate(); |
532 if (d) | 508 if (d) |
533 d->DidStartLoading(webview); | 509 d->DidStartLoading(webview); |
534 | 510 |
535 WebDataSourceImpl* ds = webframe_->GetDataSourceImpl(); | 511 WebDataSourceImpl* ds = webframe_->GetDataSourceImpl(); |
536 DCHECK(ds) << "DataSource NULL when navigating to reference fragment"; | 512 DCHECK(ds) << "DataSource NULL when navigating to reference fragment"; |
537 if (ds) { | 513 if (ds) { |
538 GURL url = ds->request().url(); | 514 GURL url = ds->request().url(); |
539 GURL chain_end = ds->endOfRedirectChain(); | 515 GURL chain_end = ds->endOfRedirectChain(); |
540 ds->clearRedirectChain(); | 516 ds->clearRedirectChain(); |
541 | 517 |
542 // Figure out if this location change is because of a JS-initiated client | 518 // Figure out if this location change is because of a JS-initiated client |
543 // redirect (e.g onload/setTimeout document.location.href=). | 519 // redirect (e.g onload/setTimeout document.location.href=). |
544 // TODO(timsteele): (bugs 1085325, 1046841) We don't get proper redirect | 520 // TODO(timsteele): (bugs 1085325, 1046841) We don't get proper redirect |
545 // performed/cancelled notifications across anchor navigations, so the | 521 // performed/cancelled notifications across anchor navigations, so the |
546 // other redirect-tracking code in this class (see dispatch*ClientRedirect() | 522 // other redirect-tracking code in this class (see dispatch*ClientRedirect() |
547 // and dispatchDidStartProvisionalLoad) is insufficient to catch and | 523 // and dispatchDidStartProvisionalLoad) is insufficient to catch and |
548 // properly flag these transitions. Once a proper fix for this bug is | 524 // properly flag these transitions. Once a proper fix for this bug is |
549 // identified and applied the following block may no longer be required. | 525 // identified and applied the following block may no longer be required. |
550 bool was_client_redirect = | 526 bool was_client_redirect = |
551 ((url == expected_client_redirect_dest_) && | 527 (url == expected_client_redirect_dest_ && |
552 (chain_end == expected_client_redirect_src_)) || | 528 chain_end == expected_client_redirect_src_) || |
553 (NavigationGestureForLastLoad() == NavigationGestureAuto); | 529 !webframe_->isProcessingUserGesture(); |
554 | 530 |
555 if (was_client_redirect) { | 531 if (was_client_redirect) { |
556 if (d) | 532 if (webframe_->client()) |
557 d->DidCompleteClientRedirect(webview, webframe_, chain_end); | 533 webframe_->client()->didCompleteClientRedirect(webframe_, chain_end); |
558 ds->appendRedirect(chain_end); | 534 ds->appendRedirect(chain_end); |
559 // Make sure we clear the expected redirect since we just effectively | 535 // Make sure we clear the expected redirect since we just effectively |
560 // completed it. | 536 // completed it. |
561 expected_client_redirect_src_ = GURL(); | 537 expected_client_redirect_src_ = GURL(); |
562 expected_client_redirect_dest_ = GURL(); | 538 expected_client_redirect_dest_ = GURL(); |
563 } | 539 } |
564 | 540 |
565 // Regardless of how we got here, we are navigating to a URL so we need to | 541 // Regardless of how we got here, we are navigating to a URL so we need to |
566 // add it to the redirect chain. | 542 // add it to the redirect chain. |
567 ds->appendRedirect(url); | 543 ds->appendRedirect(url); |
568 } | 544 } |
569 | 545 |
570 bool is_new_navigation; | 546 bool is_new_navigation; |
571 webview->DidCommitLoad(&is_new_navigation); | 547 webview->DidCommitLoad(&is_new_navigation); |
572 if (d) { | 548 if (webframe_->client()) { |
573 d->DidChangeLocationWithinPageForFrame(webview, webframe_, | 549 webframe_->client()->didChangeLocationWithinPage( |
574 is_new_navigation); | 550 webframe_, is_new_navigation); |
575 } | 551 } |
576 | 552 |
577 if (d) | 553 if (d) |
578 d->DidStopLoading(webview); | 554 d->DidStopLoading(webview); |
579 } | 555 } |
580 | 556 |
581 void WebFrameLoaderClient::dispatchWillClose() { | 557 void WebFrameLoaderClient::dispatchWillClose() { |
582 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 558 if (webframe_->client()) |
583 WebViewDelegate* d = webview->delegate(); | 559 webframe_->client()->willClose(webframe_); |
584 if (d) | |
585 d->WillCloseFrame(webview, webframe_); | |
586 } | 560 } |
587 | 561 |
588 void WebFrameLoaderClient::dispatchDidReceiveIcon() { | 562 void WebFrameLoaderClient::dispatchDidReceiveIcon() { |
589 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 563 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
590 WebViewDelegate* d = webview->delegate(); | 564 WebViewDelegate* d = webview->delegate(); |
591 if (d) | 565 if (d) |
592 d->DidReceiveIconForFrame(webview, webframe_); | 566 d->DidReceiveIconForFrame(webview, webframe_); |
593 } | 567 } |
594 | 568 |
595 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { | 569 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { |
596 // In case a redirect occurs, we need this to be set so that the redirect | 570 // In case a redirect occurs, we need this to be set so that the redirect |
597 // handling code can tell where the redirect came from. Server redirects | 571 // handling code can tell where the redirect came from. Server redirects |
598 // will occur on the provisional load, so we need to keep track of the most | 572 // will occur on the provisional load, so we need to keep track of the most |
599 // recent provisional load URL. | 573 // recent provisional load URL. |
600 // See dispatchDidReceiveServerRedirectForProvisionalLoad. | 574 // See dispatchDidReceiveServerRedirectForProvisionalLoad. |
601 WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); | 575 WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); |
602 if (!ds) { | 576 if (!ds) { |
603 NOTREACHED() << "Attempting to provisional load but there isn't one"; | 577 NOTREACHED() << "Attempting to provisional load but there isn't one"; |
604 return; | 578 return; |
605 } | 579 } |
606 GURL url = ds->request().url(); | 580 GURL url = ds->request().url(); |
607 | 581 |
608 // Since the provisional load just started, we should have not gotten | 582 // Since the provisional load just started, we should have not gotten |
609 // any redirects yet. | 583 // any redirects yet. |
610 DCHECK(!ds->hasRedirectChain()); | 584 DCHECK(!ds->hasRedirectChain()); |
611 | 585 |
612 WebViewImpl* webview = webframe_->GetWebViewImpl(); | |
613 WebViewDelegate* d = webview->delegate(); | |
614 // If this load is what we expected from a client redirect, treat it as a | 586 // If this load is what we expected from a client redirect, treat it as a |
615 // redirect from that original page. The expected redirect urls will be | 587 // redirect from that original page. The expected redirect urls will be |
616 // cleared by DidCancelClientRedirect. | 588 // cleared by DidCancelClientRedirect. |
617 bool completing_client_redirect = false; | 589 bool completing_client_redirect = false; |
618 if (expected_client_redirect_src_.is_valid()) { | 590 if (expected_client_redirect_src_.is_valid()) { |
619 // expected_client_redirect_dest_ could be something like | 591 // expected_client_redirect_dest_ could be something like |
620 // "javascript:history.go(-1)" thus we need to exclude url starts with | 592 // "javascript:history.go(-1)" thus we need to exclude url starts with |
621 // "javascript:". See bug: 1080873 | 593 // "javascript:". See bug: 1080873 |
622 DCHECK(expected_client_redirect_dest_.SchemeIs("javascript") || | 594 DCHECK(expected_client_redirect_dest_.SchemeIs("javascript") || |
623 expected_client_redirect_dest_ == url); | 595 expected_client_redirect_dest_ == url); |
624 ds->appendRedirect(expected_client_redirect_src_); | 596 ds->appendRedirect(expected_client_redirect_src_); |
625 completing_client_redirect = true; | 597 completing_client_redirect = true; |
626 } | 598 } |
627 ds->appendRedirect(url); | 599 ds->appendRedirect(url); |
628 | 600 |
629 if (d) { | 601 if (webframe_->client()) { |
630 // As the comment for DidCompleteClientRedirect in webview_delegate.h | 602 // As the comment for DidCompleteClientRedirect in webview_delegate.h |
631 // points out, whatever information its invocation contains should only | 603 // points out, whatever information its invocation contains should only |
632 // be considered relevant until the next provisional load has started. | 604 // be considered relevant until the next provisional load has started. |
633 // So we first tell the delegate that the load started, and then tell it | 605 // So we first tell the delegate that the load started, and then tell it |
634 // about the client redirect the load is responsible for completing. | 606 // about the client redirect the load is responsible for completing. |
635 d->DidStartProvisionalLoadForFrame(webview, webframe_, | 607 webframe_->client()->didStartProvisionalLoad(webframe_); |
636 NavigationGestureForLastLoad()); | |
637 if (completing_client_redirect) | 608 if (completing_client_redirect) |
638 d->DidCompleteClientRedirect(webview, webframe_, | 609 webframe_->client()->didCompleteClientRedirect( |
639 expected_client_redirect_src_); | 610 webframe_, expected_client_redirect_src_); |
640 } | 611 } |
641 } | 612 } |
642 | 613 |
643 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) { | 614 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) { |
644 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 615 if (webframe_->client()) { |
645 WebViewDelegate* d = webview->delegate(); | 616 webframe_->client()->didReceiveTitle( |
646 if (d) { | 617 webframe_, webkit_glue::StringToWebString(title)); |
647 d->DidReceiveTitle(webview, webkit_glue::StringToStdWString(title), | |
648 webframe_); | |
649 } | 618 } |
650 } | 619 } |
651 | 620 |
652 void WebFrameLoaderClient::dispatchDidCommitLoad() { | 621 void WebFrameLoaderClient::dispatchDidCommitLoad() { |
653 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 622 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
654 bool is_new_navigation; | 623 bool is_new_navigation; |
655 webview->DidCommitLoad(&is_new_navigation); | 624 webview->DidCommitLoad(&is_new_navigation); |
656 WebViewDelegate* d = webview->delegate(); | 625 |
657 if (d) | 626 if (webframe_->client()) { |
658 d->DidCommitLoadForFrame(webview, webframe_, is_new_navigation); | 627 webframe_->client()->didCommitProvisionalLoad( |
| 628 webframe_, is_new_navigation); |
| 629 } |
659 | 630 |
660 WebDevToolsAgentImpl* tools_agent = webview->GetWebDevToolsAgentImpl(); | 631 WebDevToolsAgentImpl* tools_agent = webview->GetWebDevToolsAgentImpl(); |
661 if (tools_agent) { | 632 if (tools_agent) { |
662 tools_agent->DidCommitLoadForFrame(webview, webframe_, is_new_navigation); | 633 tools_agent->DidCommitLoadForFrame(webview, webframe_, is_new_navigation); |
663 } | 634 } |
664 } | 635 } |
665 | 636 |
666 void WebFrameLoaderClient::dispatchDidFailProvisionalLoad( | 637 void WebFrameLoaderClient::dispatchDidFailProvisionalLoad( |
667 const ResourceError& error) { | 638 const ResourceError& error) { |
668 // If a policy change occured, then we do not want to inform the plugin | 639 // If a policy change occured, then we do not want to inform the plugin |
(...skipping 19 matching lines...) Expand all Loading... |
688 plugin_load_observer->didFailLoading(error); | 659 plugin_load_observer->didFailLoading(error); |
689 | 660 |
690 // Don't clear the redirect chain, this will happen in the middle of client | 661 // Don't clear the redirect chain, this will happen in the middle of client |
691 // redirects, and we need the context. The chain will be cleared when the | 662 // redirects, and we need the context. The chain will be cleared when the |
692 // provisional load succeeds or fails, not the "real" one. | 663 // provisional load succeeds or fails, not the "real" one. |
693 } | 664 } |
694 | 665 |
695 void WebFrameLoaderClient::dispatchDidFinishLoad() { | 666 void WebFrameLoaderClient::dispatchDidFinishLoad() { |
696 OwnPtr<WebPluginLoadObserver> plugin_load_observer = GetPluginLoadObserver(); | 667 OwnPtr<WebPluginLoadObserver> plugin_load_observer = GetPluginLoadObserver(); |
697 | 668 |
698 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 669 if (webframe_->client()) |
699 WebViewDelegate* d = webview->delegate(); | 670 webframe_->client()->didFinishLoad(webframe_); |
700 if (d) | 671 |
701 d->DidFinishLoadForFrame(webview, webframe_); | |
702 if (plugin_load_observer) | 672 if (plugin_load_observer) |
703 plugin_load_observer->didFinishLoading(); | 673 plugin_load_observer->didFinishLoading(); |
704 | 674 |
705 // Don't clear the redirect chain, this will happen in the middle of client | 675 // Don't clear the redirect chain, this will happen in the middle of client |
706 // redirects, and we need the context. The chain will be cleared when the | 676 // redirects, and we need the context. The chain will be cleared when the |
707 // provisional load succeeds or fails, not the "real" one. | 677 // provisional load succeeds or fails, not the "real" one. |
708 } | 678 } |
709 | 679 |
710 void WebFrameLoaderClient::dispatchDidFirstLayout() { | 680 void WebFrameLoaderClient::dispatchDidFirstLayout() { |
711 } | 681 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 (webframe_->frame()->loader()->*function)(policy_action); | 798 (webframe_->frame()->loader()->*function)(policy_action); |
829 } | 799 } |
830 | 800 |
831 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( | 801 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( |
832 WebCore::FramePolicyFunction function, | 802 WebCore::FramePolicyFunction function, |
833 const WebCore::NavigationAction& action, | 803 const WebCore::NavigationAction& action, |
834 const WebCore::ResourceRequest& request, | 804 const WebCore::ResourceRequest& request, |
835 PassRefPtr<WebCore::FormState> form_state) { | 805 PassRefPtr<WebCore::FormState> form_state) { |
836 PolicyAction policy_action = PolicyIgnore; | 806 PolicyAction policy_action = PolicyIgnore; |
837 | 807 |
838 WebViewImpl* wv = webframe_->GetWebViewImpl(); | |
839 WebViewDelegate* d = wv->delegate(); | |
840 // It is valid for this function to be invoked in code paths where the | 808 // It is valid for this function to be invoked in code paths where the |
841 // the webview is closed. | 809 // the webview is closed. |
842 // The NULL check here is to fix a crash that seems strange | 810 // The NULL check here is to fix a crash that seems strange |
843 // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). | 811 // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). |
844 if (d && !request.url().isNull()) { | 812 if (webframe_->client() && !request.url().isNull()) { |
845 WebNavigationPolicy navigation_policy = | 813 WebNavigationPolicy navigation_policy = |
846 WebKit::WebNavigationPolicyCurrentTab; | 814 WebKit::WebNavigationPolicyCurrentTab; |
847 ActionSpecifiesNavigationPolicy(action, &navigation_policy); | 815 ActionSpecifiesNavigationPolicy(action, &navigation_policy); |
848 | 816 |
849 // Give the delegate a chance to change the navigation policy. | 817 // Give the delegate a chance to change the navigation policy. |
850 const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); | 818 const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); |
851 if (ds) { | 819 if (ds) { |
852 GURL url = ds->request().url(); | 820 GURL url = ds->request().url(); |
853 if (url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)) { | 821 if (url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)) { |
854 HandleBackForwardNavigation(url); | 822 HandleBackForwardNavigation(url); |
855 navigation_policy = WebKit::WebNavigationPolicyIgnore; | 823 navigation_policy = WebKit::WebNavigationPolicyIgnore; |
856 } else { | 824 } else { |
857 bool is_redirect = ds->hasRedirectChain(); | 825 bool is_redirect = ds->hasRedirectChain(); |
858 | 826 |
859 WebNavigationType webnav_type = | 827 WebNavigationType webnav_type = |
860 WebDataSourceImpl::toWebNavigationType(action.type()); | 828 WebDataSourceImpl::toWebNavigationType(action.type()); |
861 | 829 |
862 navigation_policy = d->PolicyForNavigationAction( | 830 navigation_policy = webframe_->client()->decidePolicyForNavigation( |
863 wv, webframe_, ds->request(), webnav_type, navigation_policy, | 831 webframe_, ds->request(), webnav_type, navigation_policy, |
864 is_redirect); | 832 is_redirect); |
865 } | 833 } |
866 } | 834 } |
867 | 835 |
868 if (navigation_policy == WebKit::WebNavigationPolicyCurrentTab) { | 836 if (navigation_policy == WebKit::WebNavigationPolicyCurrentTab) { |
869 policy_action = PolicyUse; | 837 policy_action = PolicyUse; |
870 } else if (navigation_policy == WebKit::WebNavigationPolicyDownload) { | 838 } else if (navigation_policy == WebKit::WebNavigationPolicyDownload) { |
871 policy_action = PolicyDownload; | 839 policy_action = PolicyDownload; |
872 } else { | 840 } else { |
873 if (navigation_policy != WebKit::WebNavigationPolicyIgnore) { | 841 if (navigation_policy != WebKit::WebNavigationPolicyIgnore) { |
874 GURL referrer = webkit_glue::StringToGURL( | 842 WrappedResourceRequest webreq(request); |
875 request.httpHeaderField("Referer")); | 843 webframe_->client()->loadURLExternally( |
876 | 844 webframe_, webreq, navigation_policy); |
877 d->OpenURL(webframe_->GetWebViewImpl(), | |
878 webkit_glue::KURLToGURL(request.url()), | |
879 referrer, | |
880 navigation_policy); | |
881 } | 845 } |
882 policy_action = PolicyIgnore; | 846 policy_action = PolicyIgnore; |
883 } | 847 } |
884 } | 848 } |
885 | 849 |
886 (webframe_->frame()->loader()->*function)(policy_action); | 850 (webframe_->frame()->loader()->*function)(policy_action); |
887 } | 851 } |
888 | 852 |
889 void WebFrameLoaderClient::cancelPolicyCheck() { | 853 void WebFrameLoaderClient::cancelPolicyCheck() { |
890 // FIXME | 854 // FIXME |
891 } | 855 } |
892 | 856 |
893 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&)
{ | 857 void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&)
{ |
894 // FIXME | 858 // FIXME |
895 } | 859 } |
896 | 860 |
897 void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, | 861 void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function, |
898 PassRefPtr<FormState> form_ref) { | 862 PassRefPtr<FormState> form_ref) { |
899 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 863 if (webframe_->client()) { |
900 WebViewDelegate* d = webview->delegate(); | 864 webframe_->client()->willSubmitForm( |
901 if (d) { | 865 webframe_, webkit_glue::HTMLFormElementToWebForm(form_ref->form())); |
902 d->WillSubmitForm(webview, webframe_, | |
903 webkit_glue::HTMLFormElementToWebForm(form_ref->form())); | |
904 } | 866 } |
905 (webframe_->frame()->loader()->*function)(PolicyUse); | 867 (webframe_->frame()->loader()->*function)(PolicyUse); |
906 } | 868 } |
907 | 869 |
908 void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*) { | 870 void WebFrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*) { |
909 // FIXME | 871 // FIXME |
910 } | 872 } |
911 | 873 |
912 void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*) { | 874 void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*) { |
913 has_representation_ = true; | 875 has_representation_ = true; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 // FIXME | 929 // FIXME |
968 } | 930 } |
969 | 931 |
970 void WebFrameLoaderClient::didChangeTitle(DocumentLoader*) { | 932 void WebFrameLoaderClient::didChangeTitle(DocumentLoader*) { |
971 // FIXME | 933 // FIXME |
972 } | 934 } |
973 | 935 |
974 // Called whenever data is received. | 936 // Called whenever data is received. |
975 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* dat
a, int length) { | 937 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* dat
a, int length) { |
976 if (!plugin_widget_.get()) { | 938 if (!plugin_widget_.get()) { |
977 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); | 939 if (webframe_->client()) { |
978 if (d) | 940 bool preventDefault = false; |
979 d->DidReceiveDocumentData(webframe_, data, length); | 941 webframe_->client()->didReceiveDocumentData(webframe_, data, length, preve
ntDefault); |
| 942 if (!preventDefault) |
| 943 webframe_->commitDocumentData(data, length); |
| 944 } |
980 } | 945 } |
981 | 946 |
982 // If we are sending data to WebCore::MediaDocument, we should stop here | 947 // If we are sending data to WebCore::MediaDocument, we should stop here |
983 // and cancel the request. | 948 // and cancel the request. |
984 if (webframe_->frame()->document() && | 949 if (webframe_->frame()->document() && |
985 webframe_->frame()->document()->isMediaDocument()) { | 950 webframe_->frame()->document()->isMediaDocument()) { |
986 loader->cancelMainResourceLoad( | 951 loader->cancelMainResourceLoad( |
987 pluginWillHandleLoadError(loader->response())); | 952 pluginWillHandleLoadError(loader->response())); |
988 } | 953 } |
989 | 954 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 } | 1116 } |
1152 | 1117 |
1153 void WebFrameLoaderClient::prepareForDataSourceReplacement() { | 1118 void WebFrameLoaderClient::prepareForDataSourceReplacement() { |
1154 // FIXME | 1119 // FIXME |
1155 } | 1120 } |
1156 | 1121 |
1157 PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader( | 1122 PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader( |
1158 const ResourceRequest& request, | 1123 const ResourceRequest& request, |
1159 const SubstituteData& data) { | 1124 const SubstituteData& data) { |
1160 RefPtr<WebDataSourceImpl> ds = WebDataSourceImpl::create(request, data); | 1125 RefPtr<WebDataSourceImpl> ds = WebDataSourceImpl::create(request, data); |
1161 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); | 1126 if (webframe_->client()) |
1162 if (d) | 1127 webframe_->client()->didCreateDataSource(webframe_, ds.get()); |
1163 d->DidCreateDataSource(webframe_, ds.get()); | |
1164 return ds.release(); | 1128 return ds.release(); |
1165 } | 1129 } |
1166 | 1130 |
1167 void WebFrameLoaderClient::setTitle(const String& title, const KURL& url) { | 1131 void WebFrameLoaderClient::setTitle(const String& title, const KURL& url) { |
1168 // FIXME: monitor for changes in WebFrameLoaderClient.mm | 1132 // FIXME: monitor for changes in WebFrameLoaderClient.mm |
1169 // FIXME: Set the title of the current history item. HistoryItemImpl's setter | 1133 // FIXME: Set the title of the current history item. HistoryItemImpl's setter |
1170 // will notify its clients (e.g. the history database) that the title | 1134 // will notify its clients (e.g. the history database) that the title |
1171 // has changed. | 1135 // has changed. |
1172 // | 1136 // |
1173 // e.g.: | 1137 // e.g.: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 // fallback plugin handler that allows you to install a missing | 1203 // fallback plugin handler that allows you to install a missing |
1240 // plugin. Since we don't yet have a default plugin handler, we | 1204 // plugin. Since we don't yet have a default plugin handler, we |
1241 // need to return NULL here rather than going through all the | 1205 // need to return NULL here rather than going through all the |
1242 // plugin-creation IPCs only to discover we don't have a plugin | 1206 // plugin-creation IPCs only to discover we don't have a plugin |
1243 // registered, which causes a crash. | 1207 // registered, which causes a crash. |
1244 // TODO(evanm): remove me once we have a default plugin. | 1208 // TODO(evanm): remove me once we have a default plugin. |
1245 if (objectContentType(url, mime_type) != ObjectContentNetscapePlugin) | 1209 if (objectContentType(url, mime_type) != ObjectContentNetscapePlugin) |
1246 return NULL; | 1210 return NULL; |
1247 #endif | 1211 #endif |
1248 | 1212 |
1249 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 1213 if (!webframe_->client()) |
1250 if (!webview->delegate()) | |
1251 return NULL; | 1214 return NULL; |
1252 | 1215 |
1253 WebPluginParams params; | 1216 WebPluginParams params; |
1254 params.url = webkit_glue::KURLToWebURL(url); | 1217 params.url = webkit_glue::KURLToWebURL(url); |
1255 params.mimeType = webkit_glue::StringToWebString(mime_type); | 1218 params.mimeType = webkit_glue::StringToWebString(mime_type); |
1256 CopyStringVector(param_names, ¶ms.attributeNames); | 1219 CopyStringVector(param_names, ¶ms.attributeNames); |
1257 CopyStringVector(param_values, ¶ms.attributeValues); | 1220 CopyStringVector(param_values, ¶ms.attributeValues); |
1258 params.loadManually = load_manually; | 1221 params.loadManually = load_manually; |
1259 | 1222 |
1260 WebPlugin* webplugin = webview->delegate()->CreatePlugin(webframe_, params); | 1223 WebPlugin* webplugin = webframe_->client()->createPlugin(webframe_, params); |
1261 if (!webplugin) | 1224 if (!webplugin) |
1262 return NULL; | 1225 return NULL; |
1263 | 1226 |
1264 // The container takes ownership of the WebPlugin. | 1227 // The container takes ownership of the WebPlugin. |
1265 RefPtr<WebPluginContainerImpl> container = | 1228 RefPtr<WebPluginContainerImpl> container = |
1266 WebPluginContainerImpl::create(element, webplugin); | 1229 WebPluginContainerImpl::create(element, webplugin); |
1267 | 1230 |
1268 if (!webplugin->initialize(container.get())) | 1231 if (!webplugin->initialize(container.get())) |
1269 return NULL; | 1232 return NULL; |
1270 | 1233 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 } else { | 1317 } else { |
1355 if (shift) { | 1318 if (shift) { |
1356 *policy = WebKit::WebNavigationPolicyNewWindow; | 1319 *policy = WebKit::WebNavigationPolicyNewWindow; |
1357 } else { | 1320 } else { |
1358 *policy = WebKit::WebNavigationPolicyDownload; | 1321 *policy = WebKit::WebNavigationPolicyDownload; |
1359 } | 1322 } |
1360 } | 1323 } |
1361 return true; | 1324 return true; |
1362 } | 1325 } |
1363 | 1326 |
1364 NavigationGesture WebFrameLoaderClient::NavigationGestureForLastLoad() { | |
1365 // TODO(timsteele): isProcessingUserGesture() returns too many false positives | |
1366 // (see bug 1051891) to trust it and assign NavigationGestureUser, so | |
1367 // for now we assign Unknown in those cases and Auto otherwise. | |
1368 // (Issue 874811 known false negative as well). | |
1369 return webframe_->frame()->loader()->isProcessingUserGesture() ? | |
1370 NavigationGestureUnknown : | |
1371 NavigationGestureAuto; | |
1372 } | |
1373 | |
1374 void WebFrameLoaderClient::HandleBackForwardNavigation(const GURL& url) { | 1327 void WebFrameLoaderClient::HandleBackForwardNavigation(const GURL& url) { |
1375 DCHECK(url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)); | 1328 DCHECK(url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)); |
1376 | 1329 |
1377 std::string offset_str = url.ExtractFileName(); | 1330 std::string offset_str = url.ExtractFileName(); |
1378 int offset; | 1331 int offset; |
1379 if (!StringToInt(offset_str, &offset)) | 1332 if (!StringToInt(offset_str, &offset)) |
1380 return; | 1333 return; |
1381 | 1334 |
1382 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); | 1335 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); |
1383 if (d) | 1336 if (d) |
1384 d->NavigateBackForwardSoon(offset); | 1337 d->NavigateBackForwardSoon(offset); |
1385 } | 1338 } |
1386 | 1339 |
1387 PassOwnPtr<WebPluginLoadObserver> WebFrameLoaderClient::GetPluginLoadObserver()
{ | 1340 PassOwnPtr<WebPluginLoadObserver> WebFrameLoaderClient::GetPluginLoadObserver()
{ |
1388 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader( | 1341 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader( |
1389 webframe_->frame()->loader()->activeDocumentLoader()); | 1342 webframe_->frame()->loader()->activeDocumentLoader()); |
1390 return ds->releasePluginLoadObserver(); | 1343 return ds->releasePluginLoadObserver(); |
1391 } | 1344 } |
OLD | NEW |