Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Unified Diff: content/renderer/render_frame_impl.cc

Issue 2655143002: Drop replacesCurrentHistoryItem, NavigationType (Closed)
Patch Set: More compile fixes Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_impl_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 71213fce8182bc921564fdfe5a70ff0f05004e79..7adb62b64300b35b19b102b6529f300259cda131 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -302,7 +302,6 @@ using blink::WebMediaPlayer;
using blink::WebMediaPlayerClient;
using blink::WebMediaPlayerEncryptedMediaClient;
using blink::WebNavigationPolicy;
-using blink::WebNavigationType;
using blink::WebNode;
using blink::WebPluginDocument;
using blink::WebPluginParams;
@@ -633,17 +632,20 @@ CommonNavigationParams MakeCommonNavigationParams(
static_cast<FrameMsg_UILoadMetricsReportType::Value>(
info.urlRequest.inputPerfMetricReportPolicy());
+ bool is_reload = info.loadType == WebFrameLoadType::Reload ||
+ info.loadType == WebFrameLoadType::ReloadMainResource ||
+ info.loadType == WebFrameLoadType::ReloadBypassingCache;
FrameMsg_Navigate_Type::Value navigation_type =
- info.navigationType == blink::WebNavigationTypeReload
- ? FrameMsg_Navigate_Type::RELOAD
- : FrameMsg_Navigate_Type::NORMAL;
+ is_reload ? FrameMsg_Navigate_Type::RELOAD
+ : FrameMsg_Navigate_Type::NORMAL;
const RequestExtraData* extra_data =
static_cast<RequestExtraData*>(info.urlRequest.getExtraData());
DCHECK(extra_data);
return CommonNavigationParams(
info.urlRequest.url(), referrer, extra_data->transition_type(),
- navigation_type, true, info.replacesCurrentHistoryItem, ui_timestamp,
+ navigation_type, true,
+ info.loadType == WebFrameLoadType::ReplaceCurrentItem, ui_timestamp,
report_type, GURL(), GURL(),
static_cast<PreviewsState>(info.urlRequest.getPreviewsState()),
base::TimeTicks::Now(), info.urlRequest.httpMethod().latin1(),
@@ -2502,7 +2504,7 @@ blink::WebPlugin* RenderFrameImpl::CreatePlugin(
void RenderFrameImpl::LoadURLExternally(const blink::WebURLRequest& request,
blink::WebNavigationPolicy policy) {
- loadURLExternally(request, policy, WebString(), false);
+ loadURLExternally(request, policy, WebString(), WebFrameLoadType::Standard);
}
void RenderFrameImpl::loadErrorPage(int reason) {
@@ -3271,7 +3273,7 @@ void RenderFrameImpl::didAddMessageToConsole(
void RenderFrameImpl::loadURLExternally(const blink::WebURLRequest& request,
blink::WebNavigationPolicy policy,
const blink::WebString& suggested_name,
- bool should_replace_current_entry) {
+ WebFrameLoadType load_type) {
Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame_, request));
if (policy == blink::WebNavigationPolicyDownload) {
FrameHostMsg_DownloadUrl_Params params;
@@ -3286,8 +3288,7 @@ void RenderFrameImpl::loadURLExternally(const blink::WebURLRequest& request,
} else {
OpenURL(request.url(), IsHttpPost(request),
GetRequestBodyForWebURLRequest(request),
- GetWebURLRequestHeaders(request), referrer, policy,
- should_replace_current_entry, false);
+ GetWebURLRequestHeaders(request), referrer, policy, load_type);
}
}
@@ -3420,27 +3421,20 @@ void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame,
content_initiated));
}
-void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame) {
- DCHECK_EQ(frame_, frame);
- WebDataSource* ds = frame->provisionalDataSource();
-
- // In fast/loader/stop-provisional-loads.html, we abort the load before this
- // callback is invoked.
- if (!ds)
- return;
-
+void RenderFrameImpl::didStartProvisionalLoad(WebDataSource* ds,
+ WebFrameLoadType type) {
TRACE_EVENT2("navigation,benchmark,rail",
"RenderFrameImpl::didStartProvisionalLoad", "id", routing_id_,
"url", ds->getRequest().url().string().utf8());
DocumentState* document_state = DocumentState::FromDataSource(ds);
NavigationStateImpl* navigation_state = static_cast<NavigationStateImpl*>(
document_state->navigation_state());
- bool is_top_most = !frame->parent();
+ bool is_top_most = !frame_->parent();
if (is_top_most) {
render_view_->set_navigation_gesture(
WebUserGestureIndicator::isProcessingUserGesture() ?
NavigationGestureUser : NavigationGestureAuto);
- } else if (ds->replacesCurrentHistoryItem()) {
+ } else if (type == WebFrameLoadType::ReplaceCurrentItem) {
// Subframe navigations that don't add session history items must be
// marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
// handle loading of error pages.
@@ -3452,7 +3446,7 @@ void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame) {
DCHECK(!navigation_start.is_null());
for (auto& observer : render_view_->observers())
- observer.DidStartProvisionalLoad(frame);
+ observer.DidStartProvisionalLoad(frame_);
for (auto& observer : observers_)
observer.DidStartProvisionalLoad();
@@ -3522,13 +3516,13 @@ void RenderFrameImpl::didFailProvisionalLoad(
}
void RenderFrameImpl::didCommitProvisionalLoad(
- blink::WebLocalFrame* frame,
+ blink::WebDataSource* data_source,
+ blink::WebFrameLoadType load_type,
const blink::WebHistoryItem& item,
blink::WebHistoryCommitType commit_type) {
TRACE_EVENT2("navigation,rail", "RenderFrameImpl::didCommitProvisionalLoad",
"id", routing_id_,
"url", GetLoadingUrl().possibly_invalid_spec());
- DCHECK_EQ(frame_, frame);
// TODO(dcheng): Remove this UMA once we have enough measurements.
// Record the number of subframes where window.name changes between the
@@ -3566,12 +3560,11 @@ void RenderFrameImpl::didCommitProvisionalLoad(
committed_first_load_ = true;
}
- DocumentState* document_state =
- DocumentState::FromDataSource(frame->dataSource());
+ DocumentState* document_state = DocumentState::FromDataSource(data_source);
NavigationStateImpl* navigation_state =
static_cast<NavigationStateImpl*>(document_state->navigation_state());
WebURLResponseExtraDataImpl* extra_data =
- GetExtraDataFromResponse(frame->dataSource()->response());
+ GetExtraDataFromResponse(data_source->response());
// Only update the PreviewsState and effective connection type states for new
// main frame documents. Subframes inherit from the main frame and should not
// change at commit time.
@@ -3643,13 +3636,13 @@ void RenderFrameImpl::didCommitProvisionalLoad(
}
for (auto& observer : render_view_->observers_)
- observer.DidCommitProvisionalLoad(frame, is_new_navigation);
+ observer.DidCommitProvisionalLoad(frame_, is_new_navigation);
for (auto& observer : observers_) {
observer.DidCommitProvisionalLoad(is_new_navigation,
navigation_state->WasWithinSamePage());
}
- if (!frame->parent()) { // Only for top frames.
+ if (!frame_->parent()) { // Only for top frames.
RenderThreadImpl* render_thread_impl = RenderThreadImpl::current();
if (render_thread_impl) { // Can be NULL in tests.
render_thread_impl->histogram_customizer()->
@@ -3673,10 +3666,10 @@ void RenderFrameImpl::didCommitProvisionalLoad(
// new navigation.
navigation_state->set_request_committed(true);
- SendDidCommitProvisionalLoad(frame, commit_type, item);
+ SendDidCommitProvisionalLoad(data_source, load_type, item);
// Check whether we have new encoding name.
- UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
+ UpdateEncoding(frame_, frame_->view()->pageEncoding().utf8());
}
void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) {
@@ -3974,21 +3967,20 @@ void RenderFrameImpl::didFinishLoad(blink::WebLocalFrame* frame) {
}
void RenderFrameImpl::didNavigateWithinPage(
- blink::WebLocalFrame* frame,
+ blink::WebDataSource* data_source,
+ blink::WebFrameLoadType load_type,
const blink::WebHistoryItem& item,
blink::WebHistoryCommitType commit_type,
bool content_initiated) {
TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didNavigateWithinPage",
"id", routing_id_);
- DCHECK_EQ(frame_, frame);
- DocumentState* document_state =
- DocumentState::FromDataSource(frame->dataSource());
+ DocumentState* document_state = DocumentState::FromDataSource(data_source);
UpdateNavigationState(document_state, true /* was_within_same_page */,
content_initiated);
static_cast<NavigationStateImpl*>(document_state->navigation_state())
->set_was_within_same_page(true);
- didCommitProvisionalLoad(frame, item, commit_type);
+ didCommitProvisionalLoad(data_source, load_type, item, commit_type);
}
void RenderFrameImpl::didUpdateCurrentHistoryItem() {
@@ -4166,7 +4158,8 @@ void RenderFrameImpl::saveImageFromDataURL(const blink::WebString& data_url) {
}
void RenderFrameImpl::willSendRequest(blink::WebLocalFrame* frame,
- blink::WebURLRequest& request) {
+ blink::WebURLRequest& request,
+ blink::WebFrameLoadType load_type) {
DCHECK_EQ(frame_, frame);
// Set the first party for cookies url if it has not been set yet (new
@@ -4253,11 +4246,6 @@ void RenderFrameImpl::willSendRequest(blink::WebLocalFrame* frame,
// present.
request.addHTTPOriginIfNeeded(WebSecurityOrigin::createUnique());
- // Attach |should_replace_current_entry| state to requests so that, should
- // this navigation later require a request transfer, all state is preserved
- // when it is re-created in the new process.
- bool should_replace_current_entry = data_source->replacesCurrentHistoryItem();
-
int provider_id = kInvalidServiceWorkerProviderId;
if (request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel ||
request.getFrameType() == blink::WebURLRequest::FrameTypeNested) {
@@ -4306,7 +4294,8 @@ void RenderFrameImpl::willSendRequest(blink::WebLocalFrame* frame,
extra_data->set_allow_download(
navigation_state->common_params().allow_download);
extra_data->set_transition_type(transition_type);
- extra_data->set_should_replace_current_entry(should_replace_current_entry);
+ extra_data->set_should_replace_current_entry(
+ load_type == WebFrameLoadType::ReplaceCurrentItem);
extra_data->set_service_worker_provider_id(provider_id);
extra_data->set_stream_override(std::move(stream_override));
bool is_prefetch =
@@ -4788,11 +4777,9 @@ const RenderFrameImpl* RenderFrameImpl::GetLocalRoot() const {
// Tell the embedding application that the URL of the active page has changed.
void RenderFrameImpl::SendDidCommitProvisionalLoad(
- blink::WebFrame* frame,
- blink::WebHistoryCommitType commit_type,
+ blink::WebDataSource* ds,
+ blink::WebFrameLoadType load_type,
const blink::WebHistoryItem& item) {
- DCHECK_EQ(frame_, frame);
- WebDataSource* ds = frame->dataSource();
DCHECK(ds);
const WebURLRequest& request = ds->getRequest();
@@ -4817,8 +4804,9 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad(
params.method = "GET";
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.did_create_new_entry = load_type == WebFrameLoadType::Standard;
+ params.should_replace_current_entry =
+ load_type == WebFrameLoadType::ReplaceCurrentItem;
params.post_id = -1;
params.nav_entry_id = navigation_state->request_params().nav_entry_id;
// We need to track the RenderViewHost routing_id because of downstream
@@ -4835,18 +4823,18 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad(
// Set the origin of the frame. This will be replicated to the corresponding
// RenderFrameProxies in other processes.
- params.origin = frame->document().getSecurityOrigin();
+ params.origin = frame_->document().getSecurityOrigin();
- params.insecure_request_policy = frame->getInsecureRequestPolicy();
+ params.insecure_request_policy = frame_->getInsecureRequestPolicy();
params.has_potentially_trustworthy_unique_origin =
- frame->document().getSecurityOrigin().isUnique() &&
- frame->document().getSecurityOrigin().isPotentiallyTrustworthy();
+ frame_->document().getSecurityOrigin().isUnique() &&
+ frame_->document().getSecurityOrigin().isPotentiallyTrustworthy();
// Set the URL to be displayed in the browser UI to the user.
params.url = GetLoadingUrl();
- if (GURL(frame->document().baseURL()) != params.url)
- params.base_url = frame->document().baseURL();
+ if (GURL(frame_->document().baseURL()) != params.url)
+ params.base_url = frame_->document().baseURL();
GetRedirectChain(ds, &params.redirects);
params.should_update_history =
@@ -4879,10 +4867,10 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad(
Referrer(params.redirects[0], ds->getRequest().getReferrerPolicy());
} else {
params.referrer =
- RenderViewImpl::GetReferrerFromRequest(frame, ds->getRequest());
+ RenderViewImpl::GetReferrerFromRequest(frame_, ds->getRequest());
}
- if (!frame->parent()) {
+ if (!frame_->parent()) {
// Top-level navigation.
// Reset the zoom limits in case a plugin had changed them previously. This
@@ -4952,16 +4940,16 @@ void RenderFrameImpl::SendDidCommitProvisionalLoad(
navigation_state->request_params().should_clear_history_list;
params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>(
- frame->dataSource()->getRequest().inputPerfMetricReportPolicy());
- params.ui_timestamp = base::TimeTicks() +
- base::TimeDelta::FromSecondsD(
- frame->dataSource()->getRequest().uiStartTime());
+ ds->getRequest().inputPerfMetricReportPolicy());
+ params.ui_timestamp =
+ base::TimeTicks() +
+ base::TimeDelta::FromSecondsD(ds->getRequest().uiStartTime());
} else {
// Subframe navigation: the type depends on whether this navigation
// generated a new session history entry. When they do generate a session
// history entry, it means the user initiated the navigation and we should
// mark it as such.
- if (commit_type == blink::WebStandardCommit)
+ if (load_type == WebFrameLoadType::Standard)
params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
else
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
@@ -5218,6 +5206,9 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
info.extraData ||
(pending_navigation_params_ &&
!pending_navigation_params_->request_params.redirects.empty());
+ bool is_reload = info.loadType == WebFrameLoadType::Reload ||
+ info.loadType == WebFrameLoadType::ReloadMainResource ||
+ info.loadType == WebFrameLoadType::ReloadBypassingCache;
#ifdef OS_ANDROID
bool render_view_was_created_by_renderer =
@@ -5226,7 +5217,8 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
// crbug.com/325351 is resolved.
if (GetContentClient()->renderer()->HandleNavigation(
this, is_content_initiated, render_view_was_created_by_renderer,
- frame_, info.urlRequest, info.navigationType, info.defaultPolicy,
+ frame_, info.urlRequest,
+ info.loadType == WebFrameLoadType::BackForward, info.defaultPolicy,
is_redirect)) {
return blink::WebNavigationPolicyIgnore;
}
@@ -5247,7 +5239,7 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
OpenURL(url, IsHttpPost(info.urlRequest),
GetRequestBodyForWebURLRequest(info.urlRequest),
GetWebURLRequestHeaders(info.urlRequest), referrer,
- info.defaultPolicy, info.replacesCurrentHistoryItem, false);
+ info.defaultPolicy, info.loadType);
return blink::WebNavigationPolicyIgnore; // Suppress the load here.
}
@@ -5257,8 +5249,8 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
// that have history items, or if it's staying at the initial about:blank URL,
// fall back to loading the default url. (We remove each name as we encounter
// it, because it will only be used once as the frame is created.)
- if (info.isHistoryNavigationInNewChildFrame && is_content_initiated &&
- frame_->parent()) {
+ if (info.loadType == WebFrameLoadType::InitialHistoryLoad &&
+ is_content_initiated && frame_->parent()) {
// Check whether the browser has a history item for this frame that isn't
// just staying at the initial about:blank document.
bool should_ask_browser = false;
@@ -5280,7 +5272,7 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
OpenURL(url, IsHttpPost(info.urlRequest),
GetRequestBodyForWebURLRequest(info.urlRequest),
GetWebURLRequestHeaders(info.urlRequest), referrer,
- info.defaultPolicy, info.replacesCurrentHistoryItem, true);
+ info.defaultPolicy, info.loadType);
// Suppress the load in Blink but mark the frame as loading.
return blink::WebNavigationPolicyHandledByClient;
} else {
@@ -5322,8 +5314,7 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) ||
(cumulative_bindings & BINDINGS_POLICY_WEB_UI) ||
url.SchemeIs(kViewSourceScheme) ||
- (frame_->isViewSourceModeEnabled() &&
- info.navigationType != blink::WebNavigationTypeReload);
+ (frame_->isViewSourceModeEnabled() && is_reload);
if (!should_fork && url.SchemeIs(url::kFileScheme)) {
// Fork non-file to file opens. Note that this may fork unnecessarily if
@@ -5344,7 +5335,7 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
GetRequestBodyForWebURLRequest(info.urlRequest),
GetWebURLRequestHeaders(info.urlRequest),
send_referrer ? referrer : Referrer(), info.defaultPolicy,
- info.replacesCurrentHistoryItem, false);
+ info.loadType);
return blink::WebNavigationPolicyIgnore; // Suppress the load here.
}
}
@@ -5378,15 +5369,15 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
is_content_initiated &&
// Must be targeted at the current tab.
info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
- // Must be a JavaScript navigation, which appears as "other".
- info.navigationType == blink::WebNavigationTypeOther;
+ // Must be a JavaScript navigation.
+ info.isClientRedirect;
if (is_fork) {
// Open the URL via the browser, not via WebKit.
OpenURL(url, IsHttpPost(info.urlRequest),
GetRequestBodyForWebURLRequest(info.urlRequest),
GetWebURLRequestHeaders(info.urlRequest), Referrer(),
- info.defaultPolicy, info.replacesCurrentHistoryItem, false);
+ info.defaultPolicy, info.loadType);
return blink::WebNavigationPolicyIgnore;
}
@@ -5409,11 +5400,8 @@ WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
// BeforeUnload event destriyed this frame.
base::WeakPtr<RenderFrameImpl> weak_self = weak_factory_.GetWeakPtr();
- if (!frame_->dispatchBeforeUnloadEvent(info.navigationType ==
- blink::WebNavigationTypeReload) ||
- !weak_self) {
+ if (!frame_->dispatchBeforeUnloadEvent(is_reload) || !weak_self)
return blink::WebNavigationPolicyIgnore;
- }
// |navigation_start| must be recorded immediately after dispatching the
// beforeunload event.
@@ -5747,8 +5735,7 @@ void RenderFrameImpl::OpenURL(
const std::string& extra_headers,
const Referrer& referrer,
WebNavigationPolicy policy,
- bool should_replace_current_entry,
- bool is_history_navigation_in_new_child) {
+ WebFrameLoadType load_type) {
FrameHostMsg_OpenURL_Params params;
params.url = url;
params.uses_post = uses_post;
@@ -5757,16 +5744,10 @@ void RenderFrameImpl::OpenURL(
params.referrer = referrer;
params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy);
- if (IsBrowserInitiated(pending_navigation_params_.get())) {
- // 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.
- WebDataSource* ds = frame_->provisionalDataSource();
- DCHECK(ds);
- params.should_replace_current_entry = ds->replacesCurrentHistoryItem();
- } else {
- params.should_replace_current_entry =
- should_replace_current_entry && render_view_->history_list_length_;
- }
+ params.should_replace_current_entry =
+ load_type == WebFrameLoadType::ReplaceCurrentItem &&
+ (IsBrowserInitiated(pending_navigation_params_.get()) ||
+ render_view_->history_list_length_);
params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
if (GetContentClient()->renderer()->AllowPopup())
params.user_gesture = true;
@@ -5778,7 +5759,7 @@ void RenderFrameImpl::OpenURL(
WebUserGestureIndicator::consumeUserGesture();
}
- if (is_history_navigation_in_new_child)
+ if (load_type == WebFrameLoadType::InitialHistoryLoad)
params.is_history_navigation_in_new_child = true;
Send(new FrameHostMsg_OpenURL(routing_id_, params));
@@ -6174,7 +6155,7 @@ void RenderFrameImpl::BeginNavigation(const NavigationPolicyInfo& info) {
// TODO(clamy): Apply devtools override.
// TODO(clamy): Make sure that navigation requests are not modified somewhere
// else in blink.
- willSendRequest(frame_, info.urlRequest);
+ willSendRequest(frame_, info.urlRequest, info.loadType);
// Update the transition type of the request for client side redirects.
if (!info.urlRequest.getExtraData())
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_frame_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698