[hands-off] Remove hands-off support from EnrollmentScreen.

This a is part of hands-off and Rialto board deprecation.

Bug: b:256522545
Test: none
Change-Id: I02abb07538ef7d4d5999da1a6f89ef2e590351d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5098588
Reviewed-by: Roland Bock <rbock@google.com>
Commit-Queue: Artem Sumaneev <asumaneev@google.com>
Cr-Commit-Position: refs/heads/main@{#1243350}
diff --git a/chrome/browser/ash/login/enrollment/enrollment_screen.cc b/chrome/browser/ash/login/enrollment/enrollment_screen.cc
index 01ba4185..eb3bfa7 100644
--- a/chrome/browser/ash/login/enrollment/enrollment_screen.cc
+++ b/chrome/browser/ash/login/enrollment/enrollment_screen.cc
@@ -842,11 +842,14 @@
 }
 
 bool EnrollmentScreen::ShouldAutoRetryOnError() const {
-  return WizardController::IsZeroTouchHandsOffOobeFlow();
+  // Currently there is no use-case for the retry logic. But error
+  // classification may bring one. If not, the whole retry stack can be removed.
+  // TODO(b/314130124): Remove if retry logic is not needed.
+  return false;
 }
 
 bool EnrollmentScreen::AutoCloseEnrollmentConfirmationOnSuccess() const {
-  return WizardController::IsZeroTouchHandsOffOobeFlow() || is_rollback_flow_;
+  return is_rollback_flow_;
 }
 
 bool EnrollmentScreen::IsEnrollmentScreenHiddenByError() {
diff --git a/chrome/browser/ash/login/enrollment/enrollment_screen.h b/chrome/browser/ash/login/enrollment/enrollment_screen.h
index 46f9bd9a..f8ef460f 100644
--- a/chrome/browser/ash/login/enrollment/enrollment_screen.h
+++ b/chrome/browser/ash/login/enrollment/enrollment_screen.h
@@ -211,6 +211,7 @@
   // Similar to OnRetry(), but responds to a timer instead of the user
   // pressing the Retry button. Does not retry if `ShouldAutoRetryOnError()`
   // returns false.
+  // TODO(b/314130124): Remove if retry logic is not needed.
   void MaybeAutomaticRetry();
 
   // Processes a request to retry enrollment.
@@ -227,12 +228,11 @@
   // to reboot the device.
   void CheckInstallAttributesState();
 
-  // Returns true if enrollment should be automatically retried on error. E.g.
-  // for Zero-Touch Hands Off flow.
+  // Returns true if enrollment should be automatically retried on error.
+  // TODO(b/314130124): Remove if retry logic is not needed.
   bool ShouldAutoRetryOnError() const;
 
-  // Returns true if success screen should be skipped. E.g. for Zero-Touch Hands
-  // Off flow or rollback.
+  // Returns true if success screen should be skipped.
   bool AutoCloseEnrollmentConfirmationOnSuccess() const;
 
   // Returns true if current visible screen is the error screen over
diff --git a/chrome/browser/ash/login/enrollment/enrollment_screen_browsertest.cc b/chrome/browser/ash/login/enrollment/enrollment_screen_browsertest.cc
index 2ab2f00..69d9ac7 100644
--- a/chrome/browser/ash/login/enrollment/enrollment_screen_browsertest.cc
+++ b/chrome/browser/ash/login/enrollment/enrollment_screen_browsertest.cc
@@ -775,35 +775,6 @@
         {policy::EnrollmentConfig::MODE_ATTESTATION,
          policy::EnrollmentConfig::AUTH_MECHANISM_BEST_AVAILABLE}}));
 
