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 4a0c7cec73ffc4825e29fd96547d6e33faaef1c2..8f2b67aa5d48c97dab6c3c1788a8dda35f3c798f 100644 |
| --- a/content/browser/frame_host/navigation_request.cc |
| +++ b/content/browser/frame_host/navigation_request.cc |
| @@ -206,43 +206,14 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
| bool is_history_navigation_in_new_child, |
| const base::TimeTicks& navigation_start, |
| NavigationControllerImpl* controller) { |
| - // Fill POST data in the request body. |
| - scoped_refptr<ResourceRequestBodyImpl> request_body; |
| - if (frame_entry.method() == "POST") |
| - request_body = frame_entry.GetPostData(); |
| - |
| - base::Optional<url::Origin> initiator = |
| - frame_tree_node->IsMainFrame() |
| - ? base::Optional<url::Origin>() |
| - : base::Optional<url::Origin>( |
| - frame_tree_node->frame_tree()->root()->current_origin()); |
| - |
| // While the navigation was started via the LoadURL path it may have come from |
| // the renderer in the first place as part of OpenURL. |
| bool browser_initiated = !entry.is_renderer_initiated(); |
|
clamy
2017/02/15 16:27:55
Here we set whether the navigation was browser ini
ananta
2017/02/15 23:45:02
Thanks. Added code to set the flag for child frame
|
| - std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| - frame_tree_node, entry.ConstructCommonNavigationParams( |
| - frame_entry, request_body, dest_url, dest_referrer, |
| - navigation_type, previews_state, navigation_start), |
| - BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, |
| - false, // has_user_gestures |
| - false, // skip_service_worker |
| - REQUEST_CONTEXT_TYPE_LOCATION, |
| - blink::WebMixedContentContextType::Blockable, |
| - initiator), |
| - entry.ConstructRequestNavigationParams( |
| - frame_entry, is_history_navigation_in_new_child, |
| - entry.GetSubframeUniqueNames(frame_tree_node), |
| - frame_tree_node->has_committed_real_load(), |
| - controller->GetPendingEntryIndex() == -1, |
| - controller->GetIndexOfEntry(&entry), |
| - controller->GetLastCommittedEntryIndex(), |
| - controller->GetEntryCount()), |
| - browser_initiated, |
| - true, // may_transfer |
| - &frame_entry, &entry)); |
| - return navigation_request; |
| + return CreateNavigationHelper( |
| + frame_tree_node, dest_url, dest_referrer, frame_entry, entry, |
| + navigation_type, previews_state, is_history_navigation_in_new_child, |
| + false, browser_initiated, navigation_start, controller); |
| } |
| // static |
| @@ -258,7 +229,8 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
| // - 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. |
| + // ViewHostMsg_GoToEntryAtOffset. Exceptions include child frames which are |
| + // navigated without user gesture. |
| DCHECK(FrameMsg_Navigate_Type::IsReload(common_params.navigation_type) || |
| common_params.navigation_type == |
| FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT); |
| @@ -283,6 +255,7 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
| 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 |
| @@ -291,6 +264,76 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
| return navigation_request; |
| } |
| +// static |
| +std::unique_ptr<NavigationRequest> |
| +NavigationRequest::CreateRendererInitiatedHistoryNavigation( |
| + FrameTreeNode* frame_tree_node, |
| + const GURL& dest_url, |
| + const Referrer& dest_referrer, |
| + const FrameNavigationEntry& frame_entry, |
| + const NavigationEntryImpl& entry, |
| + FrameMsg_Navigate_Type::Value navigation_type, |
| + PreviewsState previews_state, |
| + bool is_history_navigation_in_new_child, |
| + bool has_user_gesture, |
| + const base::TimeTicks& navigation_start, |
| + NavigationControllerImpl* controller) { |
| + DCHECK_EQ(true, is_history_navigation_in_new_child); |
| + |
| + return CreateNavigationHelper( |
| + frame_tree_node, dest_url, dest_referrer, frame_entry, entry, |
| + navigation_type, previews_state, is_history_navigation_in_new_child, |
| + has_user_gesture, false, navigation_start, controller); |
| +} |
| + |
| +std::unique_ptr<NavigationRequest> NavigationRequest::CreateNavigationHelper( |
| + FrameTreeNode* frame_tree_node, |
| + const GURL& dest_url, |
| + const Referrer& dest_referrer, |
| + const FrameNavigationEntry& frame_entry, |
| + const NavigationEntryImpl& entry, |
| + FrameMsg_Navigate_Type::Value navigation_type, |
| + PreviewsState previews_state, |
| + bool is_same_document_history_load, |
| + bool is_history_navigation_in_new_child, |
| + bool browser_initiated, |
| + const base::TimeTicks& navigation_start, |
| + NavigationControllerImpl* controller) { |
| + // Fill POST data in the request body. |
| + scoped_refptr<ResourceRequestBodyImpl> request_body; |
| + if (frame_entry.method() == "POST") |
| + request_body = frame_entry.GetPostData(); |
| + |
| + base::Optional<url::Origin> initiator = |
| + frame_tree_node->IsMainFrame() |
| + ? base::Optional<url::Origin>() |
| + : base::Optional<url::Origin>( |
| + frame_tree_node->frame_tree()->root()->current_origin()); |
| + |
| + std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| + frame_tree_node, entry.ConstructCommonNavigationParams( |
| + frame_entry, request_body, dest_url, dest_referrer, |
| + navigation_type, previews_state, navigation_start), |
| + BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, |
| + false, // has_user_gestures |
| + false, // skip_service_worker |
| + REQUEST_CONTEXT_TYPE_LOCATION, |
| + blink::WebMixedContentContextType::Blockable, |
| + initiator), |
| + entry.ConstructRequestNavigationParams( |
| + frame_entry, is_history_navigation_in_new_child, |
| + entry.GetSubframeUniqueNames(frame_tree_node), |
| + frame_tree_node->has_committed_real_load(), |
| + controller->GetPendingEntryIndex() == -1, |
| + controller->GetIndexOfEntry(&entry), |
| + controller->GetLastCommittedEntryIndex(), |
| + controller->GetEntryCount()), |
| + browser_initiated, |
| + true, // may_transfer |
| + &frame_entry, &entry)); |
| + return navigation_request; |
| +} |
| + |
| NavigationRequest::NavigationRequest( |
| FrameTreeNode* frame_tree_node, |
| const CommonNavigationParams& common_params, |