Commit 5420f021 authored by Yunke Zhou's avatar Yunke Zhou Committed by Chromium LUCI CQ

Oobe: move Back logic handling in GaiaScreen to WizardController

Bug: 1163474
Change-Id: I931fa71f052b40e11d3f0316717344a0895b36c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2612946Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Yunke Zhou <yunkez@google.com>
Cr-Commit-Position: refs/heads/master@{#842412}
parent 2a7e78c7
......@@ -25,8 +25,8 @@ std::string GaiaScreen::GetResultString(Result result) {
switch (result) {
case Result::BACK:
return "Back";
case Result::CLOSE_DIALOG:
return "CloseDialog";
case Result::CANCEL:
return "Cancel";
case Result::ENTERPRISE_ENROLL:
return "EnterpriseEnroll";
case Result::START_CONSUMER_KIOSK:
......@@ -83,21 +83,15 @@ void GaiaScreen::HideImpl() {
}
void GaiaScreen::OnUserAction(const std::string& action_id) {
if (action_id == kUserActionBack || action_id == kUserActionCancel) {
// `kUserActionBack` will go back to user creation screen if possible.
// `kUserActionCancel` will stay at the gaia screen and reload the screen.
if (action_id == kUserActionBack && context()->is_user_creation_enabled) {
exit_callback_.Run(Result::BACK);
} else {
HandleCancel();
}
return;
}
if (action_id == kUserActionStartEnrollment) {
if (action_id == kUserActionBack) {
exit_callback_.Run(Result::BACK);
} else if (action_id == kUserActionCancel) {
exit_callback_.Run(Result::CANCEL);
} else if (action_id == kUserActionStartEnrollment) {
exit_callback_.Run(Result::ENTERPRISE_ENROLL);
return;
} else {
BaseScreen::OnUserAction(action_id);
}
BaseScreen::OnUserAction(action_id);
}
bool GaiaScreen::HandleAccelerator(ash::LoginAcceleratorAction action) {
......@@ -112,15 +106,4 @@ bool GaiaScreen::HandleAccelerator(ash::LoginAcceleratorAction action) {
return false;
}
void GaiaScreen::HandleCancel() {
// Close the user pod if it exists and gaia is the first screen, or reload
// the page.
if (LoginDisplayHost::default_host()->HasUserPods() &&
!context()->is_user_creation_enabled) {
exit_callback_.Run(Result::CLOSE_DIALOG);
} else {
LoadOnline(EmptyAccountId());
}
}
} // namespace chromeos
......@@ -24,7 +24,7 @@ class GaiaScreen : public BaseScreen {
enum class Result {
BACK,
CLOSE_DIALOG,
CANCEL,
ENTERPRISE_ENROLL,
START_CONSUMER_KIOSK,
};
......@@ -51,8 +51,6 @@ class GaiaScreen : public BaseScreen {
void OnUserAction(const std::string& action_id) override;
bool HandleAccelerator(ash::LoginAcceleratorAction action) override;
void HandleCancel();
GaiaView* view_ = nullptr;
ScreenExitCallback exit_callback_;
......
......@@ -957,10 +957,22 @@ void WizardController::OnGaiaScreenExit(GaiaScreen::Result result) {
OnScreenExit(GaiaView::kScreenId, GaiaScreen::GetResultString(result));
switch (result) {
case GaiaScreen::Result::BACK:
AdvanceToScreen(UserCreationView::kScreenId);
break;
case GaiaScreen::Result::CLOSE_DIALOG:
LoginDisplayHost::default_host()->HideOobeDialog();
case GaiaScreen::Result::CANCEL:
if (result == GaiaScreen::Result::BACK &&
wizard_context_->is_user_creation_enabled) {
// `Result::BACK` is only triggered when pressing back button. It goes
// back to UserCreationScreen if screen is enabled; otherwise, it
// behaves the same as `Result::CANCEL` which is triggered by pressing
// ESC key.
AdvanceToScreen(UserCreationView::kScreenId);
break;
}
if (LoginDisplayHost::default_host()->HasUserPods() &&
!wizard_context_->is_user_creation_enabled) {
LoginDisplayHost::default_host()->HideOobeDialog();
} else {
GetScreen<GaiaScreen>()->LoadOnline(EmptyAccountId());
}
break;
case GaiaScreen::Result::ENTERPRISE_ENROLL:
ShowEnrollmentScreenIfEligible();
......
......@@ -12016,7 +12016,12 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
<suffix name="Family-link-notice.Done" label=""/>
<suffix name="Fingerprint-setup.Next" label=""/>
<suffix name="Gaia-signin.Back" label=""/>
<suffix name="Gaia-signin.CloseDialog" label=""/>
<suffix name="Gaia-signin.Cancel" label=""/>
<suffix name="Gaia-signin.CloseDialog" label="">
<obsolete>
Removed in M89.
</obsolete>
</suffix>
<suffix name="Gaia-signin.EnterpriseEnroll" label=""/>
<suffix name="Gaia-signin.StartConsumerKiosk" label=""/>
<suffix name="Gesture-navigation.Next" label=""/>
......
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