Chromium Code Reviews| Index: chrome/browser/resources/settings/people_page/sync_page.js |
| diff --git a/chrome/browser/resources/settings/people_page/sync_page.js b/chrome/browser/resources/settings/people_page/sync_page.js |
| index c50b263903c447012519667dfd7d8f6da42fe7ef..dba1b03511b0e994e6b088aebeb49fff2fcde02d 100644 |
| --- a/chrome/browser/resources/settings/people_page/sync_page.js |
| +++ b/chrome/browser/resources/settings/people_page/sync_page.js |
| @@ -15,6 +15,23 @@ var RadioButtonNames = { |
| }; |
| /** |
| + * Names of the individual data type properties to be cached from |
| + * settings.SyncPrefs when the user checks 'Sync All'. |
|
dpapad
2016/06/29 01:00:35
@type {!Array<string>}
tommycli
2016/06/29 18:00:02
Done.
|
| + */ |
| +var SyncPrefsIndividualDataTypes = [ |
| + 'appsSynced', |
| + 'extensionsSynced', |
| + 'preferencesSynced', |
| + 'autofillSynced', |
| + 'typedUrlsSynced', |
| + 'themesSynced', |
| + 'bookmarksSynced', |
| + 'passwordsSynced', |
| + 'tabsSynced', |
| + 'paymentsIntegrationEnabled', |
| +]; |
| + |
| +/** |
| * @fileoverview |
| * 'settings-sync-page' is the settings page containing sync settings. |
| * |
| @@ -67,6 +84,15 @@ Polymer({ |
| }, |
| /** |
| + * Caches the individually selected synced data types. This is used to |
| + * be able to restore the selections after checking and unchecking Sync All. |
| + * @private |
| + */ |
| + cachedSyncPrefs_: { |
| + type: Object, |
| + }, |
| + |
| + /** |
| * Whether the "create passphrase" inputs should be shown. These inputs |
| * give the user the opportunity to use a custom passphrase instead of |
| * authenticating with his Google credentials. |
| @@ -190,16 +216,20 @@ Polymer({ |
| onSyncAllDataTypesChanged_: function(event) { |
| if (event.target.checked) { |
|
dpapad
2016/06/29 01:00:35
Guessing that this file is not compiled, otherwise
tommycli
2016/06/29 18:00:02
Hi, it is compiled. I think anything on event.targ
|
| this.set('syncPrefs.syncAllDataTypes', true); |
| - this.set('syncPrefs.appsSynced', true); |
| - this.set('syncPrefs.extensionsSynced', true); |
| - this.set('syncPrefs.preferencesSynced', true); |
| - this.set('syncPrefs.autofillSynced', true); |
| - this.set('syncPrefs.typedUrlsSynced', true); |
| - this.set('syncPrefs.themesSynced', true); |
| - this.set('syncPrefs.bookmarksSynced', true); |
| - this.set('syncPrefs.passwordsSynced', true); |
| - this.set('syncPrefs.tabsSynced', true); |
| - this.set('syncPrefs.paymentsIntegrationEnabled', true); |
| + |
| + // Cache the previously selected preference before checking every box. |
| + this.cachedSyncPrefs_ = {}; |
| + for (dataType of SyncPrefsIndividualDataTypes) { |
| + // These are all booleans, so this shallow copy is sufficient. |
| + this.cachedSyncPrefs_[dataType] = this.syncPrefs[dataType]; |
| + |
| + this.set(['syncPrefs', dataType], true); |
| + } |
| + } else if (this.cachedSyncPrefs_) { |
| + // Restore the previously selected preference. |
| + for (dataType of SyncPrefsIndividualDataTypes) { |
| + this.set(['syncPrefs', dataType], this.cachedSyncPrefs_[dataType]); |
| + } |
| } |
| this.onSingleSyncDataTypeChanged_(); |