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

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2965563002: Fix crash for renderer-initiated same-document navigation. (Closed)
Patch Set: Self review Created 3 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index 61ee232486bd3e1dae3e6285d49e8aae9157208e..3e2f9597d079cd86685fa630f4b6f91d9a6b75d1 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -4788,15 +4788,24 @@ registerLoadRequestForURL:(const GURL&)requestURL
[self setDocumentURL:webViewURL];
[self webPageChanged];
- web::NavigationContextImpl* context =
+ web::NavigationContextImpl* existingContext =
[self contextForPendingNavigationWithURL:webViewURL];
- // Same document navigation does not contain response headers.
- net::HttpResponseHeaders* headers =
- isSameDocumentNavigation ? nullptr
- : _webStateImpl->GetHttpResponseHeaders();
- context->SetResponseHeaders(headers);
- context->SetIsSameDocument(isSameDocumentNavigation);
- _webStateImpl->OnNavigationFinished(context);
+ if (!existingContext && isSameDocumentNavigation) {
+ // This is a renderer-initiated same-document navigation, which needs to
+ // be registered.
+ std::unique_ptr<web::NavigationContextImpl> newContext =
+ [self registerLoadRequestForURL:webViewURL];
+ newContext->SetIsSameDocument(true);
+ _webStateImpl->OnNavigationFinished(newContext.get());
+ } else {
+ // Same document navigation does not contain response headers.
+ net::HttpResponseHeaders* headers =
+ isSameDocumentNavigation ? nullptr
+ : _webStateImpl->GetHttpResponseHeaders();
+ existingContext->SetResponseHeaders(headers);
+ existingContext->SetIsSameDocument(isSameDocumentNavigation);
+ _webStateImpl->OnNavigationFinished(existingContext);
+ }
}
[self updateSSLStatusForCurrentNavigationItem];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698