Commit c46acd7a authored by Eugene But's avatar Eugene But Committed by Commit Bot

Hide SetDisplayingNativeError behind kWebErrorPages flag.

SetDisplayingNativeError should not be used if kWebErrorPages is
enabled.

Bug: 725241
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I8a8be55dc0312fe60e9a4d403ed5e1ad78cbbf32
Reviewed-on: https://chromium-review.googlesource.com/c/1288975Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600896}
parent 70179d64
...@@ -84,6 +84,9 @@ class ErrorRetryStateMachine { ...@@ -84,6 +84,9 @@ class ErrorRetryStateMachine {
// Transitions the state machine to kDisplayingNativeErrorForFailedNavigation. // Transitions the state machine to kDisplayingNativeErrorForFailedNavigation.
void SetDisplayingNativeError(); void SetDisplayingNativeError();
// Transitions the state machine to kDisplayingWebErrorForFailedNavigation.
void SetDisplayingWebError();
// Runs state transitions upon a failed provisional navigation. // Runs state transitions upon a failed provisional navigation.
ErrorRetryCommand DidFailProvisionalNavigation(const GURL& web_view_url, ErrorRetryCommand DidFailProvisionalNavigation(const GURL& web_view_url,
const GURL& error_url); const GURL& error_url);
......
...@@ -45,6 +45,23 @@ void ErrorRetryStateMachine::SetDisplayingNativeError() { ...@@ -45,6 +45,23 @@ void ErrorRetryStateMachine::SetDisplayingNativeError() {
state_ = ErrorRetryState::kDisplayingNativeErrorForFailedNavigation; state_ = ErrorRetryState::kDisplayingNativeErrorForFailedNavigation;
} }
void ErrorRetryStateMachine::SetDisplayingWebError() {
// Web error is displayed in two scenarios:
// (1) Placeholder entry for network load error finished loading in web view.
// This is the common case.
// (2) Retry of a previously failed load failed in SSL error. This can happen
// when the first navigation failed in offline mode. SSL interstitial does
// not normally trigger ErrorRetryStateMachine because the error page is
// not to become part of the navigation history. This leaves the item
// stuck in the transient kRetryFailedNavigationItem state. So for this
// specific case, treat the SSL interstitial as a web error so that
// error retry works as expected on subsequent back/forward navigations.
DCHECK(state_ == ErrorRetryState::kReadyToDisplayErrorForFailedNavigation ||
state_ == ErrorRetryState::kRetryFailedNavigationItem)
<< "Unexpected error retry state: " << static_cast<int>(state_);
state_ = ErrorRetryState::kDisplayingWebErrorForFailedNavigation;
}
ErrorRetryCommand ErrorRetryStateMachine::DidFailProvisionalNavigation( ErrorRetryCommand ErrorRetryStateMachine::DidFailProvisionalNavigation(
const GURL& web_view_url, const GURL& web_view_url,
const GURL& error_url) { const GURL& error_url) {
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
#include "ios/web/navigation/error_retry_state_machine.h" #include "ios/web/navigation/error_retry_state_machine.h"
#include "base/feature_list.h"
#include "ios/web/navigation/wk_navigation_util.h" #include "ios/web/navigation/wk_navigation_util.h"
#include "ios/web/public/features.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h" #import "testing/gtest_mac.h"
#include "testing/platform_test.h" #include "testing/platform_test.h"
...@@ -41,10 +43,16 @@ TEST_F(ErrorRetryStateMachineTest, OfflineThenReload) { ...@@ -41,10 +43,16 @@ TEST_F(ErrorRetryStateMachineTest, OfflineThenReload) {
ASSERT_EQ(ErrorRetryState::kReadyToDisplayErrorForFailedNavigation, ASSERT_EQ(ErrorRetryState::kReadyToDisplayErrorForFailedNavigation,
machine.state()); machine.state());
// Presents error in native view. // Presents error.
machine.SetDisplayingNativeError(); if (base::FeatureList::IsEnabled(web::features::kWebErrorPages)) {
ASSERT_EQ(ErrorRetryState::kDisplayingNativeErrorForFailedNavigation, machine.SetDisplayingWebError();
machine.state()); ASSERT_EQ(ErrorRetryState::kDisplayingWebErrorForFailedNavigation,
machine.state());
} else {
machine.SetDisplayingNativeError();
ASSERT_EQ(ErrorRetryState::kDisplayingNativeErrorForFailedNavigation,
machine.state());
}
// Reload the failed navigation. // Reload the failed navigation.
ASSERT_EQ(ErrorRetryCommand::kRewriteWebViewURL, ASSERT_EQ(ErrorRetryCommand::kRewriteWebViewURL,
......
...@@ -3893,7 +3893,11 @@ registerLoadRequestForURL:(const GURL&)requestURL ...@@ -3893,7 +3893,11 @@ registerLoadRequestForURL:(const GURL&)requestURL
self.navigationManagerImpl, context->GetNavigationItemUniqueID()); self.navigationManagerImpl, context->GetNavigationItemUniqueID());
if (item && item->error_retry_state_machine().state() == if (item && item->error_retry_state_machine().state() ==
web::ErrorRetryState::kRetryFailedNavigationItem) { web::ErrorRetryState::kRetryFailedNavigationItem) {
item->error_retry_state_machine().SetDisplayingNativeError(); if (base::FeatureList::IsEnabled(web::features::kWebErrorPages)) {
item->error_retry_state_machine().SetDisplayingWebError();
} else {
item->error_retry_state_machine().SetDisplayingNativeError();
}
} }
} }
......
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