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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 is_transfer && | 380 is_transfer && |
381 entry.transferred_global_request_id().child_id == | 381 entry.transferred_global_request_id().child_id == |
382 dest_render_frame_host->GetProcess()->GetID(); | 382 dest_render_frame_host->GetProcess()->GetID(); |
383 if (!is_transfer_to_same) { | 383 if (!is_transfer_to_same) { |
384 navigation_data_.reset(new NavigationMetricsData( | 384 navigation_data_.reset(new NavigationMetricsData( |
385 navigation_start, dest_url, entry.restore_type())); | 385 navigation_start, dest_url, entry.restore_type())); |
386 // Create the navigation parameters. | 386 // Create the navigation parameters. |
387 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( | 387 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( |
388 controller_->GetBrowserContext(), entry, reload_type); | 388 controller_->GetBrowserContext(), entry, reload_type); |
389 dest_render_frame_host->Navigate( | 389 dest_render_frame_host->Navigate( |
390 entry.ConstructCommonNavigationParams(frame_entry, dest_url, | 390 entry.ConstructCommonNavigationParams(frame_entry, nullptr, dest_url, |
391 dest_referrer, navigation_type, | 391 dest_referrer, navigation_type, |
392 lofi_state, navigation_start), | 392 lofi_state, navigation_start), |
393 entry.ConstructStartNavigationParams(), | 393 entry.ConstructStartNavigationParams(), |
394 entry.ConstructRequestNavigationParams( | 394 entry.ConstructRequestNavigationParams( |
395 frame_entry, is_same_document_history_load, | 395 frame_entry, is_same_document_history_load, |
396 frame_tree_node->has_committed_real_load(), | 396 frame_tree_node->has_committed_real_load(), |
397 controller_->GetPendingEntryIndex() == -1, | 397 controller_->GetPendingEntryIndex() == -1, |
398 controller_->GetIndexOfEntry(&entry), | 398 controller_->GetIndexOfEntry(&entry), |
399 controller_->GetLastCommittedEntryIndex(), | 399 controller_->GetLastCommittedEntryIndex(), |
400 controller_->GetEntryCount())); | 400 controller_->GetEntryCount())); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 if (proceed) | 853 if (proceed) |
854 navigation_request->BeginNavigation(); | 854 navigation_request->BeginNavigation(); |
855 else | 855 else |
856 CancelNavigation(frame_tree_node); | 856 CancelNavigation(frame_tree_node); |
857 } | 857 } |
858 | 858 |
859 // PlzNavigate | 859 // PlzNavigate |
860 void NavigatorImpl::OnBeginNavigation( | 860 void NavigatorImpl::OnBeginNavigation( |
861 FrameTreeNode* frame_tree_node, | 861 FrameTreeNode* frame_tree_node, |
862 const CommonNavigationParams& common_params, | 862 const CommonNavigationParams& common_params, |
863 const BeginNavigationParams& begin_params, | 863 const BeginNavigationParams& begin_params) { |
864 scoped_refptr<ResourceRequestBody> body) { | |
865 // TODO(clamy): the url sent by the renderer should be validated with | 864 // TODO(clamy): the url sent by the renderer should be validated with |
866 // FilterURL. | 865 // FilterURL. |
867 // This is a renderer-initiated navigation. | 866 // This is a renderer-initiated navigation. |
868 CHECK(IsBrowserSideNavigationEnabled()); | 867 CHECK(IsBrowserSideNavigationEnabled()); |
869 DCHECK(frame_tree_node); | 868 DCHECK(frame_tree_node); |
870 | 869 |
871 NavigationRequest* ongoing_navigation_request = | 870 NavigationRequest* ongoing_navigation_request = |
872 frame_tree_node->navigation_request(); | 871 frame_tree_node->navigation_request(); |
873 | 872 |
874 // The renderer-initiated navigation request is ignored iff a) there is an | 873 // The renderer-initiated navigation request is ignored iff a) there is an |
875 // ongoing request b) which is browser or user-initiated and c) the renderer | 874 // ongoing request b) which is browser or user-initiated and c) the renderer |
876 // request is not user-initiated. | 875 // request is not user-initiated. |
877 if (ongoing_navigation_request && | 876 if (ongoing_navigation_request && |
878 (ongoing_navigation_request->browser_initiated() || | 877 (ongoing_navigation_request->browser_initiated() || |
879 ongoing_navigation_request->begin_params().has_user_gesture) && | 878 ongoing_navigation_request->begin_params().has_user_gesture) && |
880 !begin_params.has_user_gesture) { | 879 !begin_params.has_user_gesture) { |
881 RenderFrameHost* current_frame_host = | 880 RenderFrameHost* current_frame_host = |
882 frame_tree_node->render_manager()->current_frame_host(); | 881 frame_tree_node->render_manager()->current_frame_host(); |
883 current_frame_host->Send( | 882 current_frame_host->Send( |
884 new FrameMsg_Stop(current_frame_host->GetRoutingID())); | 883 new FrameMsg_Stop(current_frame_host->GetRoutingID())); |
885 return; | 884 return; |
886 } | 885 } |
887 | 886 |
888 // In all other cases the current navigation, if any, is canceled and a new | 887 // In all other cases the current navigation, if any, is canceled and a new |
889 // NavigationRequest is created for the node. | 888 // NavigationRequest is created for the node. |
890 frame_tree_node->CreatedNavigationRequest( | 889 frame_tree_node->CreatedNavigationRequest( |
891 NavigationRequest::CreateRendererInitiated( | 890 NavigationRequest::CreateRendererInitiated( |
892 frame_tree_node, common_params, begin_params, body, | 891 frame_tree_node, common_params, begin_params, |
893 controller_->GetLastCommittedEntryIndex(), | 892 controller_->GetLastCommittedEntryIndex(), |
894 controller_->GetEntryCount())); | 893 controller_->GetEntryCount())); |
895 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 894 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
896 if (frame_tree_node->IsMainFrame()) { | 895 if (frame_tree_node->IsMainFrame()) { |
897 // Renderer-initiated main-frame navigations that need to swap processes | 896 // Renderer-initiated main-frame navigations that need to swap processes |
898 // will go to the browser via a OpenURL call, and then be handled by the | 897 // will go to the browser via a OpenURL call, and then be handled by the |
899 // same code path as browser-initiated navigations. For renderer-initiated | 898 // same code path as browser-initiated navigations. For renderer-initiated |
900 // main frame navigation that start via a BeginNavigation IPC, the | 899 // main frame navigation that start via a BeginNavigation IPC, the |
901 // RenderFrameHost will not be swapped. Therefore it is safe to call | 900 // RenderFrameHost will not be swapped. Therefore it is safe to call |
902 // DidStartMainFrameNavigation with the SiteInstance from the current | 901 // DidStartMainFrameNavigation with the SiteInstance from the current |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 if (pending_entry != controller_->GetVisibleEntry() || | 1163 if (pending_entry != controller_->GetVisibleEntry() || |
1165 !should_preserve_entry) { | 1164 !should_preserve_entry) { |
1166 controller_->DiscardPendingEntry(true); | 1165 controller_->DiscardPendingEntry(true); |
1167 | 1166 |
1168 // Also force the UI to refresh. | 1167 // Also force the UI to refresh. |
1169 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1168 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
1170 } | 1169 } |
1171 } | 1170 } |
1172 | 1171 |
1173 } // namespace content | 1172 } // namespace content |
OLD | NEW |