Commit 71f5682e authored by mrefaat's avatar mrefaat Committed by Commit Bot

Discard pending Item when web state should allow request return False.

This fixes a problem when the StoreKit is dismissed, the URL stays on the omni box.
Where it should be reverted to the last item.

Bug: 842725
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I2c645289209d0ae03b09d60e9b90d42565bca057
Reviewed-on: https://chromium-review.googlesource.com/1060346Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Mohammad Refaat <mrefaat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559333}
parent cefd5072
......@@ -577,6 +577,10 @@ NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) {
// If YES, the page should be closed if it successfully redirects to a native
// application, for example if a new tab redirects to the App Store.
- (BOOL)shouldClosePageOnNativeApplicationLoad;
// Discards non committed items, only if the last committed URL was not loaded
// in native view. But if it was a native view, no discard will happen to avoid
// an ugly animation where the web view is inserted and quickly removed.
- (void)discardNonCommittedItemsIfLastCommittedWasNotNativeView;
// Updates URL for navigation context and navigation item.
- (void)didReceiveRedirectForNavigation:(web::NavigationContextImpl*)context
withURL:(const GURL&)URL;
......@@ -2195,6 +2199,14 @@ registerLoadRequestForURL:(const GURL&)requestURL
[self requirePageReconstruction];
}
- (void)discardNonCommittedItemsIfLastCommittedWasNotNativeView {
GURL lastCommittedURL = self.webState->GetLastCommittedURL();
BOOL previousItemWasLoadedInNativeView =
[self shouldLoadURLInNativeView:lastCommittedURL];
if (!previousItemWasLoadedInNativeView)
self.navigationManagerImpl->DiscardNonCommittedItems();
}
#pragma mark -
#pragma mark CRWWebControllerContainerViewDelegate
......@@ -4260,6 +4272,9 @@ registerLoadRequestForURL:(const GURL&)requestURL
action.request, transition, [self isMainFrameNavigationAction:action]);
if (!allowLoad && action.targetFrame.mainFrame) {
[_pendingNavigationInfo setCancelled:YES];
// Discard the pending item to ensure that the current URL is not
// different from what is displayed on the view.
[self discardNonCommittedItemsIfLastCommittedWasNotNativeView];
}
if (allowLoad)
......@@ -4344,14 +4359,8 @@ registerLoadRequestForURL:(const GURL&)requestURL
if (isPassKit ||
base::FeatureList::IsEnabled(web::features::kNewFileDownload)) {
// Discard the pending item to ensure that the current URL is not
// different from what is displayed on the view. URL loaded in a native
// view should be excluded to avoid an ugly animation where the web view
// is inserted and quickly removed.
GURL lastCommittedURL = self.webState->GetLastCommittedURL();
BOOL previousItemWasLoadedInNativeView =
[self shouldLoadURLInNativeView:lastCommittedURL];
if (!previousItemWasLoadedInNativeView)
self.navigationManagerImpl->DiscardNonCommittedItems();
// different from what is displayed on the view.
[self discardNonCommittedItemsIfLastCommittedWasNotNativeView];
}
_webStateImpl->SetIsLoading(false);
}
......
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