-class EnrollmentScreenHandsOffTest : public EnrollmentScreenTest {
- public:
-  EnrollmentScreenHandsOffTest() = default;
-  ~EnrollmentScreenHandsOffTest() override = default;
-
-  EnrollmentScreenHandsOffTest(const EnrollmentScreenHandsOffTest&) = delete;
-  EnrollmentScreenHandsOffTest& operator=(const EnrollmentScreenHandsOffTest&) =
-      delete;
-
-  // EnrollmentScreenTest:
-  void SetUpCommandLine(base::CommandLine* command_line) override {
-    EnrollmentScreenTest::SetUpCommandLine(command_line);
-    command_line->AppendSwitchASCII(
-        switches::kEnterpriseEnableZeroTouchEnrollment, "hands-off");
-  }
-};
-
-// TODO(crbug.com/1344492): Consistent failures, unable to cleanly revert
-// culprit CL.
-IN_PROC_BROWSER_TEST_F(EnrollmentScreenHandsOffTest,
-                       DISABLED_SkipEnrollmentCompleteScreen) {
-  enrollment_ui_.SetExitHandler();
-  enrollment_screen()->OnDeviceAttributeUpdatePermission(false /* granted */);
-  EnrollmentScreen::Result screen_result = enrollment_ui_.WaitForScreenExit();
-  EXPECT_EQ(EnrollmentScreen::Result::COMPLETED, screen_result);
-
-  EXPECT_TRUE(StartupUtils::IsDeviceRegistered());
-}
-
 // Class to test TPM pre-enrollment check that happens only with
 // --tpm-is-dynamic switch enabled. Test parameter represents take TPM
 // ownership reply possible statuses.
diff --git a/chrome/browser/ash/login/enrollment/enrollment_screen_unittest.cc b/chrome/browser/ash/login/enrollment/enrollment_screen_unittest.cc
index 437bbac..0a45a3a 100644
--- a/chrome/browser/ash/login/enrollment/enrollment_screen_unittest.cc
+++ b/chrome/browser/ash/login/enrollment/enrollment_screen_unittest.cc
@@ -6,11 +6,8 @@
 
 #include <optional>
 
-#include "ash/constants/ash_switches.h"
-#include "base/command_line.h"
 #include "base/functional/bind.h"
 #include "base/functional/callback.h"
-#include "base/task/single_thread_task_runner.h"
 #include "base/test/task_environment.h"
 #include "base/time/time.h"
 #include "chrome/browser/ash/login/configuration_keys.h"
@@ -34,30 +31,6 @@
 
 namespace ash {
 
-namespace {
-
-policy::EnrollmentConfig GetZeroTouchEnrollmentConfig() {
-  policy::EnrollmentConfig config;
-  config.mode = policy::EnrollmentConfig::MODE_ATTESTATION_LOCAL_FORCED;
-  config.auth_mechanism = policy::EnrollmentConfig::AUTH_MECHANISM_ATTESTATION;
-  return config;
-}
-
-policy::EnrollmentConfig GetZeroTouchEnrollmentConfigForFallback() {
-  policy::EnrollmentConfig config;
-  config.mode = policy::EnrollmentConfig::MODE_ATTESTATION;
-  config.auth_mechanism =
-      policy::EnrollmentConfig::AUTH_MECHANISM_BEST_AVAILABLE;
-  return config;
-}
-
-void ConfigureZeroTouchEnrollment() {
-  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kEnterpriseEnableZeroTouchEnrollment, "hands-off");
-}
-
-}  // namespace
-
 using ::testing::_;
 using ::testing::AnyNumber;
 using ::testing::Invoke;
@@ -91,8 +64,6 @@
     task_environment_.FastForwardBy(time);
   }
 
-  MockEnrollmentScreenView* GetMockScreenView() { return &mock_view_; }
-
   // testing::Test:
   void SetUp() override {
     RegisterLocalState(pref_service_.registry());
@@ -195,14 +166,6 @@
     enrollment_screen_->Show(&wizard_context_);
   }
 
