Commit a26145c6 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[unified-consent] Cancel sync setup on settings search

Bug: 956495
Change-Id: If86a4618eb2865e3bf63a6bfdc3d92096d7f747b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1591839Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659495}
parent 56f9d347
......@@ -291,30 +291,46 @@ Polymer({
currentRouteChanged: function() {
if (settings.getCurrentRoute() == settings.routes.SYNC) {
this.onNavigateToPage_();
} else if (!settings.routes.SYNC.contains(settings.getCurrentRoute())) {
// When the user is about to cancel the sync setup, but hasn't confirmed
// the cancellation, navigate back and show the 'Cancel sync?' dialog.
if (this.unifiedConsentEnabled && this.syncStatus &&
this.syncStatus.setupInProgress && this.didAbort_ &&
!this.setupCancelConfirmed_) {
chrome.metricsPrivate.recordUserAction(
'Signin_Signin_BackOnAdvancedSyncSettings');
// Yield so that other |currentRouteChanged| observers are called,
// before triggering another navigation (and another round of observers
// firing). Triggering navigation from within an observer leads to some
// undefined behavior and runtime errors.
requestAnimationFrame(() => {
settings.navigateTo(settings.routes.SYNC);
this.showSetupCancelDialog_ = true;
// Flush to make sure that the setup cancel dialog is attached.
Polymer.dom.flush();
this.$$('#setupCancelDialog').showModal();
});
} else {
this.setupCancelConfirmed_ = false;
this.onNavigateAwayFromPage_();
}
return;
}
if (settings.routes.SYNC.contains(settings.getCurrentRoute())) {
return;
}
const searchParams = settings.getQueryParameters().get('search');
if (searchParams) {
// User navigated away via searching. Cancel sync without showing
// confirmation dialog.
this.onNavigateAwayFromPage_();
return;
}
const userActionCancelsSetup =
this.syncStatus && this.syncStatus.setupInProgress && this.didAbort_;
if (this.unifiedConsentEnabled && userActionCancelsSetup &&
!this.setupCancelConfirmed_) {
chrome.metricsPrivate.recordUserAction(
'Signin_Signin_BackOnAdvancedSyncSettings');
// Show the 'Cancel sync?' dialog.
// Yield so that other |currentRouteChanged| observers are called,
// before triggering another navigation (and another round of observers
// firing). Triggering navigation from within an observer leads to some
// undefined behavior and runtime errors.
requestAnimationFrame(() => {
settings.navigateTo(settings.routes.SYNC);
this.showSetupCancelDialog_ = true;
// Flush to make sure that the setup cancel dialog is attached.
Polymer.dom.flush();
this.$$('#setupCancelDialog').showModal();
});
return;
}
// Reset variable.
this.setupCancelConfirmed_ = false;
this.onNavigateAwayFromPage_();
},
/**
......
......@@ -707,6 +707,26 @@ cr.define('settings_people_page_sync_page', function() {
});
});
test('SyncSetupSearchSettings UnifiedConsentEnabled', function() {
syncPage.unifiedConsentEnabled = true;
syncPage.syncStatus = {
signinAllowed: true,
syncSystemEnabled: true,
setupInProgress: true,
signedIn: true
};
Polymer.dom.flush();
// Searching settings while setup is in progress cancels sync.
settings.navigateTo(
settings.routes.BASIC, new URLSearchParams('search=foo'));
return browserProxy.whenCalled('didNavigateAwayFromSyncPage')
.then(abort => {
assertTrue(abort);
});
});
test('ShowAccountRow', function() {
assertFalse(!!syncPage.$$('settings-sync-account-control'));
syncPage.diceEnabled = true;
......
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