Commit bcfbdf47 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Fix document URL updates on error page reload

This CL makes sure that the documentURL is correctly updated, or is not
updated when the user is reloading an error page with the new workflow.

Bug: 1139303
Change-Id: I11d5f70eeb58077c0ed40f0b183c3f762f749ab8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514205
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823485}
parent 12085ae4
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#import "ios/web/navigation/crw_web_view_navigation_observer_delegate.h" #import "ios/web/navigation/crw_web_view_navigation_observer_delegate.h"
#import "ios/web/navigation/crw_wk_navigation_handler.h" #import "ios/web/navigation/crw_wk_navigation_handler.h"
#import "ios/web/navigation/crw_wk_navigation_states.h" #import "ios/web/navigation/crw_wk_navigation_states.h"
#import "ios/web/navigation/error_page_helper.h"
#import "ios/web/navigation/navigation_context_impl.h" #import "ios/web/navigation/navigation_context_impl.h"
#import "ios/web/navigation/wk_navigation_util.h" #import "ios/web/navigation/wk_navigation_util.h"
#import "ios/web/public/web_client.h" #import "ios/web/public/web_client.h"
...@@ -247,8 +248,9 @@ using web::wk_navigation_util::IsPlaceholderUrl; ...@@ -247,8 +248,9 @@ using web::wk_navigation_util::IsPlaceholderUrl;
// 4) When a SafeBrowsing warning is displayed after // 4) When a SafeBrowsing warning is displayed after
// decidePolicyForNavigationAction but before a provisional navigation // decidePolicyForNavigationAction but before a provisional navigation
// starts, and the user clicks the "Go Back" link on the warning page. // starts, and the user clicks the "Go Back" link on the warning page.
// 5) When the user is reloading an error page.
// //
// If |isLoading| is NO, then it must be case 2, 3, or 4. If the last // If |isLoading| is NO, then it must be case 2, 3, 4 or 5. If the last
// committed URL (_documentURL) matches the current URL, assume that it is // committed URL (_documentURL) matches the current URL, assume that it is
// case 4 if a SafeBrowsing warning is currently displayed and case 3 // case 4 if a SafeBrowsing warning is currently displayed and case 3
// otherwise. If the URL does not match, assume it is a non-document-changing // otherwise. If the URL does not match, assume it is a non-document-changing
...@@ -266,6 +268,12 @@ using web::wk_navigation_util::IsPlaceholderUrl; ...@@ -266,6 +268,12 @@ using web::wk_navigation_util::IsPlaceholderUrl;
// window.location.href will match the previous URL at this stage, not the web // window.location.href will match the previous URL at this stage, not the web
// view's current URL. // view's current URL.
if (!self.webView.loading) { if (!self.webView.loading) {
if ([ErrorPageHelper isErrorPageFileURL:URL] &&
self.documentURL ==
[ErrorPageHelper failedNavigationURLFromErrorPageFileURL:URL]) {
// Case 5: reloading an error page.
return;
}
if (self.documentURL == URL) { if (self.documentURL == URL) {
if (!web::IsSafeBrowsingWarningDisplayedInWebView(self.webView)) if (!web::IsSafeBrowsingWarningDisplayedInWebView(self.webView))
return; return;
......
...@@ -1002,7 +1002,7 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation( ...@@ -1002,7 +1002,7 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation(
// webView has the file URL. // webView has the file URL.
BOOL isErrorPage = BOOL isErrorPage =
base::FeatureList::IsEnabled(web::features::kUseJSForErrorPage) && base::FeatureList::IsEnabled(web::features::kUseJSForErrorPage) &&
context && context->IsLoadingErrorPage(); [ErrorPageHelper isErrorPageFileURL:webViewURL];
// When loading an error page that is a placeholder (legacy), the webViewURL // When loading an error page that is a placeholder (legacy), the webViewURL
// should be used as it is the actual URL we want to load. // should be used as it is the actual URL we want to load.
......
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