-  void ScheduleUserRetry(base::TimeDelta delay) {
-    base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
-        FROM_HERE,
-        base::BindOnce(&EnrollmentScreen::OnRetry,
-                       enrollment_screen_->weak_ptr_factory_.GetWeakPtr()),
-        delay);
-  }
-
   int GetEnrollmentScreenRetries() { return enrollment_screen_->num_retries_; }
 
   void TestEnrollmentFlowShouldComplete(
@@ -224,45 +187,6 @@
     EXPECT_EQ(EnrollmentScreen::Result::COMPLETED, last_screen_result_.value());
   }
 
-  void TestEnrollmentFlowRetriesOnFailure(
-      const policy::EnrollmentConfig& config) {
-    // Define behavior of MockEnrollmentLauncher to always fail enrollment.
-    SetupMockEnrollmentLauncher(AttestationEnrollmentStatus::DMSERVER_ERROR);
-
-    ScopedEnrollmentLauncherFactoryOverrideForTesting
-        enrollment_launcher_factory_override(base::BindRepeating(
-            FakeEnrollmentLauncher::Create, &mock_enrollment_launcher_));
-
-    SetUpEnrollmentScreen(config);
-
-    ShowEnrollmentScreen(/*suppress_jitter=*/true);
-
-    // Fast forward time by 1 minute.
-    FastForwardTime(base::Minutes(1));
-
-    // Check that we have retried 4 times.
-    EXPECT_EQ(GetEnrollmentScreenRetries(), 4);
-  }
-
-  void TestEnrollmentFlowShouldUseFallback(
-      const policy::EnrollmentConfig& config) {
-    // Define behavior of MockEnrollmentLauncher to fail attestation-based
-    // enrollment.
-    SetupMockEnrollmentLauncher(
-        AttestationEnrollmentStatus::DEVICE_NOT_SETUP_FOR_ZERO_TOUCH);
-    ScopedEnrollmentLauncherFactoryOverrideForTesting
-        enrollment_launcher_factory_override(base::BindRepeating(
-            FakeEnrollmentLauncher::Create, &mock_enrollment_launcher_));
-
-    SetUpEnrollmentScreen(config);
-
-    // Once we fallback we show a sign in screen for manual enrollment.
-    EXPECT_CALL(*GetMockScreenView(), Show()).Times(2);
-
-    // Start enrollment.
-    ShowEnrollmentScreen();
-  }
-
  private:
   void HandleScreenExit(EnrollmentScreen::Result screen_result) {
     EXPECT_FALSE(last_screen_result_.has_value());
@@ -337,119 +261,4 @@
   EXPECT_EQ(GetEnrollmentScreenRetries(), 0);
 }
 
