| 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> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "Chrome.h" | 7 #include "Chrome.h" |
| 11 #include "CString.h" | 8 #include "CString.h" |
| 12 #include "Document.h" | 9 #include "Document.h" |
| 13 #include "DocumentLoader.h" | 10 #include "DocumentLoader.h" |
| 14 #include "HTMLAppletElement.h" | 11 #include "HTMLAppletElement.h" |
| 15 #include "HTMLFormElement.h" // needed by FormState.h | 12 #include "HTMLFormElement.h" // needed by FormState.h |
| 16 #include "HTMLNames.h" | 13 #include "HTMLNames.h" |
| 17 #include "FormState.h" | 14 #include "FormState.h" |
| 18 #include "FrameLoader.h" | 15 #include "FrameLoader.h" |
| 19 #include "FrameLoadRequest.h" | 16 #include "FrameLoadRequest.h" |
| 20 #include "HitTestResult.h" | 17 #include "HitTestResult.h" |
| 21 #include "MIMETypeRegistry.h" | 18 #include "MIMETypeRegistry.h" |
| 22 #include "MouseEvent.h" | 19 #include "MouseEvent.h" |
| 23 #include "Page.h" | 20 #include "Page.h" |
| 24 #include "PlatformString.h" | 21 #include "PlatformString.h" |
| 25 #include "PluginData.h" | 22 #include "PluginData.h" |
| 26 #include "StringExtras.h" | 23 #include "StringExtras.h" |
| 27 #include "WindowFeatures.h" | 24 #include "WindowFeatures.h" |
| 28 #undef LOG | 25 #undef LOG |
| 29 | 26 |
| 30 #include "base/basictypes.h" | |
| 31 #include "base/logging.h" | |
| 32 #include "base/string_util.h" | |
| 33 #include "net/base/mime_util.h" | 27 #include "net/base/mime_util.h" |
| 34 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
| 35 #include "webkit/api/public/WebForm.h" | 29 #include "webkit/api/public/WebForm.h" |
| 36 #include "webkit/api/public/WebFrameClient.h" | 30 #include "webkit/api/public/WebFrameClient.h" |
| 37 #include "webkit/api/public/WebNode.h" | 31 #include "webkit/api/public/WebNode.h" |
| 38 #include "webkit/api/public/WebPlugin.h" | 32 #include "webkit/api/public/WebPlugin.h" |
| 39 #include "webkit/api/public/WebPluginParams.h" | 33 #include "webkit/api/public/WebPluginParams.h" |
| 40 #include "webkit/api/public/WebSecurityOrigin.h" | 34 #include "webkit/api/public/WebSecurityOrigin.h" |
| 41 #include "webkit/api/public/WebURL.h" | 35 #include "webkit/api/public/WebURL.h" |
| 42 #include "webkit/api/public/WebURLError.h" | 36 #include "webkit/api/public/WebURLError.h" |
| 43 #include "webkit/api/public/WebVector.h" | 37 #include "webkit/api/public/WebVector.h" |
| 44 #include "webkit/api/src/WebDataSourceImpl.h" | 38 #include "webkit/api/src/WebDataSourceImpl.h" |
| 45 #include "webkit/api/src/WebPluginContainerImpl.h" | 39 #include "webkit/api/src/WebPluginContainerImpl.h" |
| 46 #include "webkit/api/src/WebPluginLoadObserver.h" | 40 #include "webkit/api/src/WebPluginLoadObserver.h" |
| 47 #include "webkit/api/src/WrappedResourceRequest.h" | 41 #include "webkit/api/src/WrappedResourceRequest.h" |
| 48 #include "webkit/api/src/WrappedResourceResponse.h" | 42 #include "webkit/api/src/WrappedResourceResponse.h" |
| 49 #include "webkit/glue/glue_util.h" | 43 #include "webkit/glue/glue_util.h" |
| 50 #include "webkit/glue/plugins/plugin_list.h" | |
| 51 #include "webkit/glue/webdevtoolsagent_impl.h" | 44 #include "webkit/glue/webdevtoolsagent_impl.h" |
| 52 #include "webkit/glue/webframe_impl.h" | 45 #include "webkit/glue/webframe_impl.h" |
| 53 #include "webkit/glue/webframeloaderclient_impl.h" | 46 #include "webkit/glue/webframeloaderclient_impl.h" |
| 54 #include "webkit/glue/webkit_glue.h" | 47 #include "webkit/glue/webkit_glue.h" |
| 55 #include "webkit/glue/webview_delegate.h" | |
| 56 #include "webkit/glue/webview_impl.h" | 48 #include "webkit/glue/webview_impl.h" |
| 57 | 49 |
| 58 using namespace WebCore; | 50 using namespace WebCore; |
| 59 | 51 |
| 60 using base::Time; | |
| 61 using base::TimeDelta; | |
| 62 | |
| 63 using WebKit::WebData; | 52 using WebKit::WebData; |
| 64 using WebKit::WebDataSourceImpl; | 53 using WebKit::WebDataSourceImpl; |
| 65 using WebKit::WebNavigationType; | 54 using WebKit::WebNavigationType; |
| 66 using WebKit::WebNavigationPolicy; | 55 using WebKit::WebNavigationPolicy; |
| 67 using WebKit::WebNode; | 56 using WebKit::WebNode; |
| 68 using WebKit::WebPlugin; | 57 using WebKit::WebPlugin; |
| 69 using WebKit::WebPluginContainerImpl; | 58 using WebKit::WebPluginContainerImpl; |
| 70 using WebKit::WebPluginLoadObserver; | 59 using WebKit::WebPluginLoadObserver; |
| 71 using WebKit::WebPluginParams; | 60 using WebKit::WebPluginParams; |
| 72 using WebKit::WebString; | 61 using WebKit::WebString; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 // dispatchDidCommitLoad() -> DISPATCHES
1#anchor | 411 // dispatchDidCommitLoad() -> DISPATCHES
1#anchor |
| 423 // dispatchWillPerformClientRedirect() -> saves exp.
source (1#anchor) | 412 // dispatchWillPerformClientRedirect() -> saves exp.
source (1#anchor) |
| 424 // -- redirect timer fires | 413 // -- redirect timer fires |
| 425 // dispatchDidStartProvisionalLoad() -> appends 1#a
nchor (src) and 1 (dest) | 414 // dispatchDidStartProvisionalLoad() -> appends 1#a
nchor (src) and 1 (dest) |
| 426 // dispatchDidCancelClientRedirect() -> clears expe
cted redirect | 415 // dispatchDidCancelClientRedirect() -> clears expe
cted redirect |
| 427 // dispatchDidCommitLoad() -> DISPATCHES
1#anchor + 1 | 416 // dispatchDidCommitLoad() -> DISPATCHES
1#anchor + 1 |
| 428 // | 417 // |
| 429 void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
{ | 418 void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
{ |
| 430 WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); | 419 WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); |
| 431 if (!ds) { | 420 if (!ds) { |
| 432 NOTREACHED() << "Got a server redirect when there is no provisional DS"; | 421 // Got a server redirect when there is no provisional DS! |
| 422 ASSERT_NOT_REACHED(); |
| 433 return; | 423 return; |
| 434 } | 424 } |
| 435 | 425 |
| 436 // The server redirect may have been blocked. | 426 // The server redirect may have been blocked. |
| 437 if (ds->request().isNull()) | 427 if (ds->request().isNull()) |
| 438 return; | 428 return; |
| 439 | 429 |
| 440 // A provisional load should have started already, which should have put an | 430 // A provisional load should have started already, which should have put an |
| 441 // entry in our redirect chain. | 431 // entry in our redirect chain. |
| 442 DCHECK(ds->hasRedirectChain()); | 432 ASSERT(ds->hasRedirectChain()); |
| 443 | 433 |
| 444 // The URL of the destination is on the provisional data source. We also need | 434 // The URL of the destination is on the provisional data source. We also need |
| 445 // to update the redirect chain to account for this addition (we do this | 435 // to update the redirect chain to account for this addition (we do this |
| 446 // before the callback so the callback can look at the redirect chain to see | 436 // before the callback so the callback can look at the redirect chain to see |
| 447 // what happened). | 437 // what happened). |
| 448 ds->appendRedirect(ds->request().url()); | 438 ds->appendRedirect(webkit_glue::WebURLToKURL(ds->request().url())); |
| 449 | 439 |
| 450 if (webframe_->client()) | 440 if (webframe_->client()) |
| 451 webframe_->client()->didReceiveServerRedirectForProvisionalLoad(webframe_); | 441 webframe_->client()->didReceiveServerRedirectForProvisionalLoad(webframe_); |
| 452 } | 442 } |
| 453 | 443 |
| 454 // Called on both success and failure of a client redirect. | 444 // Called on both success and failure of a client redirect. |
| 455 void WebFrameLoaderClient::dispatchDidCancelClientRedirect() { | 445 void WebFrameLoaderClient::dispatchDidCancelClientRedirect() { |
| 456 // No longer expecting a client redirect. | 446 // No longer expecting a client redirect. |
| 457 if (webframe_->client()) { | 447 if (webframe_->client()) { |
| 458 expected_client_redirect_src_ = GURL(); | 448 expected_client_redirect_src_ = KURL(); |
| 459 expected_client_redirect_dest_ = GURL(); | 449 expected_client_redirect_dest_ = KURL(); |
| 460 webframe_->client()->didCancelClientRedirect(webframe_); | 450 webframe_->client()->didCancelClientRedirect(webframe_); |
| 461 } | 451 } |
| 462 | 452 |
| 463 // No need to clear the redirect chain, since that data source has already | 453 // No need to clear the redirect chain, since that data source has already |
| 464 // been deleted by the time this function is called. | 454 // been deleted by the time this function is called. |
| 465 } | 455 } |
| 466 | 456 |
| 467 void WebFrameLoaderClient::dispatchWillPerformClientRedirect( | 457 void WebFrameLoaderClient::dispatchWillPerformClientRedirect( |
| 468 const KURL& url, | 458 const KURL& url, |
| 469 double interval, | 459 double interval, |
| 470 double fire_date) { | 460 double fire_date) { |
| 471 // Tells dispatchDidStartProvisionalLoad that if it sees this item it is a | 461 // Tells dispatchDidStartProvisionalLoad that if it sees this item it is a |
| 472 // redirect and the source item should be added as the start of the chain. | 462 // redirect and the source item should be added as the start of the chain. |
| 473 expected_client_redirect_src_ = webframe_->url(); | 463 expected_client_redirect_src_ = webkit_glue::WebURLToKURL(webframe_->url()); |
| 474 expected_client_redirect_dest_ = webkit_glue::KURLToGURL(url); | 464 expected_client_redirect_dest_ = url; |
| 475 | 465 |
| 476 // TODO(timsteele): bug 1135512. Webkit does not properly notify us of | 466 // TODO(timsteele): bug 1135512. Webkit does not properly notify us of |
| 477 // cancelling http > file client redirects. Since the FrameLoader's policy | 467 // cancelling http > file client redirects. Since the FrameLoader's policy |
| 478 // is to never carry out such a navigation anyway, the best thing we can do | 468 // is to never carry out such a navigation anyway, the best thing we can do |
| 479 // for now to not get confused is ignore this notification. | 469 // for now to not get confused is ignore this notification. |
| 480 if (expected_client_redirect_dest_.SchemeIsFile() && | 470 if (expected_client_redirect_dest_.isLocalFile() && |
| 481 (expected_client_redirect_src_.SchemeIs("http") || | 471 expected_client_redirect_src_.protocolInHTTPFamily()) { |
| 482 expected_client_redirect_src_.SchemeIsSecure())) { | 472 expected_client_redirect_src_ = KURL(); |
| 483 expected_client_redirect_src_ = GURL(); | 473 expected_client_redirect_dest_ = KURL(); |
| 484 expected_client_redirect_dest_ = GURL(); | |
| 485 return; | 474 return; |
| 486 } | 475 } |
| 487 | 476 |
| 488 if (webframe_->client()) { | 477 if (webframe_->client()) { |
| 489 webframe_->client()->willPerformClientRedirect( | 478 webframe_->client()->willPerformClientRedirect( |
| 490 webframe_, | 479 webframe_, |
| 491 expected_client_redirect_src_, | 480 webkit_glue::KURLToWebURL(expected_client_redirect_src_), |
| 492 expected_client_redirect_dest_, | 481 webkit_glue::KURLToWebURL(expected_client_redirect_dest_), |
| 493 static_cast<unsigned int>(interval), | 482 static_cast<unsigned int>(interval), |
| 494 static_cast<unsigned int>(fire_date)); | 483 static_cast<unsigned int>(fire_date)); |
| 495 } | 484 } |
| 496 } | 485 } |
| 497 | 486 |
| 498 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() { | 487 void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() { |
| 499 // Anchor fragment navigations are not normal loads, so we need to synthesize | 488 // Anchor fragment navigations are not normal loads, so we need to synthesize |
| 500 // some events for our delegate. | 489 // some events for our delegate. |
| 501 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 490 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 502 if (webview->client()) | 491 if (webview->client()) |
| 503 webview->client()->didStartLoading(); | 492 webview->client()->didStartLoading(); |
| 504 | 493 |
| 505 WebDataSourceImpl* ds = webframe_->GetDataSourceImpl(); | 494 WebDataSourceImpl* ds = webframe_->GetDataSourceImpl(); |
| 506 DCHECK(ds) << "DataSource NULL when navigating to reference fragment"; | 495 ASSERT(ds); // Should not be null when navigating to a reference fragment! |
| 507 if (ds) { | 496 if (ds) { |
| 508 GURL url = ds->request().url(); | 497 KURL url = webkit_glue::WebURLToKURL(ds->request().url()); |
| 509 GURL chain_end = ds->endOfRedirectChain(); | 498 KURL chain_end = ds->endOfRedirectChain(); |
| 510 ds->clearRedirectChain(); | 499 ds->clearRedirectChain(); |
| 511 | 500 |
| 512 // Figure out if this location change is because of a JS-initiated client | 501 // Figure out if this location change is because of a JS-initiated client |
| 513 // redirect (e.g onload/setTimeout document.location.href=). | 502 // redirect (e.g onload/setTimeout document.location.href=). |
| 514 // TODO(timsteele): (bugs 1085325, 1046841) We don't get proper redirect | 503 // TODO(timsteele): (bugs 1085325, 1046841) We don't get proper redirect |
| 515 // performed/cancelled notifications across anchor navigations, so the | 504 // performed/cancelled notifications across anchor navigations, so the |
| 516 // other redirect-tracking code in this class (see dispatch*ClientRedirect() | 505 // other redirect-tracking code in this class (see dispatch*ClientRedirect() |
| 517 // and dispatchDidStartProvisionalLoad) is insufficient to catch and | 506 // and dispatchDidStartProvisionalLoad) is insufficient to catch and |
| 518 // properly flag these transitions. Once a proper fix for this bug is | 507 // properly flag these transitions. Once a proper fix for this bug is |
| 519 // identified and applied the following block may no longer be required. | 508 // identified and applied the following block may no longer be required. |
| 520 bool was_client_redirect = | 509 bool was_client_redirect = |
| 521 (url == expected_client_redirect_dest_ && | 510 (url == expected_client_redirect_dest_ && |
| 522 chain_end == expected_client_redirect_src_) || | 511 chain_end == expected_client_redirect_src_) || |
| 523 !webframe_->isProcessingUserGesture(); | 512 !webframe_->isProcessingUserGesture(); |
| 524 | 513 |
| 525 if (was_client_redirect) { | 514 if (was_client_redirect) { |
| 526 if (webframe_->client()) | 515 if (webframe_->client()) { |
| 527 webframe_->client()->didCompleteClientRedirect(webframe_, chain_end); | 516 webframe_->client()->didCompleteClientRedirect( |
| 517 webframe_, webkit_glue::KURLToWebURL(chain_end)); |
| 518 } |
| 528 ds->appendRedirect(chain_end); | 519 ds->appendRedirect(chain_end); |
| 529 // Make sure we clear the expected redirect since we just effectively | 520 // Make sure we clear the expected redirect since we just effectively |
| 530 // completed it. | 521 // completed it. |
| 531 expected_client_redirect_src_ = GURL(); | 522 expected_client_redirect_src_ = KURL(); |
| 532 expected_client_redirect_dest_ = GURL(); | 523 expected_client_redirect_dest_ = KURL(); |
| 533 } | 524 } |
| 534 | 525 |
| 535 // Regardless of how we got here, we are navigating to a URL so we need to | 526 // Regardless of how we got here, we are navigating to a URL so we need to |
| 536 // add it to the redirect chain. | 527 // add it to the redirect chain. |
| 537 ds->appendRedirect(url); | 528 ds->appendRedirect(url); |
| 538 } | 529 } |
| 539 | 530 |
| 540 bool is_new_navigation; | 531 bool is_new_navigation; |
| 541 webview->DidCommitLoad(&is_new_navigation); | 532 webview->DidCommitLoad(&is_new_navigation); |
| 542 if (webframe_->client()) { | 533 if (webframe_->client()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 559 } | 550 } |
| 560 | 551 |
| 561 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { | 552 void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { |
| 562 // In case a redirect occurs, we need this to be set so that the redirect | 553 // In case a redirect occurs, we need this to be set so that the redirect |
| 563 // handling code can tell where the redirect came from. Server redirects | 554 // handling code can tell where the redirect came from. Server redirects |
| 564 // will occur on the provisional load, so we need to keep track of the most | 555 // will occur on the provisional load, so we need to keep track of the most |
| 565 // recent provisional load URL. | 556 // recent provisional load URL. |
| 566 // See dispatchDidReceiveServerRedirectForProvisionalLoad. | 557 // See dispatchDidReceiveServerRedirectForProvisionalLoad. |
| 567 WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); | 558 WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); |
| 568 if (!ds) { | 559 if (!ds) { |
| 569 NOTREACHED() << "Attempting to provisional load but there isn't one"; | 560 ASSERT_NOT_REACHED(); |
| 570 return; | 561 return; |
| 571 } | 562 } |
| 572 GURL url = ds->request().url(); | 563 KURL url = webkit_glue::WebURLToKURL(ds->request().url()); |
| 573 | 564 |
| 574 // Since the provisional load just started, we should have not gotten | 565 // Since the provisional load just started, we should have not gotten |
| 575 // any redirects yet. | 566 // any redirects yet. |
| 576 DCHECK(!ds->hasRedirectChain()); | 567 ASSERT(!ds->hasRedirectChain()); |
| 577 | 568 |
| 578 // If this load is what we expected from a client redirect, treat it as a | 569 // If this load is what we expected from a client redirect, treat it as a |
| 579 // redirect from that original page. The expected redirect urls will be | 570 // redirect from that original page. The expected redirect urls will be |
| 580 // cleared by DidCancelClientRedirect. | 571 // cleared by DidCancelClientRedirect. |
| 581 bool completing_client_redirect = false; | 572 bool completing_client_redirect = false; |
| 582 if (expected_client_redirect_src_.is_valid()) { | 573 if (expected_client_redirect_src_.isValid()) { |
| 583 // expected_client_redirect_dest_ could be something like | 574 // expected_client_redirect_dest_ could be something like |
| 584 // "javascript:history.go(-1)" thus we need to exclude url starts with | 575 // "javascript:history.go(-1)" thus we need to exclude url starts with |
| 585 // "javascript:". See bug: 1080873 | 576 // "javascript:". See bug: 1080873 |
| 586 DCHECK(expected_client_redirect_dest_.SchemeIs("javascript") || | 577 ASSERT(expected_client_redirect_dest_.protocolIs("javascript") || |
| 587 expected_client_redirect_dest_ == url); | 578 expected_client_redirect_dest_ == url); |
| 588 ds->appendRedirect(expected_client_redirect_src_); | 579 ds->appendRedirect(expected_client_redirect_src_); |
| 589 completing_client_redirect = true; | 580 completing_client_redirect = true; |
| 590 } | 581 } |
| 591 ds->appendRedirect(url); | 582 ds->appendRedirect(url); |
| 592 | 583 |
| 593 if (webframe_->client()) { | 584 if (webframe_->client()) { |
| 594 // As the comment for DidCompleteClientRedirect in webview_delegate.h | 585 // As the comment for DidCompleteClientRedirect in webview_delegate.h |
| 595 // points out, whatever information its invocation contains should only | 586 // points out, whatever information its invocation contains should only |
| 596 // be considered relevant until the next provisional load has started. | 587 // be considered relevant until the next provisional load has started. |
| 597 // So we first tell the delegate that the load started, and then tell it | 588 // So we first tell the delegate that the load started, and then tell it |
| 598 // about the client redirect the load is responsible for completing. | 589 // about the client redirect the load is responsible for completing. |
| 599 webframe_->client()->didStartProvisionalLoad(webframe_); | 590 webframe_->client()->didStartProvisionalLoad(webframe_); |
| 600 if (completing_client_redirect) | 591 if (completing_client_redirect) |
| 601 webframe_->client()->didCompleteClientRedirect( | 592 webframe_->client()->didCompleteClientRedirect( |
| 602 webframe_, expected_client_redirect_src_); | 593 webframe_, webkit_glue::KURLToWebURL(expected_client_redirect_src_)); |
| 603 } | 594 } |
| 604 } | 595 } |
| 605 | 596 |
| 606 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) { | 597 void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) { |
| 607 if (webframe_->client()) { | 598 if (webframe_->client()) { |
| 608 webframe_->client()->didReceiveTitle( | 599 webframe_->client()->didReceiveTitle( |
| 609 webframe_, webkit_glue::StringToWebString(title)); | 600 webframe_, webkit_glue::StringToWebString(title)); |
| 610 } | 601 } |
| 611 } | 602 } |
| 612 | 603 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 // All resources have not necessarily finished loading. | 669 // All resources have not necessarily finished loading. |
| 679 } | 670 } |
| 680 | 671 |
| 681 Frame* WebFrameLoaderClient::dispatchCreatePage() { | 672 Frame* WebFrameLoaderClient::dispatchCreatePage() { |
| 682 struct WebCore::WindowFeatures features; | 673 struct WebCore::WindowFeatures features; |
| 683 Page* new_page = webframe_->frame()->page()->chrome()->createWindow( | 674 Page* new_page = webframe_->frame()->page()->chrome()->createWindow( |
| 684 webframe_->frame(), FrameLoadRequest(), features); | 675 webframe_->frame(), FrameLoadRequest(), features); |
| 685 | 676 |
| 686 // Make sure that we have a valid disposition. This should have been set in | 677 // Make sure that we have a valid disposition. This should have been set in |
| 687 // the preceeding call to dispatchDecidePolicyForNewWindowAction. | 678 // the preceeding call to dispatchDecidePolicyForNewWindowAction. |
| 688 DCHECK(next_navigation_policy_ != WebKit::WebNavigationPolicyIgnore); | 679 ASSERT(next_navigation_policy_ != WebKit::WebNavigationPolicyIgnore); |
| 689 WebNavigationPolicy policy = next_navigation_policy_; | 680 WebNavigationPolicy policy = next_navigation_policy_; |
| 690 next_navigation_policy_ = WebKit::WebNavigationPolicyIgnore; | 681 next_navigation_policy_ = WebKit::WebNavigationPolicyIgnore; |
| 691 | 682 |
| 692 // createWindow can return NULL (e.g., popup blocker denies the window). | 683 // createWindow can return NULL (e.g., popup blocker denies the window). |
| 693 if (!new_page) | 684 if (!new_page) |
| 694 return NULL; | 685 return NULL; |
| 695 | 686 |
| 696 WebViewImpl::FromPage(new_page)->set_initial_navigation_policy(policy); | 687 WebViewImpl::FromPage(new_page)->set_initial_navigation_policy(policy); |
| 697 return new_page->mainFrame(); | 688 return new_page->mainFrame(); |
| 698 } | 689 } |
| 699 | 690 |
| 700 void WebFrameLoaderClient::dispatchShow() { | 691 void WebFrameLoaderClient::dispatchShow() { |
| 701 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 692 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 702 WebViewDelegate* d = webview->delegate(); | 693 if (webview && webview->client()) |
| 703 if (d) | 694 webview->client()->show(webview->initial_navigation_policy()); |
| 704 d->show(webview->initial_navigation_policy()); | |
| 705 } | 695 } |
| 706 | 696 |
| 707 static bool TreatAsAttachment(const ResourceResponse& response) { | 697 static bool TreatAsAttachment(const ResourceResponse& response) { |
| 708 const String& content_disposition = | 698 const String& content_disposition = |
| 709 response.httpHeaderField("Content-Disposition"); | 699 response.httpHeaderField("Content-Disposition"); |
| 710 if (content_disposition.isEmpty()) | 700 if (content_disposition.isEmpty()) |
| 711 return false; | 701 return false; |
| 712 | 702 |
| 713 // Some broken sites just send | 703 // Some broken sites just send |
| 714 // Content-Disposition: ; filename="file" | 704 // Content-Disposition: ; filename="file" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 // The NULL check here is to fix a crash that seems strange | 792 // The NULL check here is to fix a crash that seems strange |
| 803 // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). | 793 // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). |
| 804 if (webframe_->client() && !request.url().isNull()) { | 794 if (webframe_->client() && !request.url().isNull()) { |
| 805 WebNavigationPolicy navigation_policy = | 795 WebNavigationPolicy navigation_policy = |
| 806 WebKit::WebNavigationPolicyCurrentTab; | 796 WebKit::WebNavigationPolicyCurrentTab; |
| 807 ActionSpecifiesNavigationPolicy(action, &navigation_policy); | 797 ActionSpecifiesNavigationPolicy(action, &navigation_policy); |
| 808 | 798 |
| 809 // Give the delegate a chance to change the navigation policy. | 799 // Give the delegate a chance to change the navigation policy. |
| 810 const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); | 800 const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); |
| 811 if (ds) { | 801 if (ds) { |
| 812 GURL url = ds->request().url(); | 802 KURL url = webkit_glue::WebURLToKURL(ds->request().url()); |
| 813 if (url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)) { | 803 if (url.protocolIs(webkit_glue::kBackForwardNavigationScheme)) { |
| 814 HandleBackForwardNavigation(url); | 804 HandleBackForwardNavigation(url); |
| 815 navigation_policy = WebKit::WebNavigationPolicyIgnore; | 805 navigation_policy = WebKit::WebNavigationPolicyIgnore; |
| 816 } else { | 806 } else { |
| 817 bool is_redirect = ds->hasRedirectChain(); | 807 bool is_redirect = ds->hasRedirectChain(); |
| 818 | 808 |
| 819 WebNavigationType webnav_type = | 809 WebNavigationType webnav_type = |
| 820 WebDataSourceImpl::toWebNavigationType(action.type()); | 810 WebDataSourceImpl::toWebNavigationType(action.type()); |
| 821 | 811 |
| 822 RefPtr<WebCore::Node> node; | 812 RefPtr<WebCore::Node> node; |
| 823 for (const Event* event = action.event(); event; | 813 for (const Event* event = action.event(); event; |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 // | 1135 // |
| 1146 // item_impl->SetTitle(webkit_glue::StringToStdWString(title)); | 1136 // item_impl->SetTitle(webkit_glue::StringToStdWString(title)); |
| 1147 } | 1137 } |
| 1148 | 1138 |
| 1149 String WebFrameLoaderClient::userAgent(const KURL& url) { | 1139 String WebFrameLoaderClient::userAgent(const KURL& url) { |
| 1150 return webkit_glue::StdStringToString( | 1140 return webkit_glue::StdStringToString( |
| 1151 webkit_glue::GetUserAgent(webkit_glue::KURLToGURL(url))); | 1141 webkit_glue::GetUserAgent(webkit_glue::KURLToGURL(url))); |
| 1152 } | 1142 } |
| 1153 | 1143 |
| 1154 void WebFrameLoaderClient::savePlatformDataToCachedFrame(WebCore::CachedFrame*)
{ | 1144 void WebFrameLoaderClient::savePlatformDataToCachedFrame(WebCore::CachedFrame*)
{ |
| 1155 NOTREACHED() << "Page cache should be disabled"; | 1145 // The page cache should be disabled. |
| 1146 ASSERT_NOT_REACHED(); |
| 1156 } | 1147 } |
| 1157 | 1148 |
| 1158 void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(WebCore::CachedF
rame*) { | 1149 void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(WebCore::CachedF
rame*) { |
| 1159 ASSERT_NOT_REACHED(); | 1150 ASSERT_NOT_REACHED(); |
| 1160 } | 1151 } |
| 1161 | 1152 |
| 1162 // Called when the FrameLoader goes into a state in which a new page load | 1153 // Called when the FrameLoader goes into a state in which a new page load |
| 1163 // will occur. | 1154 // will occur. |
| 1164 void WebFrameLoaderClient::transitionToCommittedForNewPage() { | 1155 void WebFrameLoaderClient::transitionToCommittedForNewPage() { |
| 1165 makeDocumentView(); | 1156 makeDocumentView(); |
| 1166 } | 1157 } |
| 1167 | 1158 |
| 1168 bool WebFrameLoaderClient::canCachePage() const { | 1159 bool WebFrameLoaderClient::canCachePage() const { |
| 1169 // Since we manage the cache, always report this page as non-cacheable to | 1160 // Since we manage the cache, always report this page as non-cacheable to |
| 1170 // FrameLoader. | 1161 // FrameLoader. |
| 1171 return false; | 1162 return false; |
| 1172 } | 1163 } |
| 1173 | 1164 |
| 1174 // Downloading is handled in the browser process, not WebKit. If we get to this | 1165 // Downloading is handled in the browser process, not WebKit. If we get to this |
| 1175 // point, our download detection code in the ResourceDispatcherHost is broken! | 1166 // point, our download detection code in the ResourceDispatcherHost is broken! |
| 1176 void WebFrameLoaderClient::download(ResourceHandle* handle, | 1167 void WebFrameLoaderClient::download(ResourceHandle* handle, |
| 1177 const ResourceRequest& request, | 1168 const ResourceRequest& request, |
| 1178 const ResourceRequest& initialRequest, | 1169 const ResourceRequest& initialRequest, |
| 1179 const ResourceResponse& response) { | 1170 const ResourceResponse& response) { |
| 1180 NOTREACHED(); | 1171 ASSERT_NOT_REACHED(); |
| 1181 } | 1172 } |
| 1182 | 1173 |
| 1183 PassRefPtr<Frame> WebFrameLoaderClient::createFrame( | 1174 PassRefPtr<Frame> WebFrameLoaderClient::createFrame( |
| 1184 const KURL& url, | 1175 const KURL& url, |
| 1185 const String& name, | 1176 const String& name, |
| 1186 HTMLFrameOwnerElement* owner_element, | 1177 HTMLFrameOwnerElement* owner_element, |
| 1187 const String& referrer, | 1178 const String& referrer, |
| 1188 bool allows_scrolling, | 1179 bool allows_scrolling, |
| 1189 int margin_width, | 1180 int margin_width, |
| 1190 int margin_height) { | 1181 int margin_height) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 if (!element->renderer()) | 1230 if (!element->renderer()) |
| 1240 return NULL; | 1231 return NULL; |
| 1241 | 1232 |
| 1242 return container; | 1233 return container; |
| 1243 } | 1234 } |
| 1244 | 1235 |
| 1245 // This method gets called when a plugin is put in place of html content | 1236 // This method gets called when a plugin is put in place of html content |
| 1246 // (e.g., acrobat reader). | 1237 // (e.g., acrobat reader). |
| 1247 void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) { | 1238 void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) { |
| 1248 plugin_widget_ = static_cast<WebPluginContainerImpl*>(pluginWidget); | 1239 plugin_widget_ = static_cast<WebPluginContainerImpl*>(pluginWidget); |
| 1249 DCHECK(plugin_widget_.get()); | 1240 ASSERT(plugin_widget_.get()); |
| 1250 } | 1241 } |
| 1251 | 1242 |
| 1252 PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget( | 1243 PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget( |
| 1253 const IntSize& size, | 1244 const IntSize& size, |
| 1254 HTMLAppletElement* element, | 1245 HTMLAppletElement* element, |
| 1255 const KURL& /* base_url */, | 1246 const KURL& /* base_url */, |
| 1256 const Vector<String>& param_names, | 1247 const Vector<String>& param_names, |
| 1257 const Vector<String>& param_values) { | 1248 const Vector<String>& param_values) { |
| 1258 return createPlugin(size, element, KURL(), param_names, param_values, | 1249 return createPlugin(size, element, KURL(), param_names, param_values, |
| 1259 "application/x-java-applet", false); | 1250 "application/x-java-applet", false); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1286 return ObjectContentNetscapePlugin; | 1277 return ObjectContentNetscapePlugin; |
| 1287 | 1278 |
| 1288 if (MIMETypeRegistry::isSupportedNonImageMIMEType(mime_type)) | 1279 if (MIMETypeRegistry::isSupportedNonImageMIMEType(mime_type)) |
| 1289 return ObjectContentFrame; | 1280 return ObjectContentFrame; |
| 1290 | 1281 |
| 1291 return ObjectContentNone; | 1282 return ObjectContentNone; |
| 1292 } | 1283 } |
| 1293 | 1284 |
| 1294 String WebFrameLoaderClient::overrideMediaType() const { | 1285 String WebFrameLoaderClient::overrideMediaType() const { |
| 1295 // FIXME | 1286 // FIXME |
| 1296 String rv; | 1287 return String(); |
| 1297 return rv; | |
| 1298 } | 1288 } |
| 1299 | 1289 |
| 1300 bool WebFrameLoaderClient::ActionSpecifiesNavigationPolicy( | 1290 bool WebFrameLoaderClient::ActionSpecifiesNavigationPolicy( |
| 1301 const WebCore::NavigationAction& action, | 1291 const WebCore::NavigationAction& action, |
| 1302 WebNavigationPolicy* policy) { | 1292 WebNavigationPolicy* policy) { |
| 1303 if ((action.type() != NavigationTypeLinkClicked) || | 1293 if ((action.type() != NavigationTypeLinkClicked) || |
| 1304 !action.event()->isMouseEvent()) | 1294 !action.event()->isMouseEvent()) |
| 1305 return false; | 1295 return false; |
| 1306 | 1296 |
| 1307 const MouseEvent* event = static_cast<const MouseEvent*>(action.event()); | 1297 const MouseEvent* event = static_cast<const MouseEvent*>(action.event()); |
| 1308 return WebViewImpl::NavigationPolicyFromMouseEvent(event->button(), | 1298 return WebViewImpl::NavigationPolicyFromMouseEvent(event->button(), |
| 1309 event->ctrlKey(), event->shiftKey(), event->altKey(), event->metaKey(), | 1299 event->ctrlKey(), event->shiftKey(), event->altKey(), event->metaKey(), |
| 1310 policy); | 1300 policy); |
| 1311 } | 1301 } |
| 1312 | 1302 |
| 1313 void WebFrameLoaderClient::HandleBackForwardNavigation(const GURL& url) { | 1303 void WebFrameLoaderClient::HandleBackForwardNavigation(const KURL& url) { |
| 1314 DCHECK(url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)); | 1304 ASSERT(url.protocolIs(webkit_glue::kBackForwardNavigationScheme)); |
| 1315 | 1305 |
| 1316 std::string offset_str = url.ExtractFileName(); | 1306 bool ok; |
| 1317 int offset; | 1307 int offset = url.lastPathComponent().toIntStrict(&ok); |
| 1318 if (!StringToInt(offset_str, &offset)) | 1308 if (!ok) |
| 1319 return; | 1309 return; |
| 1320 | 1310 |
| 1321 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 1311 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 1322 if (webview->client()) | 1312 if (webview->client()) |
| 1323 webview->client()->navigateBackForwardSoon(offset); | 1313 webview->client()->navigateBackForwardSoon(offset); |
| 1324 } | 1314 } |
| 1325 | 1315 |
| 1326 PassOwnPtr<WebPluginLoadObserver> WebFrameLoaderClient::GetPluginLoadObserver()
{ | 1316 PassOwnPtr<WebPluginLoadObserver> WebFrameLoaderClient::GetPluginLoadObserver()
{ |
| 1327 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader( | 1317 WebDataSourceImpl* ds = WebDataSourceImpl::fromDocumentLoader( |
| 1328 webframe_->frame()->loader()->activeDocumentLoader()); | 1318 webframe_->frame()->loader()->activeDocumentLoader()); |
| 1329 return ds->releasePluginLoadObserver(); | 1319 return ds->releasePluginLoadObserver(); |
| 1330 } | 1320 } |
| OLD | NEW |