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