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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 return; | 168 return; |
169 } | 169 } |
170 | 170 |
171 // This ensures that notifications about the end of the previous | 171 // This ensures that notifications about the end of the previous |
172 // navigation are sent before notifications about the start of the | 172 // navigation are sent before notifications about the start of the |
173 // new navigation. | 173 // new navigation. |
174 render_frame_host->SetNavigationHandle( | 174 render_frame_host->SetNavigationHandle( |
175 std::unique_ptr<NavigationHandleImpl>()); | 175 std::unique_ptr<NavigationHandleImpl>()); |
176 } | 176 } |
177 | 177 |
178 NavigationEntry* pending_entry = controller_->GetPendingEntry(); | 178 bool is_renderer_initiated = false; |
Charlie Reis
2016/05/11 21:50:03
Seems like we should default to true, with a comme
dominickn
2016/05/12 04:22:58
Makes sense, done. The test I added with subframe
| |
179 int pending_nav_entry_id = 0; | |
180 NavigationEntryImpl* pending_entry = controller_->GetPendingEntry(); | |
181 if (pending_entry) { | |
182 is_renderer_initiated = pending_entry->is_renderer_initiated(); | |
183 pending_nav_entry_id = pending_entry->GetUniqueID(); | |
184 } | |
179 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create( | 185 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create( |
180 validated_url, render_frame_host->frame_tree_node(), | 186 validated_url, render_frame_host->frame_tree_node(), |
187 is_renderer_initiated, | |
181 false, // is_synchronous | 188 false, // is_synchronous |
182 is_iframe_srcdoc, // is_srcdoc | 189 is_iframe_srcdoc, // is_srcdoc |
183 navigation_start, pending_entry ? pending_entry->GetUniqueID() : 0)); | 190 navigation_start, pending_nav_entry_id)); |
184 } | 191 } |
185 | 192 |
186 void NavigatorImpl::DidFailProvisionalLoadWithError( | 193 void NavigatorImpl::DidFailProvisionalLoadWithError( |
187 RenderFrameHostImpl* render_frame_host, | 194 RenderFrameHostImpl* render_frame_host, |
188 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { | 195 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
189 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() | 196 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
190 << ", error_code: " << params.error_code | 197 << ", error_code: " << params.error_code |
191 << ", error_description: " << params.error_description | 198 << ", error_description: " << params.error_description |
192 << ", showing_repost_interstitial: " << | 199 << ", showing_repost_interstitial: " << |
193 params.showing_repost_interstitial | 200 params.showing_repost_interstitial |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 common_params.url, | 895 common_params.url, |
889 frame_tree_node->current_frame_host()->GetSiteInstance(), nullptr); | 896 frame_tree_node->current_frame_host()->GetSiteInstance(), nullptr); |
890 navigation_data_.reset(); | 897 navigation_data_.reset(); |
891 } | 898 } |
892 | 899 |
893 // For main frames, NavigationHandle will be created after the call to | 900 // For main frames, NavigationHandle will be created after the call to |
894 // |DidStartMainFrameNavigation|, so it receives the most up to date pending | 901 // |DidStartMainFrameNavigation|, so it receives the most up to date pending |
895 // entry from the NavigationController. | 902 // entry from the NavigationController. |
896 NavigationEntry* pending_entry = controller_->GetPendingEntry(); | 903 NavigationEntry* pending_entry = controller_->GetPendingEntry(); |
897 navigation_request->CreateNavigationHandle( | 904 navigation_request->CreateNavigationHandle( |
898 pending_entry ? pending_entry->GetUniqueID() : 0); | 905 true, pending_entry ? pending_entry->GetUniqueID() : 0); |
899 navigation_request->BeginNavigation(); | 906 navigation_request->BeginNavigation(); |
900 } | 907 } |
901 | 908 |
902 // PlzNavigate | 909 // PlzNavigate |
903 void NavigatorImpl::FailedNavigation(FrameTreeNode* frame_tree_node, | 910 void NavigatorImpl::FailedNavigation(FrameTreeNode* frame_tree_node, |
904 bool has_stale_copy_in_cache, | 911 bool has_stale_copy_in_cache, |
905 int error_code) { | 912 int error_code) { |
906 CHECK(IsBrowserSideNavigationEnabled()); | 913 CHECK(IsBrowserSideNavigationEnabled()); |
907 | 914 |
908 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); | 915 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
988 navigation_start, controller_); | 995 navigation_start, controller_); |
989 NavigationRequest* navigation_request = scoped_request.get(); | 996 NavigationRequest* navigation_request = scoped_request.get(); |
990 | 997 |
991 // For Javascript navigations, do not assign the NavigationRequest to the | 998 // For Javascript navigations, do not assign the NavigationRequest to the |
992 // FrameTreeNode, as navigating to a Javascript URL should not interrupt a | 999 // FrameTreeNode, as navigating to a Javascript URL should not interrupt a |
993 // previous navigation. BeginNavigation will have it commit, and the | 1000 // previous navigation. BeginNavigation will have it commit, and the |
994 // scoped_request will be destroyed at the end of this function. | 1001 // scoped_request will be destroyed at the end of this function. |
995 if (!dest_url.SchemeIs(url::kJavaScriptScheme)) | 1002 if (!dest_url.SchemeIs(url::kJavaScriptScheme)) |
996 frame_tree_node->CreatedNavigationRequest(std::move(scoped_request)); | 1003 frame_tree_node->CreatedNavigationRequest(std::move(scoped_request)); |
997 | 1004 |
998 navigation_request->CreateNavigationHandle(entry.GetUniqueID()); | 1005 navigation_request->CreateNavigationHandle(entry.is_renderer_initiated(), |
1006 entry.GetUniqueID()); | |
999 | 1007 |
1000 // Have the current renderer execute its beforeunload event if needed. If it | 1008 // Have the current renderer execute its beforeunload event if needed. If it |
1001 // is not needed (when beforeunload dispatch is not needed or this navigation | 1009 // is not needed (when beforeunload dispatch is not needed or this navigation |
1002 // is synchronous and same-site) then NavigationRequest::BeginNavigation | 1010 // is synchronous and same-site) then NavigationRequest::BeginNavigation |
1003 // should be directly called instead. | 1011 // should be directly called instead. |
1004 if (should_dispatch_beforeunload && | 1012 if (should_dispatch_beforeunload && |
1005 ShouldMakeNetworkRequestForURL( | 1013 ShouldMakeNetworkRequestForURL( |
1006 navigation_request->common_params().url)) { | 1014 navigation_request->common_params().url)) { |
1007 navigation_request->SetWaitingForRendererResponse(); | 1015 navigation_request->SetWaitingForRendererResponse(); |
1008 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); | 1016 frame_tree_node->current_frame_host()->DispatchBeforeUnload(true); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1096 if (pending_entry) { | 1104 if (pending_entry) { |
1097 entry->set_transferred_global_request_id( | 1105 entry->set_transferred_global_request_id( |
1098 pending_entry->transferred_global_request_id()); | 1106 pending_entry->transferred_global_request_id()); |
1099 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 1107 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
1100 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 1108 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
1101 } | 1109 } |
1102 | 1110 |
1103 // If there's a current NavigationHandle, update its pending NavEntry ID. | 1111 // If there's a current NavigationHandle, update its pending NavEntry ID. |
1104 // This is necessary for transfer navigations. The handle may be null in | 1112 // This is necessary for transfer navigations. The handle may be null in |
1105 // PlzNavigate. | 1113 // PlzNavigate. |
1106 if (navigation_handle) | 1114 if (navigation_handle) { |
1115 navigation_handle->set_is_renderer_initiated(true); | |
1107 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1116 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
1117 } | |
1108 | 1118 |
1109 controller_->SetPendingEntry(std::move(entry)); | 1119 controller_->SetPendingEntry(std::move(entry)); |
1110 if (delegate_) | 1120 if (delegate_) |
1111 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1121 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
1112 } | 1122 } |
1113 } | 1123 } |
1114 | 1124 |
1115 void NavigatorImpl::DiscardPendingEntryOnFailureIfNeeded( | 1125 void NavigatorImpl::DiscardPendingEntryOnFailureIfNeeded( |
1116 NavigationHandleImpl* handle) { | 1126 NavigationHandleImpl* handle) { |
1117 // Racy conditions can cause a fail message to arrive after its corresponding | 1127 // Racy conditions can cause a fail message to arrive after its corresponding |
(...skipping 29 matching lines...) Expand all Loading... | |
1147 if (pending_entry != controller_->GetVisibleEntry() || | 1157 if (pending_entry != controller_->GetVisibleEntry() || |
1148 !should_preserve_entry) { | 1158 !should_preserve_entry) { |
1149 controller_->DiscardPendingEntry(true); | 1159 controller_->DiscardPendingEntry(true); |
1150 | 1160 |
1151 // Also force the UI to refresh. | 1161 // Also force the UI to refresh. |
1152 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1162 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
1153 } | 1163 } |
1154 } | 1164 } |
1155 | 1165 |
1156 } // namespace content | 1166 } // namespace content |
OLD | NEW |