| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 bool should_dispatch_beforeunload = | 1132 bool should_dispatch_beforeunload = |
| 1133 !is_same_document_history_load && | 1133 !is_same_document_history_load && |
| 1134 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); | 1134 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); |
| 1135 FrameMsg_Navigate_Type::Value navigation_type = | 1135 FrameMsg_Navigate_Type::Value navigation_type = |
| 1136 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 1136 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
| 1137 std::unique_ptr<NavigationRequest> scoped_request = | 1137 std::unique_ptr<NavigationRequest> scoped_request = |
| 1138 NavigationRequest::CreateBrowserInitiated( | 1138 NavigationRequest::CreateBrowserInitiated( |
| 1139 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, | 1139 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, |
| 1140 navigation_type, previews_state, is_same_document_history_load, | 1140 navigation_type, previews_state, is_same_document_history_load, |
| 1141 is_history_navigation_in_new_child, navigation_start, controller_); | 1141 is_history_navigation_in_new_child, navigation_start, controller_); |
| 1142 NavigationRequest* navigation_request = scoped_request.get(); | |
| 1143 | 1142 |
| 1144 // Navigation to a javascript URL is not a "real" navigation so there is no | 1143 // Navigation to a javascript URL is not a "real" navigation so there is no |
| 1145 // need to create a NavigationHandle. The navigation commits immediately and | 1144 // need to create a NavigationHandle. The navigation commits immediately and |
| 1146 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to | 1145 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to |
| 1147 // a Javascript URL should not interrupt a previous navigation. | 1146 // a Javascript URL should not interrupt a previous navigation. |
| 1148 // Note: The scoped_request will be destroyed at the end of this function. | 1147 // Note: The scoped_request will be destroyed at the end of this function. |
| 1149 if (dest_url.SchemeIs(url::kJavaScriptScheme)) { | 1148 if (dest_url.SchemeIs(url::kJavaScriptScheme)) { |
| 1150 RenderFrameHostImpl* render_frame_host = | 1149 RenderFrameHostImpl* render_frame_host = |
| 1151 frame_tree_node->render_manager()->GetFrameHostForNavigation( | 1150 frame_tree_node->render_manager()->GetFrameHostForNavigation( |
| 1152 *navigation_request); | 1151 *scoped_request.get()); |
| 1153 render_frame_host->CommitNavigation(nullptr, // response | 1152 render_frame_host->CommitNavigation(nullptr, // response |
| 1154 nullptr, // body | 1153 nullptr, // body |
| 1155 navigation_request->common_params(), | 1154 scoped_request->common_params(), |
| 1156 navigation_request->request_params(), | 1155 scoped_request->request_params(), |
| 1157 navigation_request->is_view_source()); | 1156 scoped_request->is_view_source()); |
| 1158 return; | 1157 return; |
| 1159 } | 1158 } |
| 1160 | 1159 |
| 1161 frame_tree_node->CreatedNavigationRequest(std::move(scoped_request)); | 1160 frame_tree_node->CreatedNavigationRequest(std::move(scoped_request)); |
| 1162 navigation_request->CreateNavigationHandle(entry.GetUniqueID()); | 1161 |
| 1162 frame_tree_node->navigation_request()->CreateNavigationHandle( |
| 1163 entry.GetUniqueID()); |
| 1164 |
| 1165 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); |
| 1166 if (!navigation_request) |
| 1167 return; // Navigation was synchronously stopped. |
| 1163 | 1168 |
| 1164 // Have the current renderer execute its beforeunload event if needed. If it | 1169 // Have the current renderer execute its beforeunload event if needed. If it |
| 1165 // is not needed then NavigationRequest::BeginNavigation should be directly | 1170 // is not needed then NavigationRequest::BeginNavigation should be directly |
| 1166 // called instead. | 1171 // called instead. |
| 1167 if (should_dispatch_beforeunload && !IsRendererDebugURL(dest_url)) { | 1172 if (should_dispatch_beforeunload && !IsRendererDebugURL(dest_url)) { |
| 1168 navigation_request->SetWaitingForRendererResponse(); | 1173 navigation_request->SetWaitingForRendererResponse(); |
| 1169 frame_tree_node->current_frame_host()->DispatchBeforeUnload( | 1174 frame_tree_node->current_frame_host()->DispatchBeforeUnload( |
| 1170 true, reload_type != ReloadType::NONE); | 1175 true, reload_type != ReloadType::NONE); |
| 1171 } else { | 1176 } else { |
| 1172 navigation_request->BeginNavigation(); | 1177 navigation_request->BeginNavigation(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 if (navigation_handle) | 1270 if (navigation_handle) |
| 1266 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1271 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
| 1267 | 1272 |
| 1268 controller_->SetPendingEntry(std::move(entry)); | 1273 controller_->SetPendingEntry(std::move(entry)); |
| 1269 if (delegate_) | 1274 if (delegate_) |
| 1270 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1275 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 1271 } | 1276 } |
| 1272 } | 1277 } |
| 1273 | 1278 |
| 1274 } // namespace content | 1279 } // namespace content |
| OLD | NEW |