Commit 69ba140d authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

FrameLoader: do not rewrite frame load type to reload

Instead, make the right decision on the callsite.
This makes the implicit dependency between the request's
cache mode and frame load type a bit smaller.

Bug: 789577
Change-Id: Id82797025c7ff7160ec9cbeb37f681468127a34c
Reviewed-on: https://chromium-review.googlesource.com/1150836
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578696}
parent 667f001d
...@@ -2119,8 +2119,10 @@ void WebLocalFrameImpl::CommitDataNavigation( ...@@ -2119,8 +2119,10 @@ void WebLocalFrameImpl::CommitDataNavigation(
// inherit all of the properties of that original request. This way, // inherit all of the properties of that original request. This way,
// reload will re-attempt the original request. It is essential that // reload will re-attempt the original request. It is essential that
// we only do this when there is an unreachableURL since a non-empty // we only do this when there is an unreachableURL since a non-empty
// unreachableURL informs FrameLoader::reload to load unreachableURL // unreachableURL informs FrameLoader::CommitNavigation to load
// instead of the currently loaded URL. // unreachableURL instead of the currently loaded URL.
// TODO(dgozman): this whole logic of rewriting the params is odd,
// and should be moved to the callsites instead.
ResourceRequest request; ResourceRequest request;
HistoryItem* history_item = item; HistoryItem* history_item = item;
DocumentLoader* provisional_document_loader = DocumentLoader* provisional_document_loader =
...@@ -2130,11 +2132,15 @@ void WebLocalFrameImpl::CommitDataNavigation( ...@@ -2130,11 +2132,15 @@ void WebLocalFrameImpl::CommitDataNavigation(
// When replacing a failed back/forward provisional navigation with an error // When replacing a failed back/forward provisional navigation with an error
// page, retain the HistoryItem for the failed provisional navigation // page, retain the HistoryItem for the failed provisional navigation
// and reuse it for the error page navigation. // and reuse it for the error page navigation.
if (provisional_document_loader->LoadType() == WebFrameLoadType previous_load_type =
WebFrameLoadType::kBackForward && provisional_document_loader->LoadType();
if (previous_load_type == WebFrameLoadType::kBackForward &&
provisional_document_loader->GetHistoryItem()) { provisional_document_loader->GetHistoryItem()) {
history_item = provisional_document_loader->GetHistoryItem(); history_item = provisional_document_loader->GetHistoryItem();
web_frame_load_type = WebFrameLoadType::kBackForward; web_frame_load_type = WebFrameLoadType::kBackForward;
} else if (previous_load_type == WebFrameLoadType::kReload ||
previous_load_type == WebFrameLoadType::kReloadBypassingCache) {
web_frame_load_type = previous_load_type;
} }
} }
request.SetURL(base_url); request.SetURL(base_url);
......
...@@ -629,12 +629,10 @@ WebFrameLoadType FrameLoader::DetermineFrameLoadType( ...@@ -629,12 +629,10 @@ WebFrameLoadType FrameLoader::DetermineFrameLoadType(
return WebFrameLoadType::kReplaceCurrentItem; return WebFrameLoadType::kReplaceCurrentItem;
return WebFrameLoadType::kStandard; return WebFrameLoadType::kStandard;
} }
if (request.GetResourceRequest().GetCacheMode() == CHECK_NE(mojom::FetchCacheMode::kValidateCache,
mojom::FetchCacheMode::kValidateCache) request.GetResourceRequest().GetCacheMode());
return WebFrameLoadType::kReload; CHECK_NE(mojom::FetchCacheMode::kBypassCache,
if (request.GetResourceRequest().GetCacheMode() == request.GetResourceRequest().GetCacheMode());
mojom::FetchCacheMode::kBypassCache)
return WebFrameLoadType::kReloadBypassingCache;
// From the HTML5 spec for location.assign(): // From the HTML5 spec for location.assign():
// "If the browsing context's session history contains only one Document, // "If the browsing context's session history contains only one Document,
// and that was the about:blank Document created when the browsing context // and that was the about:blank Document created when the browsing context
......
...@@ -188,16 +188,18 @@ class ScheduledRedirect final : public ScheduledURLNavigation { ...@@ -188,16 +188,18 @@ class ScheduledRedirect final : public ScheduledURLNavigation {
std::unique_ptr<UserGestureIndicator> gesture_indicator = std::unique_ptr<UserGestureIndicator> gesture_indicator =
CreateUserGestureIndicator(); CreateUserGestureIndicator();
FrameLoadRequest request(OriginDocument(), ResourceRequest(Url()), "_self"); FrameLoadRequest request(OriginDocument(), ResourceRequest(Url()), "_self");
WebFrameLoadType load_type = WebFrameLoadType::kStandard;
request.SetReplacesCurrentItem(ReplacesCurrentItem()); request.SetReplacesCurrentItem(ReplacesCurrentItem());
if (EqualIgnoringFragmentIdentifier(frame->GetDocument()->Url(), if (EqualIgnoringFragmentIdentifier(frame->GetDocument()->Url(),
request.GetResourceRequest().Url())) { request.GetResourceRequest().Url())) {
request.GetResourceRequest().SetCacheMode( request.GetResourceRequest().SetCacheMode(
mojom::FetchCacheMode::kValidateCache); mojom::FetchCacheMode::kValidateCache);
load_type = WebFrameLoadType::kReload;
} }
request.SetClientRedirect(ClientRedirectPolicy::kClientRedirect); request.SetClientRedirect(ClientRedirectPolicy::kClientRedirect);
MaybeLogScheduledNavigationClobber( MaybeLogScheduledNavigationClobber(
ScheduledNavigationType::kScheduledRedirect, frame); ScheduledNavigationType::kScheduledRedirect, frame);
frame->Loader().StartNavigation(request); frame->Loader().StartNavigation(request, load_type);
} }
private: private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment