Commit 4025a873 authored by Olivier Robin's avatar Olivier Robin Committed by Commit Bot

Report navigation success on offline page loading.

On the current implementation, on a navigation error, the
error_retry_state_machine expect a second navigation after any error to
load the error page.
When displaying an offline page, this second navigation displayes a
native content and DidFinishNavigation is never called, so the
navigation is not cleaned.
On reload, this causes a DCHECK and a navigation failure.

This CL report a success on native navigation.

Note:
While this fix gives the expected result, there is still a bug in the
error_retry_state_maching as the state will be put in
kDisplayingWebErrorForFailedNavigation instead of success state.
Fixing this behavior is not in the scope of this CL and can be fixed in
the future by ErrorRetryStateMachine owners.

Bug: 904784
Change-Id: Ic4efe212f933e8631f1b97dbf1a5633dd8a8cc54
Reviewed-on: https://chromium-review.googlesource.com/c/1335932
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608412}
parent 1c886c53
...@@ -80,6 +80,9 @@ class ErrorRetryStateMachine { ...@@ -80,6 +80,9 @@ class ErrorRetryStateMachine {
// Returns the current error retry state. // Returns the current error retry state.
ErrorRetryState state() const; ErrorRetryState state() const;
// Transitions the state machine to kNoNavigationError.
void SetNoNavigationError();
// Transitions the state machine to kDisplayingWebErrorForFailedNavigation. // Transitions the state machine to kDisplayingWebErrorForFailedNavigation.
void SetDisplayingWebError(); void SetDisplayingWebError();
......
...@@ -28,6 +28,10 @@ ErrorRetryState ErrorRetryStateMachine::state() const { ...@@ -28,6 +28,10 @@ ErrorRetryState ErrorRetryStateMachine::state() const {
return state_; return state_;
} }
void ErrorRetryStateMachine::SetNoNavigationError() {
state_ = ErrorRetryState::kNoNavigationError;
}
void ErrorRetryStateMachine::SetDisplayingWebError() { void ErrorRetryStateMachine::SetDisplayingWebError() {
// Web error is displayed in two scenarios: // Web error is displayed in two scenarios:
// (1) Placeholder entry for network load error finished loading in web view. // (1) Placeholder entry for network load error finished loading in web view.
......
...@@ -1730,6 +1730,14 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -1730,6 +1730,14 @@ registerLoadRequestForURL:(const GURL&)requestURL
// No DidFinishNavigation callback for displaying error page. // No DidFinishNavigation callback for displaying error page.
context->SetHasCommitted(true); context->SetHasCommitted(true);
_webStateImpl->OnNavigationFinished(context); _webStateImpl->OnNavigationFinished(context);
web::NavigationItemImpl* item =
context ? web::GetItemWithUniqueID(self.navigationManagerImpl,
context->GetNavigationItemUniqueID())
: nullptr;
if (item && web::GetWebClient()->IsAppSpecificURL(item->GetURL())) {
// Reports the successful navigation to the ErrorRetryStateMachine.
item->error_retry_state_machine().SetNoNavigationError();
}
} }
NSString* title = [self.nativeController title]; NSString* title = [self.nativeController title];
......
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