Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java |
| index 394fae03fc677eac8ba62089715f3c2c9561d288..ce7c6540e3e556446c708b9d04ee101914f8a979 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/ui/SyncCustomizationFragment.java |
| @@ -28,11 +28,11 @@ import android.view.ViewGroup; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.base.metrics.RecordHistogram; |
| import org.chromium.chrome.R; |
| - |
| import org.chromium.chrome.browser.autofill.PersonalDataManager; |
| import org.chromium.chrome.browser.childaccounts.ChildAccountService; |
| import org.chromium.chrome.browser.invalidation.InvalidationController; |
| import org.chromium.chrome.browser.preferences.ChromeSwitchPreference; |
| +import org.chromium.chrome.browser.preferences.SyncAccountListPreference; |
| import org.chromium.chrome.browser.sync.ProfileSyncService; |
| import org.chromium.sync.AndroidSyncSettings; |
| import org.chromium.sync.ModelType; |
| @@ -79,7 +79,11 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| @VisibleForTesting |
| public static final String PREF_SYNC_SWITCH = "sync_switch"; |
| @VisibleForTesting |
| + public static final String PREFERENCE_SYNC_IMPORT_DATA = "sync_import_data"; |
|
newt (away)
2016/02/12 22:03:51
unused?
May
2016/02/16 17:32:08
Removed
|
| + @VisibleForTesting |
| public static final String PREFERENCE_SYNC_MANAGE_DATA = "sync_manage_data"; |
| + @VisibleForTesting |
| + public static final String PREFERENCE_SYNC_ACCOUNT_LIST = "sync_account_list"; |
| public static final String ARGUMENT_ACCOUNT = "account"; |
| @@ -114,13 +118,12 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| private Preference mSyncEncryption; |
| private Preference mManageSyncData; |
| private CheckBoxPreference[] mAllTypes; |
| - private boolean mCheckboxesInitialized; |
| private ProfileSyncService mProfileSyncService; |
| @Override |
| - public View onCreateView(LayoutInflater inflater, ViewGroup container, |
| - Bundle savedInstanceState) { |
| + public View onCreateView( |
| + LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
| mProfileSyncService = ProfileSyncService.get(); |
| assert mProfileSyncService != null; |
| mIsBackendInitialized = mProfileSyncService.isBackendInitialized(); |
| @@ -145,10 +148,8 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| mManageSyncData = findPreference(PREFERENCE_SYNC_MANAGE_DATA); |
| mManageSyncData.setOnPreferenceClickListener(this); |
| - mAllTypes = new CheckBoxPreference[]{ |
| - mSyncAutofill, mSyncBookmarks, mSyncOmnibox, mSyncPasswords, |
| - mSyncRecentTabs, mSyncSettings, mPaymentsIntegration |
| - }; |
| + mAllTypes = new CheckBoxPreference[] {mSyncAutofill, mSyncBookmarks, mSyncOmnibox, |
|
newt (away)
2016/02/12 22:03:51
revert rewrapping
May
2016/02/16 17:32:08
Removed all auto-formatted changes in this file
|
| + mSyncPasswords, mSyncRecentTabs, mSyncSettings, mPaymentsIntegration}; |
| mSyncEverything.setOnPreferenceChangeListener(this); |
| for (CheckBoxPreference type : mAllTypes) { |
| @@ -273,10 +274,9 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| } |
| /** |
| - * Update the state of all settings from sync. |
| - * |
| - * This sets the state of the sync switch from external sync state and then calls |
| - * updateSyncStateFromSwitch, which uses that as its source of truth. |
| + * Update the state of all settings from sync. This sets the state of the sync switch from |
|
newt (away)
2016/02/12 22:03:51
revert rewrapping
May
2016/02/16 17:32:08
Done.
|
| + * external sync state and then calls updateSyncStateFromSwitch, which uses that as its source |
| + * of truth. |
| */ |
| private void updateSyncState() { |
| boolean isSyncEnabled = AndroidSyncSettings.isSyncEnabled(getActivity()); |
| @@ -285,6 +285,12 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| updateSyncStateFromSwitch(); |
| } |
| + private void updateSyncAccountsListState() { |
| + SyncAccountListPreference accountList = |
| + (SyncAccountListPreference) findPreference(PREFERENCE_SYNC_ACCOUNT_LIST); |
| + accountList.updateState(mSyncSwitchPreference.isChecked()); |
| + } |
| + |
| /** |
| * Update the state of settings using the switch state to determine if sync is enabled. |
| */ |
| @@ -292,15 +298,14 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| updateSyncEverythingState(); |
| updateDataTypeState(); |
| updateEncryptionState(); |
| + updateSyncAccountsListState(); |
| } |
| /** |
| - * Update the encryption state. |
| - * |
| - * If sync's backend is initialized, the button is enabled and the dialog will present the |
| - * valid encryption options for the user. Otherwise, any encryption dialogs will be closed |
| - * and the button will be disabled because the backend is needed in order to know and |
| - * modify the encryption state. |
| + * Update the encryption state. If sync's backend is initialized, the button is enabled and the |
|
newt (away)
2016/02/12 22:03:51
revert rewrapping
May
2016/02/16 17:32:08
Done.
|
| + * dialog will present the valid encryption options for the user. Otherwise, any encryption |
| + * dialogs will be closed and the button will be disabled because the backend is needed in order |
| + * to know and modify the encryption state. |
| */ |
| private void updateEncryptionState() { |
| boolean isSyncEnabled = mSyncSwitchPreference.isChecked(); |
| @@ -339,8 +344,7 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| boolean syncEverything = mSyncEverything.isChecked(); |
| mProfileSyncService.setPreferredDataTypes(syncEverything, getSelectedModelTypes()); |
| // Update the invalidation listener with the set of types we are enabling. |
| - InvalidationController invController = |
| - InvalidationController.get(getActivity()); |
| + InvalidationController invController = InvalidationController.get(getActivity()); |
| invController.ensureStartedAndUpdateRegisteredTypes(); |
| } |
| @@ -475,7 +479,7 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| public boolean onPreferenceClick(Preference preference) { |
| if (!isResumed()) { |
| // This event could come in after onPause if the user clicks back and the preference at |
| - // roughly the same time. See http://b/5983282 |
| + // roughly the same time. See http://b/5983282 |
| return false; |
| } |
| if (preference == mSyncEncryption && mProfileSyncService.isBackendInitialized()) { |
| @@ -503,10 +507,8 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| } |
| /** |
| - * Update the state of the sync everything switch. |
| - * |
| - * If sync is on, load the pref from native. Otherwise display sync everything as on but |
| - * disable the switch. |
| + * Update the state of the sync everything switch. If sync is on, load the pref from native. |
|
newt (away)
2016/02/12 22:03:51
revert rewrapping, here and below
May
2016/02/16 17:32:08
Done.
|
| + * Otherwise display sync everything as on but disable the switch. |
| */ |
| private void updateSyncEverythingState() { |
| boolean isSyncEnabled = mSyncSwitchPreference.isChecked(); |
| @@ -516,11 +518,10 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| } |
| /** |
| - * Update the data type switch state. |
| - * |
| - * If sync is on, load the prefs from native. Otherwise, all data types are disabled and |
| - * checked. Note that the Password data type will be shown as disabled and unchecked between |
| - * sync being turned on and the backend initialization completing. |
| + * Update the data type switch state. If sync is on, load the prefs from native. Otherwise, all |
| + * data types are disabled and checked. Note that the Password data type will be shown as |
| + * disabled and unchecked between sync being turned on and the backend initialization |
| + * completing. |
| */ |
| private void updateDataTypeState() { |
| boolean isSyncEnabled = mSyncSwitchPreference.isChecked(); |
| @@ -558,10 +559,8 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| } |
| /** |
| - * Listen to sync state changes. |
| - * |
| - * If the user has just turned on sync, this listener is needed in order to enable |
| - * the encryption settings once the backend has initialized. |
| + * Listen to sync state changes. If the user has just turned on sync, this listener is needed in |
| + * order to enable the encryption settings once the backend has initialized. |
| */ |
| @Override |
| public void syncStateChanged() { |
| @@ -579,6 +578,7 @@ public class SyncCustomizationFragment extends PreferenceFragment |
| /** |
| * Disables Sync if all data types have been disabled. |
| + * |
| * @return true if Sync has been disabled, false otherwise. |
| */ |
| private boolean maybeDisableSync() { |