| 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" |
| 11 #include "content/browser/frame_host/frame_tree_node.h" | 11 #include "content/browser/frame_host/frame_tree_node.h" |
| 12 #include "content/browser/frame_host/navigation_controller_impl.h" | 12 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 13 #include "content/browser/frame_host/navigation_entry_impl.h" | 13 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 14 #include "content/browser/frame_host/navigation_handle_impl.h" | 14 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 15 #include "content/browser/frame_host/navigation_request.h" | 15 #include "content/browser/frame_host/navigation_request.h" |
| 16 #include "content/browser/frame_host/navigation_request_info.h" | 16 #include "content/browser/frame_host/navigation_request_info.h" |
| 17 #include "content/browser/frame_host/navigator_delegate.h" | 17 #include "content/browser/frame_host/navigator_delegate.h" |
| 18 #include "content/browser/frame_host/render_frame_host_impl.h" | 18 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 20 #include "content/browser/site_instance_impl.h" | 20 #include "content/browser/site_instance_impl.h" |
| 21 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 21 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 22 #include "content/browser/webui/web_ui_impl.h" | 22 #include "content/browser/webui/web_ui_impl.h" |
| 23 #include "content/common/frame_messages.h" | 23 #include "content/common/frame_messages.h" |
| 24 #include "content/common/navigation_params.h" | 24 #include "content/common/navigation_params.h" |
| 25 #include "content/common/service_worker/service_worker_types.h" |
| 25 #include "content/common/site_isolation_policy.h" | 26 #include "content/common/site_isolation_policy.h" |
| 26 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
| 27 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
| 28 #include "content/public/browser/content_browser_client.h" | 29 #include "content/public/browser/content_browser_client.h" |
| 29 #include "content/public/browser/global_request_id.h" | 30 #include "content/public/browser/global_request_id.h" |
| 30 #include "content/public/browser/invalidate_type.h" | 31 #include "content/public/browser/invalidate_type.h" |
| 31 #include "content/public/browser/navigation_controller.h" | 32 #include "content/public/browser/navigation_controller.h" |
| 32 #include "content/public/browser/navigation_details.h" | 33 #include "content/public/browser/navigation_details.h" |
| 33 #include "content/public/browser/page_navigator.h" | 34 #include "content/public/browser/page_navigator.h" |
| 34 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 render_frame_host->navigation_handle()->set_is_transferring(false); | 152 render_frame_host->navigation_handle()->set_is_transferring(false); |
| 152 return; | 153 return; |
| 153 } | 154 } |
| 154 | 155 |
| 155 // This ensures that notifications about the end of the previous | 156 // This ensures that notifications about the end of the previous |
| 156 // navigation are sent before notifications about the start of the | 157 // navigation are sent before notifications about the start of the |
| 157 // new navigation. | 158 // new navigation. |
| 158 render_frame_host->SetNavigationHandle(scoped_ptr<NavigationHandleImpl>()); | 159 render_frame_host->SetNavigationHandle(scoped_ptr<NavigationHandleImpl>()); |
| 159 } | 160 } |
| 160 | 161 |
| 161 render_frame_host->SetNavigationHandle( | 162 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create( |
| 162 NavigationHandleImpl::Create(validated_url, is_main_frame, delegate_)); | 163 validated_url, is_main_frame, render_frame_host->frame_tree_node())); |
| 163 } | 164 } |
| 164 | 165 |
| 165 void NavigatorImpl::DidFailProvisionalLoadWithError( | 166 void NavigatorImpl::DidFailProvisionalLoadWithError( |
| 166 RenderFrameHostImpl* render_frame_host, | 167 RenderFrameHostImpl* render_frame_host, |
| 167 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { | 168 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
| 168 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() | 169 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
| 169 << ", error_code: " << params.error_code | 170 << ", error_code: " << params.error_code |
| 170 << ", error_description: " << params.error_description | 171 << ", error_description: " << params.error_description |
| 171 << ", showing_repost_interstitial: " << | 172 << ", showing_repost_interstitial: " << |
| 172 params.showing_repost_interstitial | 173 params.showing_repost_interstitial |
| (...skipping 506 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(delegate_); | 690 navigation_request->CreateNavigationHandle(); |
| 690 | 691 |
| 691 if (frame_tree_node->IsMainFrame()) { | 692 if (frame_tree_node->IsMainFrame()) { |
| 692 // Renderer-initiated main-frame navigations that need to swap processes | 693 // 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 | 694 // 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 | 695 // same code path as browser-initiated navigations. For renderer-initiated |
| 695 // main frame navigation that start via a BeginNavigation IPC, the | 696 // main frame navigation that start via a BeginNavigation IPC, the |
| 696 // RenderFrameHost will not be swapped. Therefore it is safe to call | 697 // RenderFrameHost will not be swapped. Therefore it is safe to call |
| 697 // DidStartMainFrameNavigation with the SiteInstance from the current | 698 // DidStartMainFrameNavigation with the SiteInstance from the current |
| 698 // RenderFrameHost. | 699 // RenderFrameHost. |
| 699 DidStartMainFrameNavigation( | 700 DidStartMainFrameNavigation( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 render_frame_host->render_view_host()->GetRoutingID())); | 744 render_frame_host->render_view_host()->GetRoutingID())); |
| 744 } | 745 } |
| 745 | 746 |
| 746 CheckWebUIRendererDoesNotDisplayNormalURL( | 747 CheckWebUIRendererDoesNotDisplayNormalURL( |
| 747 render_frame_host, navigation_request->common_params().url); | 748 render_frame_host, navigation_request->common_params().url); |
| 748 | 749 |
| 749 navigation_request->TransferNavigationHandleOwnership(render_frame_host); | 750 navigation_request->TransferNavigationHandleOwnership(render_frame_host); |
| 750 render_frame_host->CommitNavigation(response, body.Pass(), | 751 render_frame_host->CommitNavigation(response, body.Pass(), |
| 751 navigation_request->common_params(), | 752 navigation_request->common_params(), |
| 752 navigation_request->request_params()); | 753 navigation_request->request_params()); |
| 753 | |
| 754 } | 754 } |
| 755 | 755 |
| 756 // PlzNavigate | 756 // PlzNavigate |
| 757 void NavigatorImpl::FailedNavigation(FrameTreeNode* frame_tree_node, | 757 void NavigatorImpl::FailedNavigation(FrameTreeNode* frame_tree_node, |
| 758 bool has_stale_copy_in_cache, | 758 bool has_stale_copy_in_cache, |
| 759 int error_code) { | 759 int error_code) { |
| 760 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 760 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 761 switches::kEnableBrowserSideNavigation)); | 761 switches::kEnableBrowserSideNavigation)); |
| 762 | 762 |
| 763 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 763 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 bool should_dispatch_beforeunload = | 848 bool should_dispatch_beforeunload = |
| 849 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); | 849 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); |
| 850 FrameMsg_Navigate_Type::Value navigation_type = | 850 FrameMsg_Navigate_Type::Value navigation_type = |
| 851 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 851 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
| 852 frame_tree_node->CreatedNavigationRequest( | 852 frame_tree_node->CreatedNavigationRequest( |
| 853 NavigationRequest::CreateBrowserInitiated( | 853 NavigationRequest::CreateBrowserInitiated( |
| 854 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, | 854 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, |
| 855 navigation_type, is_same_document_history_load, navigation_start, | 855 navigation_type, is_same_document_history_load, navigation_start, |
| 856 controller_)); | 856 controller_)); |
| 857 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 857 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
| 858 navigation_request->CreateNavigationHandle(delegate_); | 858 navigation_request->CreateNavigationHandle(); |
| 859 | 859 |
| 860 // Have the current renderer execute its beforeunload event if needed. If it | 860 // 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 | 861 // is not needed (when beforeunload dispatch is not needed or this navigation |
| 862 // is synchronous and same-site) then NavigationRequest::BeginNavigation | 862 // is synchronous and same-site) then NavigationRequest::BeginNavigation |
| 863 // should be directly called instead. | 863 // should be directly called instead. |
| 864 if (should_dispatch_beforeunload && | 864 if (should_dispatch_beforeunload && |
| 865 ShouldMakeNetworkRequestForURL( | 865 ShouldMakeNetworkRequestForURL( |
| 866 navigation_request->common_params().url)) { | 866 navigation_request->common_params().url)) { |
| 867 navigation_request->SetWaitingForRendererResponse(); | 867 navigation_request->SetWaitingForRendererResponse(); |
| 868 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); | 868 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()); | 952 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
| 953 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 953 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
| 954 } | 954 } |
| 955 controller_->SetPendingEntry(entry.Pass()); | 955 controller_->SetPendingEntry(entry.Pass()); |
| 956 if (delegate_) | 956 if (delegate_) |
| 957 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 957 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 958 } | 958 } |
| 959 } | 959 } |
| 960 | 960 |
| 961 } // namespace content | 961 } // namespace content |
| OLD | NEW |