Commit 386114b5 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Call WebStateObserver::PageLoaded after loading placeholder URL.

Before this CL PageLoaded was called right from
didFailProvisionalNavigation:, where URL may still represent the
previous page.

Bug: 903497
Change-Id: I712dd120340353f37d2fe739c5b05e843cb11d7a
Reviewed-on: https://chromium-review.googlesource.com/c/1327608Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606855}
parent 9773a841
...@@ -1601,6 +1601,8 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -1601,6 +1601,8 @@ registerLoadRequestForURL:(const GURL&)requestURL
// session history and UI. // session history and UI.
if (!targetURL.is_valid()) { if (!targetURL.is_valid()) {
[self didFinishWithURL:targetURL loadSuccess:NO context:nullptr]; [self didFinishWithURL:targetURL loadSuccess:NO context:nullptr];
_webStateImpl->SetIsLoading(false);
_webStateImpl->OnPageLoaded(targetURL, NO);
return; return;
} }
...@@ -1787,6 +1789,8 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -1787,6 +1789,8 @@ registerLoadRequestForURL:(const GURL&)requestURL
context->SetUrl(item->GetURL()); context->SetUrl(item->GetURL());
} }
[self loadNativeViewWithSuccess:NO navigationContext:context]; [self loadNativeViewWithSuccess:NO navigationContext:context];
_webStateImpl->SetIsLoading(false);
_webStateImpl->OnPageLoaded(currentURL, NO);
} }
// Loads the current URL in a native controller if using the legacy navigation // Loads the current URL in a native controller if using the legacy navigation
...@@ -2176,17 +2180,29 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -2176,17 +2180,29 @@ registerLoadRequestForURL:(const GURL&)requestURL
} }
[self restoreStateFromHistory]; [self restoreStateFromHistory];
// Placeholder and restore session URLs are implementation details so should // Placeholder and restore session URLs are implementation details so should
// not notify WebStateObservers. If |context| is nullptr, don't skip // not notify WebStateObservers. If |context| is nullptr, don't skip
// placeholder URLs because this may be the only opportunity to update // placeholder URLs because this may be the only opportunity to update
// |isLoading| for native view reload. // |isLoading| for native view reload.
if ((context && !IsWKInternalUrl(context->GetUrl())) ||
(!context && !IsRestoreSessionUrl(net::GURLWithNSURL(_webView.URL)))) { if (context && IsWKInternalUrl(context->GetUrl()))
_webStateImpl->SetIsLoading(false); return;
if (!context || !context->IsLoadingErrorPage()) {
_webStateImpl->OnPageLoaded(currentURL, loadSuccess); if (IsRestoreSessionUrl(net::GURLWithNSURL(_webView.URL)))
} return;
if (context && context->IsLoadingErrorPage())
return;
if (!loadSuccess) {
// WebStateObserver callbacks will be called for load failure after
// loading placeholder URL.
return;
} }
_webStateImpl->SetIsLoading(false);
_webStateImpl->OnPageLoaded(currentURL, YES);
} }
- (void)rendererInitiatedGoDelta:(int)delta - (void)rendererInitiatedGoDelta:(int)delta
......
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