From 0acf90ed8a771fd3129fbbca5e1ec898e0430336 Mon Sep 17 00:00:00 2001 From: maxbogue Date: Fri, 20 May 2016 09:09:06 -0700 Subject: [PATCH] [Sync] Ensure the user has a chance to change their settings on Android. Using onCreate and onDestroy means that the user can go into the Google Activity Controls or Sync settings subpages without triggering sync. Note that leaving the sync page will still cause sync to start, but at that point it seems safe to assume the settings are good. BUG=613340 Review-Url: https://codereview.chromium.org/1988133005 Cr-Commit-Position: refs/heads/master@{#395081} --- .../signin/AccountManagementFragment.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java index 62deb41a6c885..915deb2f536eb 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java @@ -119,6 +119,13 @@ public class AccountManagementFragment extends PreferenceFragment public void onCreate(Bundle savedState) { super.onCreate(savedState); + // Prevent sync from starting if it hasn't already to give the user a chance to change + // their sync settings. + ProfileSyncService syncService = ProfileSyncService.get(); + if (syncService != null) { + syncService.setSetupInProgress(true); + } + mGaiaServiceType = AccountManagementScreenHelper.GAIA_SERVICE_TYPE_NONE; if (getArguments() != null) { mGaiaServiceType = @@ -156,6 +163,17 @@ public void onPause() { } } + @Override + public void onDestroy() { + super.onDestroy(); + + // Allow sync to begin syncing if it hasn't yet. + ProfileSyncService syncService = ProfileSyncService.get(); + if (syncService != null) { + syncService.setSetupInProgress(false); + } + } + /** * Initiate fetching the user accounts data (images and the full name). * Fetched data will be sent to observers of ProfileDownloader. @@ -489,7 +507,9 @@ public void onSignOutDialogDismissed(boolean signOutClicked) { @Override public void syncStateChanged() { SyncPreference pref = (SyncPreference) findPreference(PREF_SYNC_SETTINGS); - pref.updateSyncSummaryAndIcon(); + if (pref != null) { + pref.updateSyncSummaryAndIcon(); + } // TODO(crbug/557784): Show notification for sync error }