Index: content/renderer/render_frame_impl.cc |
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
index 1d26e5940b95c7e048e0c00402c46f46e2753403..475451bbd2821c03a393dbbb7ea369774a341620 100644 |
--- a/content/renderer/render_frame_impl.cc |
+++ b/content/renderer/render_frame_impl.cc |
@@ -3791,10 +3791,11 @@ void RenderFrameImpl::willSendRequest( |
// If the navigation is browser-initiated, the NavigationState contains the |
// correct value instead of the WebDataSource. |
// |
- // TODO(davidben): Avoid this awkward duplication of state. See comment on |
- // NavigationState::should_replace_current_entry(). |
- should_replace_current_entry = |
- navigation_state->common_params().should_replace_current_entry; |
+ // TODO(creis): Remove should_replace_current_entry from NavigationState |
+ // once we verify this is a safe change. |
+ CHECK(!navigation_state->common_params().should_replace_current_entry || |
+ data_source->replacesCurrentHistoryItem()); |
+ should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
} |
int provider_id = kInvalidServiceWorkerProviderId; |
@@ -4452,6 +4453,7 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad( |
params.intended_as_new_entry = |
navigation_state->request_params().intended_as_new_entry; |
params.did_create_new_entry = commit_type == blink::WebStandardCommit; |
+ params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
params.post_id = -1; |
params.page_id = render_view_->page_id_; |
params.nav_entry_id = navigation_state->request_params().nav_entry_id; |
@@ -5266,10 +5268,17 @@ void RenderFrameImpl::OpenURL(const GURL& url, |
// This is necessary to preserve the should_replace_current_entry value on |
// cross-process redirects, in the event it was set by a previous process. |
// |
- // TODO(davidben): Avoid this awkward duplication of state. See comment on |
- // NavigationState::should_replace_current_entry(). |
- params.should_replace_current_entry = |
- pending_navigation_params_->common_params.should_replace_current_entry; |
+ // TODO(creis): Remove should_replace_current_entry from NavigationState |
+ // once we verify this is correct, since the WebDataSource should now be |
+ // correct. |
+ WebDataSource* ds = frame_->provisionalDataSource(); |
+ CHECK(ds); |
+ DocumentState* document_state = DocumentState::FromDataSource(ds); |
+ NavigationStateImpl* navigation_state = |
+ static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
+ CHECK_EQ(navigation_state->common_params().should_replace_current_entry, |
+ ds->replacesCurrentHistoryItem()); |
+ params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
} else { |
params.should_replace_current_entry = |
should_replace_current_entry && render_view_->history_list_length_; |
@@ -5346,8 +5355,12 @@ void RenderFrameImpl::NavigateInternal( |
pending_navigation_params_->common_params.navigation_start = |
base::TimeTicks(); |
- // Create parameters for a standard navigation. |
- blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; |
+ // Create parameters for a standard navigation, indicating whether it should |
+ // replace the current NavigationEntry. |
+ blink::WebFrameLoadType load_type = |
+ common_params.should_replace_current_entry |
+ ? blink::WebFrameLoadType::ReplaceCurrentItem |
+ : blink::WebFrameLoadType::Standard; |
blink::WebHistoryLoadType history_load_type = |
blink::WebHistoryDifferentDocumentLoad; |
bool should_load_request = false; |
@@ -5474,15 +5487,6 @@ void RenderFrameImpl::NavigateInternal( |
SanitizeNavigationTiming(load_type, common_params.navigation_start, |
renderer_navigation_start); |
- // PlzNavigate: Check if the load should replace the current item. |
- // TODO(clamy): Remove this when |
- // https://codereview.chromium.org/1250163002/ lands and makes it default |
- // for the current architecture. |
- if (browser_side_navigation && common_params.should_replace_current_entry) { |
- DCHECK(load_type == blink::WebFrameLoadType::Standard); |
- load_type = blink::WebFrameLoadType::ReplaceCurrentItem; |
- } |
- |
// Perform a navigation to a data url if needed. |
if (!common_params.base_url_for_data_url.is_empty() || |
(browser_side_navigation && |