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 @@ ...@@ -18,7 +18,9 @@
namespace { namespace {
constexpr char kUserActionAccepted[] = "accepted";
constexpr char kUserActionBack[] = "go-back"; constexpr char kUserActionBack[] = "go-back";
constexpr char kUserActionSkip[] = "skip";
} // namespace } // namespace
...@@ -83,18 +85,25 @@ void ArcTermsOfServiceScreen::HideImpl() { ...@@ -83,18 +85,25 @@ void ArcTermsOfServiceScreen::HideImpl() {
} }
void ArcTermsOfServiceScreen::OnUserAction(const std::string& action_id) { 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); exit_callback_.Run(Result::BACK);
} else if (action_id == kUserActionSkip) {
exit_callback_.Run(Result::SKIPPED);
} else { } else {
BaseScreen::OnUserAction(action_id); BaseScreen::OnUserAction(action_id);
} }
} }
void ArcTermsOfServiceScreen::OnSkip() { 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) { void ArcTermsOfServiceScreen::OnAccept(bool review_arc_settings) {
if (is_hidden())
return;
base::UmaHistogramBoolean("OOBE.ArcTermsOfServiceScreen.ReviewFollowingSetup", base::UmaHistogramBoolean("OOBE.ArcTermsOfServiceScreen.ReviewFollowingSetup",
review_arc_settings); review_arc_settings);
if (review_arc_settings) { if (review_arc_settings) {
...@@ -103,7 +112,7 @@ void ArcTermsOfServiceScreen::OnAccept(bool review_arc_settings) { ...@@ -103,7 +112,7 @@ void ArcTermsOfServiceScreen::OnAccept(bool review_arc_settings) {
profile->GetPrefs()->SetBoolean(prefs::kShowArcSettingsOnSessionStart, profile->GetPrefs()->SetBoolean(prefs::kShowArcSettingsOnSessionStart,
true); true);
} }
exit_callback_.Run(Result::ACCEPTED); HandleUserAction(kUserActionAccepted);
} }
void ArcTermsOfServiceScreen::OnViewDestroyed( void ArcTermsOfServiceScreen::OnViewDestroyed(
......
...@@ -27,6 +27,8 @@ EnableDebuggingScreen::~EnableDebuggingScreen() { ...@@ -27,6 +27,8 @@ EnableDebuggingScreen::~EnableDebuggingScreen() {
} }
void EnableDebuggingScreen::OnExit(bool success) { void EnableDebuggingScreen::OnExit(bool success) {
if (is_hidden())
return;
exit_callback_.Run(); exit_callback_.Run();
} }
......
...@@ -39,6 +39,8 @@ KioskAutolaunchScreen::~KioskAutolaunchScreen() { ...@@ -39,6 +39,8 @@ KioskAutolaunchScreen::~KioskAutolaunchScreen() {
} }
void KioskAutolaunchScreen::OnExit(bool confirmed) { void KioskAutolaunchScreen::OnExit(bool confirmed) {
if (is_hidden())
return;
exit_callback_.Run(confirmed ? Result::COMPLETED : Result::CANCELED); exit_callback_.Run(confirmed ? Result::COMPLETED : Result::CANCELED);
} }
......
...@@ -43,11 +43,16 @@ RecommendAppsScreen::~RecommendAppsScreen() { ...@@ -43,11 +43,16 @@ RecommendAppsScreen::~RecommendAppsScreen() {
view_->Bind(nullptr); view_->Bind(nullptr);
} }
// TODO(https://crbug.com/1070917) Migrate to OnUserAction.
void RecommendAppsScreen::OnSkip() { void RecommendAppsScreen::OnSkip() {
if (is_hidden())
return;
exit_callback_.Run(Result::SKIPPED); exit_callback_.Run(Result::SKIPPED);
} }
void RecommendAppsScreen::OnInstall() { void RecommendAppsScreen::OnInstall() {
if (is_hidden())
return;
exit_callback_.Run(Result::SELECTED); exit_callback_.Run(Result::SELECTED);
} }
...@@ -88,6 +93,8 @@ void RecommendAppsScreen::OnLoadSuccess(const base::Value& app_list) { ...@@ -88,6 +93,8 @@ void RecommendAppsScreen::OnLoadSuccess(const base::Value& app_list) {
} }
void RecommendAppsScreen::OnLoadError() { void RecommendAppsScreen::OnLoadError() {
if (is_hidden())
return;
exit_callback_.Run(Result::LOAD_ERROR); exit_callback_.Run(Result::LOAD_ERROR);
} }
......
...@@ -116,6 +116,8 @@ void SyncConsentScreen::OnStateChanged(syncer::SyncService* sync) { ...@@ -116,6 +116,8 @@ void SyncConsentScreen::OnStateChanged(syncer::SyncService* sync) {
void SyncConsentScreen::OnContinueAndReview( void SyncConsentScreen::OnContinueAndReview(
const std::vector<int>& consent_description, const std::vector<int>& consent_description,
const int consent_confirmation) { const int consent_confirmation) {
if (is_hidden())
return;
RecordUmaReviewFollowingSetup(true); RecordUmaReviewFollowingSetup(true);
RecordConsent(CONSENT_GIVEN, consent_description, consent_confirmation); RecordConsent(CONSENT_GIVEN, consent_description, consent_confirmation);
profile_->GetPrefs()->SetBoolean(prefs::kShowSyncSettingsOnSessionStart, profile_->GetPrefs()->SetBoolean(prefs::kShowSyncSettingsOnSessionStart,
...@@ -126,6 +128,8 @@ void SyncConsentScreen::OnContinueAndReview( ...@@ -126,6 +128,8 @@ void SyncConsentScreen::OnContinueAndReview(
void SyncConsentScreen::OnContinueWithDefaults( void SyncConsentScreen::OnContinueWithDefaults(
const std::vector<int>& consent_description, const std::vector<int>& consent_description,
const int consent_confirmation) { const int consent_confirmation) {
if (is_hidden())
return;
RecordUmaReviewFollowingSetup(false); RecordUmaReviewFollowingSetup(false);
RecordConsent(CONSENT_GIVEN, consent_description, consent_confirmation); RecordConsent(CONSENT_GIVEN, consent_description, consent_confirmation);
exit_callback_.Run(); exit_callback_.Run();
...@@ -136,6 +140,8 @@ void SyncConsentScreen::OnAcceptAndContinue( ...@@ -136,6 +140,8 @@ void SyncConsentScreen::OnAcceptAndContinue(
int consent_confirmation, int consent_confirmation,
bool enable_os_sync) { bool enable_os_sync) {
DCHECK(chromeos::features::IsSplitSyncConsentEnabled()); DCHECK(chromeos::features::IsSplitSyncConsentEnabled());
if (is_hidden())
return;
// The user only consented to the feature if they left the toggle on. // The user only consented to the feature if they left the toggle on.
RecordConsent(enable_os_sync ? CONSENT_GIVEN : CONSENT_NOT_GIVEN, RecordConsent(enable_os_sync ? CONSENT_GIVEN : CONSENT_NOT_GIVEN,
consent_description, consent_confirmation); consent_description, consent_confirmation);
......
...@@ -26,6 +26,8 @@ WrongHWIDScreen::~WrongHWIDScreen() { ...@@ -26,6 +26,8 @@ WrongHWIDScreen::~WrongHWIDScreen() {
} }
void WrongHWIDScreen::OnExit() { void WrongHWIDScreen::OnExit() {
if (is_hidden())
return;
exit_callback_.Run(); 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