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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 2309083002: PlzNavigate: Fix history navigation for error pages. (Closed)
Patch Set: . Created 4 years, 3 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
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 95165ffa90454bbfe6eec5fffa8ab0de4559597b..e9deaa0050750af09698f199f7bfaefd18c5ca50 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -2275,15 +2275,22 @@ bool RenderFrameImpl::ScheduleFileChooser(
void RenderFrameImpl::LoadNavigationErrorPage(
const WebURLRequest& failed_request,
const WebURLError& error,
- bool replace) {
+ bool replace,
+ HistoryEntry* entry) {
std::string error_html;
GetContentClient()->renderer()->GetNavigationErrorStrings(
this, failed_request, error, &error_html, nullptr);
- frame_->loadHTMLString(error_html,
- GURL(kUnreachableWebDataURL),
- error.unreachableURL,
- replace);
+ blink::WebFrameLoadType frame_load_type =
+ entry ? blink::WebFrameLoadType::BackForward
+ : blink::WebFrameLoadType::Standard;
+ const blink::WebHistoryItem& history_item =
+ entry ? entry->root() : blink::WebHistoryItem();
+
+ frame_->loadData(error_html, WebString::fromUTF8("text/html"),
+ WebString::fromUTF8("UTF-8"), GURL(kUnreachableWebDataURL),
+ error.unreachableURL, replace, frame_load_type, history_item,
+ blink::WebHistoryDifferentDocumentLoad, false);
}
void RenderFrameImpl::DidMeaningfulLayout(
@@ -3298,7 +3305,7 @@ void RenderFrameImpl::didFailProvisionalLoad(
}
// Load an error page.
- LoadNavigationErrorPage(failed_request, error, replace);
+ LoadNavigationErrorPage(failed_request, error, replace, nullptr);
}
void RenderFrameImpl::didCommitProvisionalLoad(
@@ -3649,7 +3656,8 @@ void RenderFrameImpl::runScriptsAtDocumentReady(blink::WebLocalFrame* frame,
error.domain = WebString::fromUTF8(error_domain);
error.reason = http_status_code;
// This call may run scripts, e.g. via the beforeunload event.
- LoadNavigationErrorPage(frame->dataSource()->request(), error, true);
+ LoadNavigationErrorPage(frame->dataSource()->request(), error, true,
+ nullptr);
}
// Do not use |this| or |frame| here without checking |weak_self|.
}
@@ -4896,7 +4904,10 @@ void RenderFrameImpl::OnFailedNavigation(
// separately.
bool replace = is_reload || common_params.url == GetLoadingUrl() ||
common_params.should_replace_current_entry;
- LoadNavigationErrorPage(failed_request, error, replace);
+ std::unique_ptr<HistoryEntry> history_entry;
+ if (request_params.page_state.IsValid())
+ history_entry = PageStateToHistoryEntry(request_params.page_state);
+ LoadNavigationErrorPage(failed_request, error, replace, history_entry.get());
}
WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | testing/buildbot/filters/browser-side-navigation.linux.browser_tests.filter » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698