-TEST_F(EnrollmentScreenUnitTest, ZeroTouchFlowShouldFinishEnrollmentScreen) {
-  ConfigureZeroTouchEnrollment();
-
-  TestEnrollmentFlowShouldComplete(GetZeroTouchEnrollmentConfig());
-}
-
-TEST_F(EnrollmentScreenUnitTest,
-       ZeroTouchFlowShouldFallbackToManualEnrollment) {
-  ConfigureZeroTouchEnrollment();
-
-  TestEnrollmentFlowShouldUseFallback(
-      GetZeroTouchEnrollmentConfigForFallback());
-}
-
-TEST_F(EnrollmentScreenUnitTest, ZeroTouchFlowShouldRetryEnrollment) {
-  ConfigureZeroTouchEnrollment();
-
-  TestEnrollmentFlowRetriesOnFailure(GetZeroTouchEnrollmentConfig());
-}
-
-TEST_F(EnrollmentScreenUnitTest, ZeroTouchFlowShouldNotRetryOnTopOfUser) {
-  ConfigureZeroTouchEnrollment();
-
-  // Define behavior of MockEnrollmentLauncher to always fail enrollment.
-  SetupMockEnrollmentLauncher(AttestationEnrollmentStatus::DMSERVER_ERROR);
-  ScopedEnrollmentLauncherFactoryOverrideForTesting
-      enrollment_launcher_factory_override(base::BindRepeating(
-          FakeEnrollmentLauncher::Create, &mock_enrollment_launcher_));
-
-  SetUpEnrollmentScreen(GetZeroTouchEnrollmentConfig());
-
-  // Start zero-touch enrollment.
-  ShowEnrollmentScreen(/*suppress_jitter=*/true);
-
-  // Schedule user retry button click after 30 sec.
-  ScheduleUserRetry(base::Seconds(30));
-
-  // Fast forward time by 1 minute.
-  FastForwardTime(base::Minutes(1));
-
-  // Check that the number of retries is still 4.
-  EXPECT_EQ(GetEnrollmentScreenRetries(), 4);
-}
-
-TEST_F(EnrollmentScreenUnitTest, ZeroTouchFlowShouldNotRetryAfterSuccess) {
-  ConfigureZeroTouchEnrollment();
-
-  // Define behavior of MockEnrollmentLauncher to successfully enroll.
-  SetupMockEnrollmentLauncher(AttestationEnrollmentStatus::SUCCESS);
-  ScopedEnrollmentLauncherFactoryOverrideForTesting
-      enrollment_launcher_factory_override(base::BindRepeating(
-          FakeEnrollmentLauncher::Create, &mock_enrollment_launcher_));
-
-  SetUpEnrollmentScreen(GetZeroTouchEnrollmentConfig());
-
-  // Start zero-touch enrollment.
-  ShowEnrollmentScreen();
-
-  // Fast forward time by 1 minute.
-  FastForwardTime(base::Minutes(1));
-
-  // Check that we do not retry.
-  EXPECT_EQ(GetEnrollmentScreenRetries(), 0);
-}
-
-class AutomaticEnrollmentScreenUnitTest
-    : public EnrollmentScreenUnitTest,
-      public ::testing::WithParamInterface<policy::EnrollmentConfig::Mode> {
- public:
-  AutomaticEnrollmentScreenUnitTest() = default;
-
-  AutomaticEnrollmentScreenUnitTest(const AutomaticEnrollmentScreenUnitTest&) =
-      delete;
-  AutomaticEnrollmentScreenUnitTest& operator=(
-      const AutomaticEnrollmentScreenUnitTest&) = delete;
-
-  void SetUp() override {
-    EnrollmentScreenUnitTest::SetUp();
-
-    // Configure the browser to use Hands-Off Enrollment. This is required here
-    // to test for proper completion of the enrollment process.
-    ConfigureZeroTouchEnrollment();
-  }
-
-  policy::EnrollmentConfig GetEnrollmentConfig() {
-    policy::EnrollmentConfig config;
-    config.mode = GetParam();
-    config.auth_mechanism =
-        policy::EnrollmentConfig::AUTH_MECHANISM_BEST_AVAILABLE;
-    return config;
-  }
-};
-
-TEST_P(AutomaticEnrollmentScreenUnitTest, ShowErrorPanel) {
-  // We use Zero-Touch's test for retries as a way to know that there was
-  // an error pane with a Retry button displayed to the user when we encounter
-  // a DMServer error that is not that the device isn't setup for Auto RE.
-  TestEnrollmentFlowRetriesOnFailure(GetEnrollmentConfig());
-}
-
-TEST_P(AutomaticEnrollmentScreenUnitTest, FinishEnrollmentFlow) {
-  TestEnrollmentFlowShouldComplete(GetEnrollmentConfig());
-}
-
-TEST_P(AutomaticEnrollmentScreenUnitTest, Fallback) {
-  TestEnrollmentFlowShouldUseFallback(GetEnrollmentConfig());
-}
-
-INSTANTIATE_TEST_SUITE_P(
-    P,
-    AutomaticEnrollmentScreenUnitTest,
-    ::testing::Values(
-        policy::EnrollmentConfig::MODE_ATTESTATION_INITIAL_SERVER_FORCED,
-        policy::EnrollmentConfig::MODE_ATTESTATION_SERVER_FORCED));
-
 }  // namespace ash