Chromium Code Reviews| Index: content/browser/frame_host/navigation_request.cc |
| diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc |
| index a047b10686475e946f87bc5cd09d262fbb5026a3..ad85a164043f5b3d1ec19fcc79dd4a7f2a9a9b53 100644 |
| --- a/content/browser/frame_host/navigation_request.cc |
| +++ b/content/browser/frame_host/navigation_request.cc |
| @@ -72,12 +72,15 @@ void UpdateLoadFlagsWithCacheFlags( |
| *load_flags |= |
| net::LOAD_ONLY_FROM_CACHE | net::LOAD_SKIP_CACHE_VALIDATION; |
| break; |
| - case FrameMsg_Navigate_Type::NORMAL: |
| + case FrameMsg_Navigate_Type::SAME_DOCUMENT: |
| + case FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT: |
| + case FrameMsg_Navigate_Type::HISTORY_SAME_DOCUMENT: |
| + case FrameMsg_Navigate_Type::HISTORY_DIFFERENT_DOCUMENT: |
| if (is_post) |
| *load_flags |= net::LOAD_VALIDATE_CACHE; |
| break; |
| - default: |
| - break; |
| + case FrameMsg_Navigate_Type::UNSPECIFIED: |
|
nasko
2017/01/23 19:10:13
Let's see if we can just remove UNSPECIFIED and re
arthursonzogni
2017/01/24 15:17:04
Acknowledged.
|
| + NOTREACHED(); |
| } |
| } |
| @@ -231,8 +234,7 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
| blink::WebMixedContentContextType::Blockable, |
| initiator), |
| entry.ConstructRequestNavigationParams( |
| - frame_entry, is_same_document_history_load, |
| - is_history_navigation_in_new_child, |
| + frame_entry, is_history_navigation_in_new_child, |
| entry.GetSubframeUniqueNames(frame_tree_node), |
| frame_tree_node->has_committed_real_load(), |
| controller->GetPendingEntryIndex() == -1, |
| @@ -252,34 +254,42 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
| const BeginNavigationParams& begin_params, |
| int current_history_list_offset, |
| int current_history_list_length) { |
| - // TODO(clamy): Check if some PageState should be provided here. |
| + // Only normal navigations to a different document or reloads are expected. |
| + // - Renderer-initiated fragment-navigations never take place in the browser, |
| + // even with PlzNavigate. |
| + // - Restore-navigations are always browser-initiated. |
| + // - History-navigations use the browser-initiated path, event the ones that |
| + // are initiated by a javascript script, please see the IPC message |
| + // ViewHostMsg_GoToEntryAtOffset. |
| + DCHECK(FrameMsg_Navigate_Type::IsReload(common_params.navigation_type) || |
| + common_params.navigation_type == |
| + FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT); |
| + |
| // TODO(clamy): See how we should handle override of the user agent when the |
| // navigation may start in a renderer and commit in another one. |
| // TODO(clamy): See if the navigation start time should be measured in the |
| // renderer and sent to the browser instead of being measured here. |
| // TODO(clamy): The pending history list offset should be properly set. |
| RequestNavigationParams request_params( |
| - false, // is_overriding_user_agent |
| - std::vector<GURL>(), // redirects |
| - false, // can_load_local_resources |
| - PageState(), // page_state |
| - 0, // nav_entry_id |
| - false, // is_same_document_history_load |
| - false, // is_history_navigation_in_new_child |
| - std::map<std::string, bool>(), // subframe_unique_names |
| + false, // is_overriding_user_agent |
| + std::vector<GURL>(), // redirects |
| + false, // can_load_local_resources |
| + PageState(), // page_state |
| + 0, // nav_entry_id |
| + false, // is_history_navigation_in_new_child |
| + std::map<std::string, bool>(), // subframe_unique_names |
| frame_tree_node->has_committed_real_load(), |
| - false, // intended_as_new_entry |
| - -1, // pending_history_list_offset |
| + false, // intended_as_new_entry |
| + -1, // pending_history_list_offset |
| current_history_list_offset, current_history_list_length, |
| - false, // is_view_source |
| - false, // should_clear_history_list |
| + false, // is_view_source |
| + false, // should_clear_history_list |
| begin_params.has_user_gesture); |
| - std::unique_ptr<NavigationRequest> navigation_request( |
| - new NavigationRequest(frame_tree_node, common_params, begin_params, |
| - request_params, |
| - false, // browser_initiated |
| - false, // may_transfer |
| - nullptr, nullptr)); |
| + std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| + frame_tree_node, common_params, begin_params, request_params, |
| + false, // browser_initiated |
| + false, // may_transfer |
| + nullptr, nullptr)); |
| return navigation_request; |
| } |
| @@ -346,7 +356,8 @@ void NavigationRequest::BeginNavigation() { |
| state_ = STARTED; |
| RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); |
| - if (ShouldMakeNetworkRequestForURL(common_params_.url)) { |
| + if (ShouldMakeNetworkRequestForURL(common_params_.url) && |
| + !navigation_handle_->IsSamePage()) { |
| // It's safe to use base::Unretained because this NavigationRequest owns |
| // the NavigationHandle where the callback will be stored. |
| // TODO(clamy): pass the real value for |is_external_protocol| if needed. |
| @@ -382,13 +393,11 @@ void NavigationRequest::BeginNavigation() { |
| void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { |
| DCHECK_EQ(frame_tree_node_->navigation_request(), this); |
| - // TODO(nasko): Update the NavigationHandle creation to ensure that the |
| - // proper values are specified for is_same_page. |
| FrameTreeNode* frame_tree_node = frame_tree_node_; |
| std::unique_ptr<NavigationHandleImpl> navigation_handle = |
| NavigationHandleImpl::Create( |
| common_params_.url, frame_tree_node_, !browser_initiated_, |
| - false, // is_same_page |
| + FrameMsg_Navigate_Type::IsSameDocument(common_params_.navigation_type), |
| common_params_.navigation_start, pending_nav_entry_id, |
| false); // started_in_context_menu |
| @@ -708,7 +717,8 @@ void NavigationRequest::OnWillProcessResponseChecksComplete( |
| } |
| void NavigationRequest::CommitNavigation() { |
| - DCHECK(response_ || !ShouldMakeNetworkRequestForURL(common_params_.url)); |
| + DCHECK(response_ || !ShouldMakeNetworkRequestForURL(common_params_.url) || |
| + navigation_handle_->IsSamePage()); |
| DCHECK(!common_params_.url.SchemeIs(url::kJavaScriptScheme)); |
| // Retrieve the RenderFrameHost that needs to commit the navigation. |