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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 else | 696 else |
697 CancelNavigation(frame_tree_node); | 697 CancelNavigation(frame_tree_node); |
698 } | 698 } |
699 | 699 |
700 // PlzNavigate | 700 // PlzNavigate |
701 void NavigatorImpl::OnBeginNavigation( | 701 void NavigatorImpl::OnBeginNavigation( |
702 FrameTreeNode* frame_tree_node, | 702 FrameTreeNode* frame_tree_node, |
703 const CommonNavigationParams& common_params, | 703 const CommonNavigationParams& common_params, |
704 const BeginNavigationParams& begin_params, | 704 const BeginNavigationParams& begin_params, |
705 scoped_refptr<ResourceRequestBody> body) { | 705 scoped_refptr<ResourceRequestBody> body) { |
| 706 // This is a renderer-initiated navigation. |
706 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 707 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
707 switches::kEnableBrowserSideNavigation)); | 708 switches::kEnableBrowserSideNavigation)); |
708 DCHECK(frame_tree_node); | 709 DCHECK(frame_tree_node); |
709 | 710 |
710 // This is a renderer-initiated navigation, so generate a new | 711 NavigationRequest* ongoing_navigation_request = |
711 // NavigationRequest and store it in the map. | 712 navigation_request_map_.get(frame_tree_node->frame_tree_node_id()); |
712 // TODO(clamy): Renderer-initiated navigations should not always cancel the | 713 |
713 // current one. | 714 // The renderer-initiated navigation request is ignored iff a) there is an |
| 715 // ongoing request b) which is browser or user-initiated and c) the renderer |
| 716 // request is not user-initiated. |
| 717 if (ongoing_navigation_request && |
| 718 (ongoing_navigation_request->browser_initiated() || |
| 719 ongoing_navigation_request->begin_params().has_user_gesture) && |
| 720 !begin_params.has_user_gesture) { |
| 721 return; |
| 722 } |
| 723 |
| 724 // In all other cases the current navigation, if any, is canceled and a new |
| 725 // NavigationRequest is created and stored in the map. Actual cancellation |
| 726 // happens when the existing request map entry is replaced and destroyed. |
714 scoped_ptr<NavigationRequest> navigation_request = | 727 scoped_ptr<NavigationRequest> navigation_request = |
715 NavigationRequest::CreateRendererInitiated( | 728 NavigationRequest::CreateRendererInitiated( |
716 frame_tree_node, common_params, begin_params, body); | 729 frame_tree_node, common_params, begin_params, body); |
717 navigation_request_map_.set( | 730 navigation_request_map_.set( |
718 frame_tree_node->frame_tree_node_id(), navigation_request.Pass()); | 731 frame_tree_node->frame_tree_node_id(), navigation_request.Pass()); |
719 | 732 |
720 if (frame_tree_node->IsMainFrame()) | 733 if (frame_tree_node->IsMainFrame()) |
721 navigation_data_.reset(); | 734 navigation_data_.reset(); |
722 | 735 |
723 BeginNavigation(frame_tree_node); | 736 BeginNavigation(frame_tree_node); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 930 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
918 time_to_commit); | 931 time_to_commit); |
919 UMA_HISTOGRAM_TIMES( | 932 UMA_HISTOGRAM_TIMES( |
920 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 933 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
921 time_to_network); | 934 time_to_network); |
922 } | 935 } |
923 navigation_data_.reset(); | 936 navigation_data_.reset(); |
924 } | 937 } |
925 | 938 |
926 } // namespace content | 939 } // namespace content |
OLD | NEW |