| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "FormState.h" | 22 #include "FormState.h" |
| 23 #include "FrameLoader.h" | 23 #include "FrameLoader.h" |
| 24 #include "FrameLoadRequest.h" | 24 #include "FrameLoadRequest.h" |
| 25 #include "FrameView.h" | 25 #include "FrameView.h" |
| 26 #include "MIMETypeRegistry.h" | 26 #include "MIMETypeRegistry.h" |
| 27 #include "MouseEvent.h" | 27 #include "MouseEvent.h" |
| 28 #include "Page.h" | 28 #include "Page.h" |
| 29 #include "PlatformString.h" | 29 #include "PlatformString.h" |
| 30 #include "PluginData.h" | 30 #include "PluginData.h" |
| 31 #include "RefPtr.h" | 31 #include "RefPtr.h" |
| 32 #include "StringExtras.h" |
| 32 #include "WindowFeatures.h" | 33 #include "WindowFeatures.h" |
| 33 MSVC_POP_WARNING(); | 34 MSVC_POP_WARNING(); |
| 34 | 35 |
| 35 #undef LOG | 36 #undef LOG |
| 36 #include "base/basictypes.h" | 37 #include "base/basictypes.h" |
| 37 #include "base/command_line.h" | 38 #include "base/command_line.h" |
| 38 #include "base/logging.h" | 39 #include "base/logging.h" |
| 39 #include "base/string_util.h" | 40 #include "base/string_util.h" |
| 40 #include "net/base/mime_util.h" | 41 #include "net/base/mime_util.h" |
| 41 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 #include "webkit/glue/webdevtoolsagent_impl.h" | 54 #include "webkit/glue/webdevtoolsagent_impl.h" |
| 54 #include "webkit/glue/weberror_impl.h" | 55 #include "webkit/glue/weberror_impl.h" |
| 55 #include "webkit/glue/webframeloaderclient_impl.h" | 56 #include "webkit/glue/webframeloaderclient_impl.h" |
| 56 #include "webkit/glue/webhistoryitem_impl.h" | 57 #include "webkit/glue/webhistoryitem_impl.h" |
| 57 #include "webkit/glue/webkit_glue.h" | 58 #include "webkit/glue/webkit_glue.h" |
| 58 #include "webkit/glue/webplugin_impl.h" | 59 #include "webkit/glue/webplugin_impl.h" |
| 59 #include "webkit/glue/webresponse_impl.h" | 60 #include "webkit/glue/webresponse_impl.h" |
| 60 #include "webkit/glue/webview_delegate.h" | 61 #include "webkit/glue/webview_delegate.h" |
| 61 #include "webkit/glue/webview_impl.h" | 62 #include "webkit/glue/webview_impl.h" |
| 62 #include "webkit/glue/weburlrequest.h" | 63 #include "webkit/glue/weburlrequest.h" |
| 64 #include "webkit/glue/weburlrequest_impl.h" |
| 63 | 65 |
| 64 using namespace WebCore; | 66 using namespace WebCore; |
| 67 using base::Time; |
| 68 using base::TimeDelta; |
| 65 | 69 |
| 66 // Domain for internal error codes. | 70 // Domain for internal error codes. |
| 67 static const char kInternalErrorDomain[] = "webkit_glue"; | 71 static const char kInternalErrorDomain[] = "webkit_glue"; |
| 68 | 72 |
| 69 // An internal error code. Used to note a policy change error resulting from | 73 // An internal error code. Used to note a policy change error resulting from |
| 70 // dispatchDecidePolicyForMIMEType not passing the PolicyUse option. | 74 // dispatchDecidePolicyForMIMEType not passing the PolicyUse option. |
| 71 enum { | 75 enum { |
| 72 ERR_POLICY_CHANGE = -10000, | 76 ERR_POLICY_CHANGE = -10000, |
| 73 }; | 77 }; |
| 74 | 78 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 380 } |
| 377 NetAgentImpl* net_agent = GetNetAgentImpl(); | 381 NetAgentImpl* net_agent = GetNetAgentImpl(); |
| 378 if (net_agent) { | 382 if (net_agent) { |
| 379 net_agent->DidFailLoading(loader, identifier, error); | 383 net_agent->DidFailLoading(loader, identifier, error); |
| 380 } | 384 } |
| 381 } | 385 } |
| 382 | 386 |
| 383 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { | 387 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { |
| 384 WebViewImpl* webview = webframe_->webview_impl(); | 388 WebViewImpl* webview = webframe_->webview_impl(); |
| 385 WebViewDelegate* d = webview->delegate(); | 389 WebViewDelegate* d = webview->delegate(); |
| 390 DocumentLoader* documentLoader = |
| 391 webframe_->frame()->loader()->activeDocumentLoader(); |
| 392 WebDataSourceImpl* data_source = |
| 393 WebDataSourceImpl::FromLoader(documentLoader); |
| 386 | 394 |
| 387 // A frame may be reused. This call ensures we don't hold on to our password | 395 // A frame may be reused. This call ensures we don't hold on to our password |
| 388 // listeners and their associated HTMLInputElements. | 396 // listeners and their associated HTMLInputElements. |
| 389 webframe_->ClearPasswordListeners(); | 397 webframe_->ClearPasswordListeners(); |
| 390 | 398 |
| 391 // The document has now been fully loaded. | 399 // The document has now been fully loaded. |
| 392 // Scan for password forms to be sent to the browser | 400 // Scan for password forms to be sent to the browser |
| 393 PassRefPtr<WebCore::HTMLCollection> forms = | 401 PassRefPtr<WebCore::HTMLCollection> forms = |
| 394 webframe_->frame()->document()->forms(); | 402 webframe_->frame()->document()->forms(); |
| 395 | 403 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 412 | 420 |
| 413 if (passwordFormPtr.get()) | 421 if (passwordFormPtr.get()) |
| 414 passwordForms.push_back(*passwordFormPtr); | 422 passwordForms.push_back(*passwordFormPtr); |
| 415 } | 423 } |
| 416 } | 424 } |
| 417 | 425 |
| 418 if (d && (passwordForms.size() > 0)) | 426 if (d && (passwordForms.size() > 0)) |
| 419 d->OnPasswordFormsSeen(webview, passwordForms); | 427 d->OnPasswordFormsSeen(webview, passwordForms); |
| 420 if (d) | 428 if (d) |
| 421 d->DidFinishDocumentLoadForFrame(webview, webframe_); | 429 d->DidFinishDocumentLoadForFrame(webview, webframe_); |
| 430 data_source->set_finish_document_load_time(base::Time::Now()); |
| 422 } | 431 } |
| 423 | 432 |
| 424 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( | 433 bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( |
| 425 DocumentLoader* loader, | 434 DocumentLoader* loader, |
| 426 const ResourceRequest& request, | 435 const ResourceRequest& request, |
| 427 const ResourceResponse& response, | 436 const ResourceResponse& response, |
| 428 int length) { | 437 int length) { |
| 429 WebViewImpl* webview = webframe_->webview_impl(); | 438 WebViewImpl* webview = webframe_->webview_impl(); |
| 430 WebViewDelegate* d = webview->delegate(); | 439 WebViewDelegate* d = webview->delegate(); |
| 431 | 440 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 ds->AppendRedirect(url); | 733 ds->AppendRedirect(url); |
| 725 | 734 |
| 726 if (d) { | 735 if (d) { |
| 727 // As the comment for DidCompleteClientRedirect in webview_delegate.h | 736 // As the comment for DidCompleteClientRedirect in webview_delegate.h |
| 728 // points out, whatever information its invocation contains should only | 737 // points out, whatever information its invocation contains should only |
| 729 // be considered relevant until the next provisional load has started. | 738 // be considered relevant until the next provisional load has started. |
| 730 // So we first tell the delegate that the load started, and then tell it | 739 // So we first tell the delegate that the load started, and then tell it |
| 731 // about the client redirect the load is responsible for completing. | 740 // about the client redirect the load is responsible for completing. |
| 732 d->DidStartProvisionalLoadForFrame(webview, webframe_, | 741 d->DidStartProvisionalLoadForFrame(webview, webframe_, |
| 733 NavigationGestureForLastLoad()); | 742 NavigationGestureForLastLoad()); |
| 743 DocumentLoader* documentLoader = |
| 744 webframe_->frame()->loader()->activeDocumentLoader(); |
| 745 WebDataSourceImpl* dataSource = |
| 746 WebDataSourceImpl::FromLoader(documentLoader); |
| 747 if (dataSource->GetRequestTime().ToInternalValue() == 0) { |
| 748 const Event *event = documentLoader->triggeringAction().event(); |
| 749 if (event) { |
| 750 // If the request was generated by a click, we have to use the time |
| 751 // from the event. Unfortunately this isn't tracked all the way from |
| 752 // the platform event, but it will have to do |
| 753 double eventTime = event->timeStamp() / 1000.0; |
| 754 dataSource->set_request_time(Time::FromDoubleT(eventTime)); |
| 755 } |
| 756 } |
| 757 dataSource->set_start_load_time(base::Time::Now()); |
| 734 if (completing_client_redirect) | 758 if (completing_client_redirect) |
| 735 d->DidCompleteClientRedirect(webview, webframe_, | 759 d->DidCompleteClientRedirect(webview, webframe_, |
| 736 expected_client_redirect_src_); | 760 expected_client_redirect_src_); |
| 737 } | 761 } |
| 738 | 762 |
| 739 // Cancel any pending loads. | 763 // Cancel any pending loads. |
| 740 if (alt_404_page_fetcher_.get()) | 764 if (alt_404_page_fetcher_.get()) |
| 741 alt_404_page_fetcher_->Cancel(); | 765 alt_404_page_fetcher_->Cancel(); |
| 742 } | 766 } |
| 743 | 767 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 WebPluginDelegate* plg_delegate = webframe_->plugin_delegate(); | 820 WebPluginDelegate* plg_delegate = webframe_->plugin_delegate(); |
| 797 if (plg_delegate) | 821 if (plg_delegate) |
| 798 plg_delegate->DidFinishLoadWithReason(NPRES_NETWORK_ERR); | 822 plg_delegate->DidFinishLoadWithReason(NPRES_NETWORK_ERR); |
| 799 | 823 |
| 800 // Don't clear the redirect chain, this will happen in the middle of client | 824 // Don't clear the redirect chain, this will happen in the middle of client |
| 801 // redirects, and we need the context. The chain will be cleared when the | 825 // redirects, and we need the context. The chain will be cleared when the |
| 802 // provisional load succeeds or fails, not the "real" one. | 826 // provisional load succeeds or fails, not the "real" one. |
| 803 } | 827 } |
| 804 | 828 |
| 805 void WebFrameLoaderClient::dispatchDidFinishLoad() { | 829 void WebFrameLoaderClient::dispatchDidFinishLoad() { |
| 830 DocumentLoader* documentLoader = |
| 831 webframe_->frame()->loader()->activeDocumentLoader(); |
| 832 WebDataSourceImpl* dataSource = |
| 833 WebDataSourceImpl::FromLoader(documentLoader); |
| 806 WebViewImpl* webview = webframe_->webview_impl(); | 834 WebViewImpl* webview = webframe_->webview_impl(); |
| 807 WebViewDelegate* d = webview->delegate(); | 835 WebViewDelegate* d = webview->delegate(); |
| 836 dataSource->set_finish_load_time(base::Time::Now()); |
| 808 if (d) | 837 if (d) |
| 809 d->DidFinishLoadForFrame(webview, webframe_); | 838 d->DidFinishLoadForFrame(webview, webframe_); |
| 810 WebPluginDelegate* plg_delegate = webframe_->plugin_delegate(); | 839 WebPluginDelegate* plg_delegate = webframe_->plugin_delegate(); |
| 811 if (plg_delegate) | 840 if (plg_delegate) |
| 812 plg_delegate->DidFinishLoadWithReason(NPRES_DONE); | 841 plg_delegate->DidFinishLoadWithReason(NPRES_DONE); |
| 813 | 842 |
| 814 // Don't clear the redirect chain, this will happen in the middle of client | 843 // Don't clear the redirect chain, this will happen in the middle of client |
| 815 // redirects, and we need the context. The chain will be cleared when the | 844 // redirects, and we need the context. The chain will be cleared when the |
| 816 // provisional load succeeds or fails, not the "real" one. | 845 // provisional load succeeds or fails, not the "real" one. |
| 817 } | 846 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 | 961 |
| 933 // Remember the disposition for when dispatchCreatePage is called. It is | 962 // Remember the disposition for when dispatchCreatePage is called. It is |
| 934 // unfortunate that WebCore does not provide us with any context when | 963 // unfortunate that WebCore does not provide us with any context when |
| 935 // creating or showing the new window that would allow us to avoid having | 964 // creating or showing the new window that would allow us to avoid having |
| 936 // to keep this state. | 965 // to keep this state. |
| 937 next_window_open_disposition_ = disposition; | 966 next_window_open_disposition_ = disposition; |
| 938 } | 967 } |
| 939 (webframe_->frame()->loader()->*function)(policy_action); | 968 (webframe_->frame()->loader()->*function)(policy_action); |
| 940 } | 969 } |
| 941 | 970 |
| 942 // Conversion. | |
| 943 static WebNavigationType NavigationTypeToWebNavigationType( | |
| 944 WebCore::NavigationType t) { | |
| 945 switch (t) { | |
| 946 case WebCore::NavigationTypeLinkClicked: | |
| 947 return WebNavigationTypeLinkClicked; | |
| 948 case WebCore::NavigationTypeFormSubmitted: | |
| 949 return WebNavigationTypeFormSubmitted; | |
| 950 case WebCore::NavigationTypeBackForward: | |
| 951 return WebNavigationTypeBackForward; | |
| 952 case WebCore::NavigationTypeReload: | |
| 953 return WebNavigationTypeReload; | |
| 954 case WebCore::NavigationTypeFormResubmitted: | |
| 955 return WebNavigationTypeFormResubmitted; | |
| 956 default: | |
| 957 case WebCore::NavigationTypeOther: | |
| 958 return WebNavigationTypeOther; | |
| 959 } | |
| 960 } | |
| 961 | |
| 962 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( | 971 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( |
| 963 WebCore::FramePolicyFunction function, | 972 WebCore::FramePolicyFunction function, |
| 964 const WebCore::NavigationAction& action, | 973 const WebCore::NavigationAction& action, |
| 965 const WebCore::ResourceRequest& request, | 974 const WebCore::ResourceRequest& request, |
| 966 PassRefPtr<WebCore::FormState> form_state) { | 975 PassRefPtr<WebCore::FormState> form_state) { |
| 967 PolicyAction policy_action = PolicyUse; | 976 PolicyAction policy_action = PolicyUse; |
| 968 | 977 |
| 969 WebViewImpl* wv = webframe_->webview_impl(); | 978 WebViewImpl* wv = webframe_->webview_impl(); |
| 970 WebViewDelegate* d = wv->delegate(); | 979 WebViewDelegate* d = wv->delegate(); |
| 971 // It is valid for this function to be invoked in code paths where the | 980 // It is valid for this function to be invoked in code paths where the |
| 972 // the webview is closed. | 981 // the webview is closed. |
| 973 // The NULL check here is to fix a crash that seems strange | 982 // The NULL check here is to fix a crash that seems strange |
| 974 // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). | 983 // (see - https://bugs.webkit.org/show_bug.cgi?id=23554). |
| 975 if (d && !request.url().isNull()) { | 984 if (d && !request.url().isNull()) { |
| 976 WindowOpenDisposition disposition = CURRENT_TAB; | 985 WindowOpenDisposition disposition = CURRENT_TAB; |
| 977 ActionSpecifiesDisposition(action, &disposition); | 986 ActionSpecifiesDisposition(action, &disposition); |
| 978 | 987 |
| 979 // Give the delegate a chance to change the disposition. When we do not | 988 // Give the delegate a chance to change the disposition. When we do not |
| 980 // have a provisional data source here, it means that we are scrolling to | 989 // have a provisional data source here, it means that we are scrolling to |
| 981 // an anchor in the page. We don't need to ask the WebViewDelegate about | 990 // an anchor in the page. We don't need to ask the WebViewDelegate about |
| 982 // such navigations. | 991 // such navigations. |
| 983 const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); | 992 const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); |
| 984 if (ds) { | 993 if (ds) { |
| 985 bool is_redirect = !ds->GetRedirectChain().empty(); | 994 bool is_redirect = !ds->GetRedirectChain().empty(); |
| 986 | 995 |
| 987 WebNavigationType webnav_type = | 996 WebNavigationType webnav_type = |
| 988 NavigationTypeToWebNavigationType(action.type()); | 997 WebDataSourceImpl::NavigationTypeToWebNavigationType(action.type()); |
| 989 | 998 |
| 990 disposition = d->DispositionForNavigationAction( | 999 disposition = d->DispositionForNavigationAction( |
| 991 wv, webframe_, &ds->GetRequest(), webnav_type, disposition, is_redirec
t); | 1000 wv, webframe_, &ds->GetRequest(), webnav_type, disposition, is_redirec
t); |
| 992 | 1001 |
| 993 if (disposition != IGNORE_ACTION) { | 1002 if (disposition != IGNORE_ACTION) { |
| 994 if (disposition == CURRENT_TAB) { | 1003 if (disposition == CURRENT_TAB) { |
| 995 policy_action = PolicyUse; | 1004 policy_action = PolicyUse; |
| 996 } else if (disposition == SAVE_TO_DISK) { | 1005 } else if (disposition == SAVE_TO_DISK) { |
| 997 policy_action = PolicyDownload; | 1006 policy_action = PolicyDownload; |
| 998 } else { | 1007 } else { |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 if (!web_view) { | 1595 if (!web_view) { |
| 1587 return NULL; | 1596 return NULL; |
| 1588 } | 1597 } |
| 1589 WebDevToolsAgentImpl* tools_agent = web_view->GetWebDevToolsAgentImpl(); | 1598 WebDevToolsAgentImpl* tools_agent = web_view->GetWebDevToolsAgentImpl(); |
| 1590 if (tools_agent) { | 1599 if (tools_agent) { |
| 1591 return tools_agent->net_agent_impl(); | 1600 return tools_agent->net_agent_impl(); |
| 1592 } else { | 1601 } else { |
| 1593 return NULL; | 1602 return NULL; |
| 1594 } | 1603 } |
| 1595 } | 1604 } |
| OLD | NEW |