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