Commit c53a255b authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

cros: Check if screens are hidden on user actions

This should prevent DCHECKs in wizard_controller on multiple button
presses.

Fixed: 1069240
Change-Id: Iffc71c7bf0f602ce4d3bf84ff5176afc99b49be2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144150Reviewed-by: default avatarRoman Aleksandrov <raleksandrov@google.com>
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759200}
parent a775f4ae
......@@ -18,7 +18,9 @@
namespace {
constexpr char kUserActionAccepted[] = "accepted";
constexpr char kUserActionBack[] = "go-back";
constexpr char kUserActionSkip[] = "skip";
} // namespace
......@@ -83,18 +85,25 @@ void ArcTermsOfServiceScreen::HideImpl() {
}
void ArcTermsOfServiceScreen::OnUserAction(const std::string& action_id) {
if (action_id == kUserActionBack) {
if (action_id == kUserActionAccepted) {
exit_callback_.Run(Result::ACCEPTED);
} else if (action_id == kUserActionBack) {
exit_callback_.Run(Result::BACK);
} else if (action_id == kUserActionSkip) {
exit_callback_.Run(Result::SKIPPED);
} else {
BaseScreen::OnUserAction(action_id);
}
}
void ArcTermsOfServiceScreen::OnSkip() {
exit_callback_.Run(Result::SKIPPED);
// This would check if the screen is already hidden.
HandleUserAction(kUserActionSkip);
}
void ArcTermsOfServiceScreen::OnAccept(bool review_arc_settings) {
if (is_hidden())
return;
base::UmaHistogramBoolean("OOBE.ArcTermsOfServiceScreen.ReviewFollowingSetup",
review_arc_settings);
if (review_arc_settings) {
......@@ -103,7 +112,7 @@ void ArcTermsOfServiceScreen::OnAccept(bool review_arc_settings) {
profile->GetPrefs()->SetBoolean(prefs::kShowArcSettingsOnSessionStart,
true);
}
exit_callback_.Run(Result::ACCEPTED);
HandleUserAction(kUserActionAccepted);
}
void ArcTermsOfServiceScreen::OnViewDestroyed(
......
......@@ -27,6 +27,8 @@ EnableDebuggingScreen::~EnableDebuggingScreen() {
}
void EnableDebuggingScreen::OnExit(bool success) {
if (is_hidden())
return;
exit_callback_.Run();
}
......
......@@ -39,6 +39,8 @@ KioskAutolaunchScreen::~KioskAutolaunchScreen() {
}
void KioskAutolaunchScreen::OnExit(bool confirmed) {
if (is_hidden())
return;
exit_callback_.Run(confirmed ? Result::COMPLETED : Result::CANCELED);
}
......
......@@ -43,11 +43,16 @@ RecommendAppsScreen::~RecommendAppsScreen() {
view_->Bind(nullptr);
}
// TODO(https://crbug.com/1070917) Migrate to OnUserAction.
void RecommendAppsScreen::OnSkip() {
if (is_hidden())
return;
exit_callback_.Run(Result::SKIPPED);
}
void RecommendAppsScreen::OnInstall() {
if (is_hidden())
return;
exit_callback_.Run(Result::SELECTED);
}
......@@ -88,6 +93,8 @@ void RecommendAppsScreen::OnLoadSuccess(const base::Value& app_list) {
}
void RecommendAppsScreen::OnLoadError() {
if (is_hidden())
return;
exit_callback_.Run(Result::LOAD_ERROR);
}
......
......@@ -116,6 +116,8 @@ void SyncConsentScreen::OnStateChanged(syncer::SyncService* sync) {
void SyncConsentScreen::OnContinueAndReview(
const std::vector<int>& consent_description,
const int consent_confirmation) {
if (is_hidden())
return;
RecordUmaReviewFollowingSetup(true);
RecordConsent(CONSENT_GIVEN, consent_description, consent_confirmation);
profile_->GetPrefs()->SetBoolean(prefs::kShowSyncSettingsOnSessionStart,
......@@ -126,6 +128,8 @@ void SyncConsentScreen::OnContinueAndReview(
void SyncConsentScreen::OnContinueWithDefaults(
const std::vector<int>& consent_description,
const int consent_confirmation) {
if (is_hidden())
return;
RecordUmaReviewFollowingSetup(false);
RecordConsent(CONSENT_GIVEN, consent_description, consent_confirmation);
exit_callback_.Run();
......@@ -136,6 +140,8 @@ void SyncConsentScreen::OnAcceptAndContinue(
int consent_confirmation,
bool enable_os_sync) {
DCHECK(chromeos::features::IsSplitSyncConsentEnabled());
if (is_hidden())
return;
// The user only consented to the feature if they left the toggle on.
RecordConsent(enable_os_sync ? CONSENT_GIVEN : CONSENT_NOT_GIVEN,
consent_description, consent_confirmation);
......
......@@ -26,6 +26,8 @@ WrongHWIDScreen::~WrongHWIDScreen() {
}
void WrongHWIDScreen::OnExit() {
if (is_hidden())
return;
exit_callback_.Run();
}
......
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