| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 NavigatorDelegate* NavigatorImpl::GetDelegate() { | 112 NavigatorDelegate* NavigatorImpl::GetDelegate() { |
| 113 return delegate_; | 113 return delegate_; |
| 114 } | 114 } |
| 115 | 115 |
| 116 NavigationController* NavigatorImpl::GetController() { | 116 NavigationController* NavigatorImpl::GetController() { |
| 117 return controller_; | 117 return controller_; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void NavigatorImpl::DidStartProvisionalLoad( | 120 void NavigatorImpl::DidStartProvisionalLoad( |
| 121 RenderFrameHostImpl* render_frame_host, | 121 RenderFrameHostImpl* render_frame_host, |
| 122 const GURL& url) { | 122 const GURL& url, |
| 123 double navigation_start) { |
| 123 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame(); | 124 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame(); |
| 124 bool is_error_page = (url.spec() == kUnreachableWebDataURL); | 125 bool is_error_page = (url.spec() == kUnreachableWebDataURL); |
| 125 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); | 126 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); |
| 126 GURL validated_url(url); | 127 GURL validated_url(url); |
| 127 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); | 128 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); |
| 128 render_process_host->FilterURL(false, &validated_url); | 129 render_process_host->FilterURL(false, &validated_url); |
| 129 | 130 |
| 130 if (is_main_frame && !is_error_page) { | 131 if (is_main_frame && !is_error_page) { |
| 131 DidStartMainFrameNavigation(validated_url, | 132 DidStartMainFrameNavigation(validated_url, |
| 132 render_frame_host->GetSiteInstance()); | 133 render_frame_host->GetSiteInstance()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 153 return; | 154 return; |
| 154 } | 155 } |
| 155 | 156 |
| 156 // This ensures that notifications about the end of the previous | 157 // This ensures that notifications about the end of the previous |
| 157 // navigation are sent before notifications about the start of the | 158 // navigation are sent before notifications about the start of the |
| 158 // new navigation. | 159 // new navigation. |
| 159 render_frame_host->SetNavigationHandle(scoped_ptr<NavigationHandleImpl>()); | 160 render_frame_host->SetNavigationHandle(scoped_ptr<NavigationHandleImpl>()); |
| 160 } | 161 } |
| 161 | 162 |
| 162 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create( | 163 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create( |
| 163 validated_url, render_frame_host->frame_tree_node())); | 164 validated_url, render_frame_host->frame_tree_node(), navigation_start)); |
| 164 } | 165 } |
| 165 | 166 |
| 166 void NavigatorImpl::DidFailProvisionalLoadWithError( | 167 void NavigatorImpl::DidFailProvisionalLoadWithError( |
| 167 RenderFrameHostImpl* render_frame_host, | 168 RenderFrameHostImpl* render_frame_host, |
| 168 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { | 169 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
| 169 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() | 170 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
| 170 << ", error_code: " << params.error_code | 171 << ", error_code: " << params.error_code |
| 171 << ", error_description: " << params.error_description | 172 << ", error_description: " << params.error_description |
| 172 << ", showing_repost_interstitial: " << | 173 << ", showing_repost_interstitial: " << |
| 173 params.showing_repost_interstitial | 174 params.showing_repost_interstitial |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 } | 680 } |
| 680 | 681 |
| 681 // In all other cases the current navigation, if any, is canceled and a new | 682 // In all other cases the current navigation, if any, is canceled and a new |
| 682 // NavigationRequest is created for the node. | 683 // NavigationRequest is created for the node. |
| 683 frame_tree_node->CreatedNavigationRequest( | 684 frame_tree_node->CreatedNavigationRequest( |
| 684 NavigationRequest::CreateRendererInitiated( | 685 NavigationRequest::CreateRendererInitiated( |
| 685 frame_tree_node, common_params, begin_params, body, | 686 frame_tree_node, common_params, begin_params, body, |
| 686 controller_->GetLastCommittedEntryIndex(), | 687 controller_->GetLastCommittedEntryIndex(), |
| 687 controller_->GetEntryCount())); | 688 controller_->GetEntryCount())); |
| 688 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 689 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
| 689 navigation_request->CreateNavigationHandle(); | 690 navigation_request->CreateNavigationHandle( |
| 691 begin_params.renderer_navigation_start); |
| 690 | 692 |
| 691 if (frame_tree_node->IsMainFrame()) { | 693 if (frame_tree_node->IsMainFrame()) { |
| 692 // Renderer-initiated main-frame navigations that need to swap processes | 694 // Renderer-initiated main-frame navigations that need to swap processes |
| 693 // will go to the browser via a OpenURL call, and then be handled by the | 695 // will go to the browser via a OpenURL call, and then be handled by the |
| 694 // same code path as browser-initiated navigations. For renderer-initiated | 696 // same code path as browser-initiated navigations. For renderer-initiated |
| 695 // main frame navigation that start via a BeginNavigation IPC, the | 697 // main frame navigation that start via a BeginNavigation IPC, the |
| 696 // RenderFrameHost will not be swapped. Therefore it is safe to call | 698 // RenderFrameHost will not be swapped. Therefore it is safe to call |
| 697 // DidStartMainFrameNavigation with the SiteInstance from the current | 699 // DidStartMainFrameNavigation with the SiteInstance from the current |
| 698 // RenderFrameHost. | 700 // RenderFrameHost. |
| 699 DidStartMainFrameNavigation( | 701 DidStartMainFrameNavigation( |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 bool should_dispatch_beforeunload = | 850 bool should_dispatch_beforeunload = |
| 849 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); | 851 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); |
| 850 FrameMsg_Navigate_Type::Value navigation_type = | 852 FrameMsg_Navigate_Type::Value navigation_type = |
| 851 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 853 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
| 852 frame_tree_node->CreatedNavigationRequest( | 854 frame_tree_node->CreatedNavigationRequest( |
| 853 NavigationRequest::CreateBrowserInitiated( | 855 NavigationRequest::CreateBrowserInitiated( |
| 854 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, | 856 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, |
| 855 navigation_type, is_same_document_history_load, navigation_start, | 857 navigation_type, is_same_document_history_load, navigation_start, |
| 856 controller_)); | 858 controller_)); |
| 857 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 859 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
| 858 navigation_request->CreateNavigationHandle(); | 860 |
| 861 double navigation_start_seconds = |
| 862 (navigation_start - base::TimeTicks()).InSecondsF(); |
| 863 navigation_request->CreateNavigationHandle(navigation_start_seconds); |
| 859 | 864 |
| 860 // Have the current renderer execute its beforeunload event if needed. If it | 865 // Have the current renderer execute its beforeunload event if needed. If it |
| 861 // is not needed (when beforeunload dispatch is not needed or this navigation | 866 // is not needed (when beforeunload dispatch is not needed or this navigation |
| 862 // is synchronous and same-site) then NavigationRequest::BeginNavigation | 867 // is synchronous and same-site) then NavigationRequest::BeginNavigation |
| 863 // should be directly called instead. | 868 // should be directly called instead. |
| 864 if (should_dispatch_beforeunload && | 869 if (should_dispatch_beforeunload && |
| 865 ShouldMakeNetworkRequestForURL( | 870 ShouldMakeNetworkRequestForURL( |
| 866 navigation_request->common_params().url)) { | 871 navigation_request->common_params().url)) { |
| 867 navigation_request->SetWaitingForRendererResponse(); | 872 navigation_request->SetWaitingForRendererResponse(); |
| 868 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); | 873 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 957 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
| 953 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 958 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
| 954 } | 959 } |
| 955 controller_->SetPendingEntry(entry.Pass()); | 960 controller_->SetPendingEntry(entry.Pass()); |
| 956 if (delegate_) | 961 if (delegate_) |
| 957 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 962 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 958 } | 963 } |
| 959 } | 964 } |
| 960 | 965 |
| 961 } // namespace content | 966 } // namespace content |
| OLD | NEW |