| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/navigation_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/browser/appcache/appcache_navigation_handle.h" | 9 #include "content/browser/appcache/appcache_navigation_handle.h" |
| 10 #include "content/browser/appcache/chrome_appcache_service.h" | 10 #include "content/browser/appcache/chrome_appcache_service.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // Fill POST data in the request body. | 207 // Fill POST data in the request body. |
| 208 scoped_refptr<ResourceRequestBodyImpl> request_body; | 208 scoped_refptr<ResourceRequestBodyImpl> request_body; |
| 209 if (frame_entry.method() == "POST") | 209 if (frame_entry.method() == "POST") |
| 210 request_body = frame_entry.GetPostData(); | 210 request_body = frame_entry.GetPostData(); |
| 211 | 211 |
| 212 base::Optional<url::Origin> initiator = | 212 base::Optional<url::Origin> initiator = |
| 213 frame_tree_node->IsMainFrame() | 213 frame_tree_node->IsMainFrame() |
| 214 ? base::Optional<url::Origin>() | 214 ? base::Optional<url::Origin>() |
| 215 : base::Optional<url::Origin>( | 215 : base::Optional<url::Origin>( |
| 216 frame_tree_node->frame_tree()->root()->current_origin()); | 216 frame_tree_node->frame_tree()->root()->current_origin()); |
| 217 |
| 218 // While the navigation was started via the LoadURL path it may have come from |
| 219 // the renderer in the first place as part of OpenURL. |
| 220 bool browser_initiated = !entry.is_renderer_initiated(); |
| 221 |
| 217 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 222 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| 218 frame_tree_node, entry.ConstructCommonNavigationParams( | 223 frame_tree_node, entry.ConstructCommonNavigationParams( |
| 219 frame_entry, request_body, dest_url, dest_referrer, | 224 frame_entry, request_body, dest_url, dest_referrer, |
| 220 navigation_type, lofi_state, navigation_start), | 225 navigation_type, lofi_state, navigation_start), |
| 221 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, | 226 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, |
| 222 false, // has_user_gestures | 227 false, // has_user_gestures |
| 223 false, // skip_service_worker | 228 false, // skip_service_worker |
| 224 REQUEST_CONTEXT_TYPE_LOCATION, initiator), | 229 REQUEST_CONTEXT_TYPE_LOCATION, initiator), |
| 225 entry.ConstructRequestNavigationParams( | 230 entry.ConstructRequestNavigationParams( |
| 226 frame_entry, is_same_document_history_load, | 231 frame_entry, is_same_document_history_load, |
| 227 is_history_navigation_in_new_child, | 232 is_history_navigation_in_new_child, |
| 228 entry.GetSubframeUniqueNames(frame_tree_node), | 233 entry.GetSubframeUniqueNames(frame_tree_node), |
| 229 frame_tree_node->has_committed_real_load(), | 234 frame_tree_node->has_committed_real_load(), |
| 230 controller->GetPendingEntryIndex() == -1, | 235 controller->GetPendingEntryIndex() == -1, |
| 231 controller->GetIndexOfEntry(&entry), | 236 controller->GetIndexOfEntry(&entry), |
| 232 controller->GetLastCommittedEntryIndex(), | 237 controller->GetLastCommittedEntryIndex(), |
| 233 controller->GetEntryCount()), | 238 controller->GetEntryCount()), |
| 234 true, &frame_entry, &entry)); | 239 browser_initiated, |
| 240 true, // may_transfer |
| 241 &frame_entry, &entry)); |
| 235 return navigation_request; | 242 return navigation_request; |
| 236 } | 243 } |
| 237 | 244 |
| 238 // static | 245 // static |
| 239 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( | 246 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
| 240 FrameTreeNode* frame_tree_node, | 247 FrameTreeNode* frame_tree_node, |
| 241 const CommonNavigationParams& common_params, | 248 const CommonNavigationParams& common_params, |
| 242 const BeginNavigationParams& begin_params, | 249 const BeginNavigationParams& begin_params, |
| 243 int current_history_list_offset, | 250 int current_history_list_offset, |
| 244 int current_history_list_length) { | 251 int current_history_list_length) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 259 std::map<std::string, bool>(), // subframe_unique_names | 266 std::map<std::string, bool>(), // subframe_unique_names |
| 260 frame_tree_node->has_committed_real_load(), | 267 frame_tree_node->has_committed_real_load(), |
| 261 false, // intended_as_new_entry | 268 false, // intended_as_new_entry |
| 262 -1, // pending_history_list_offset | 269 -1, // pending_history_list_offset |
| 263 current_history_list_offset, current_history_list_length, | 270 current_history_list_offset, current_history_list_length, |
| 264 false, // is_view_source | 271 false, // is_view_source |
| 265 false, // should_clear_history_list | 272 false, // should_clear_history_list |
| 266 begin_params.has_user_gesture); | 273 begin_params.has_user_gesture); |
| 267 std::unique_ptr<NavigationRequest> navigation_request( | 274 std::unique_ptr<NavigationRequest> navigation_request( |
| 268 new NavigationRequest(frame_tree_node, common_params, begin_params, | 275 new NavigationRequest(frame_tree_node, common_params, begin_params, |
| 269 request_params, false, nullptr, nullptr)); | 276 request_params, |
| 277 false, // browser_initiated |
| 278 false, // may_transfer |
| 279 nullptr, nullptr)); |
| 270 return navigation_request; | 280 return navigation_request; |
| 271 } | 281 } |
| 272 | 282 |
| 273 NavigationRequest::NavigationRequest( | 283 NavigationRequest::NavigationRequest( |
| 274 FrameTreeNode* frame_tree_node, | 284 FrameTreeNode* frame_tree_node, |
| 275 const CommonNavigationParams& common_params, | 285 const CommonNavigationParams& common_params, |
| 276 const BeginNavigationParams& begin_params, | 286 const BeginNavigationParams& begin_params, |
| 277 const RequestNavigationParams& request_params, | 287 const RequestNavigationParams& request_params, |
| 278 bool browser_initiated, | 288 bool browser_initiated, |
| 289 bool may_transfer, |
| 279 const FrameNavigationEntry* frame_entry, | 290 const FrameNavigationEntry* frame_entry, |
| 280 const NavigationEntryImpl* entry) | 291 const NavigationEntryImpl* entry) |
| 281 : frame_tree_node_(frame_tree_node), | 292 : frame_tree_node_(frame_tree_node), |
| 282 common_params_(common_params), | 293 common_params_(common_params), |
| 283 begin_params_(begin_params), | 294 begin_params_(begin_params), |
| 284 request_params_(request_params), | 295 request_params_(request_params), |
| 285 browser_initiated_(browser_initiated), | 296 browser_initiated_(browser_initiated), |
| 286 state_(NOT_STARTED), | 297 state_(NOT_STARTED), |
| 287 restore_type_(RestoreType::NONE), | 298 restore_type_(RestoreType::NONE), |
| 288 is_view_source_(false), | 299 is_view_source_(false), |
| 289 bindings_(NavigationEntryImpl::kInvalidBindings), | 300 bindings_(NavigationEntryImpl::kInvalidBindings), |
| 290 associated_site_instance_type_(AssociatedSiteInstanceType::NONE) { | 301 associated_site_instance_type_(AssociatedSiteInstanceType::NONE), |
| 302 may_transfer_(may_transfer) { |
| 291 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr)); | 303 DCHECK(!browser_initiated || (entry != nullptr && frame_entry != nullptr)); |
| 292 if (browser_initiated) { | 304 if (may_transfer) { |
| 293 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node); | 305 FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame_tree_node); |
| 294 if (frame_entry) { | 306 if (frame_entry) { |
| 295 source_site_instance_ = frame_entry->source_site_instance(); | 307 source_site_instance_ = frame_entry->source_site_instance(); |
| 296 dest_site_instance_ = frame_entry->site_instance(); | 308 dest_site_instance_ = frame_entry->site_instance(); |
| 297 } | 309 } |
| 298 | 310 |
| 299 restore_type_ = entry->restore_type(); | 311 restore_type_ = entry->restore_type(); |
| 300 is_view_source_ = entry->IsViewSourceMode(); | 312 is_view_source_ = entry->IsViewSourceMode(); |
| 301 bindings_ = entry->bindings(); | 313 bindings_ = entry->bindings(); |
| 302 } else { | 314 } else { |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 699 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
| 688 | 700 |
| 689 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 701 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
| 690 common_params_, request_params_, | 702 common_params_, request_params_, |
| 691 is_view_source_); | 703 is_view_source_); |
| 692 | 704 |
| 693 frame_tree_node_->ResetNavigationRequest(true); | 705 frame_tree_node_->ResetNavigationRequest(true); |
| 694 } | 706 } |
| 695 | 707 |
| 696 } // namespace content | 708 } // namespace content |
| OLD | NEW |