Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Unified Diff: chrome/browser/resources/settings/people_page/sync_page.js

Issue 2104173002: Settings People Revamp: Cache the selected Sync individual data types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f1d0daa814f63163f80f6f2c75795f365e11714c 100644
--- a/chrome/browser/resources/settings/people_page/sync_page.js
+++ b/chrome/browser/resources/settings/people_page/sync_page.js
@@ -15,6 +15,24 @@ var RadioButtonNames = {
};
/**
+ * Names of the individual data type properties to be cached from
+ * settings.SyncPrefs when the user checks 'Sync All'.
+ * @type {!Array<string>}
+ */
+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 +85,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.
@@ -184,22 +211,26 @@ Polymer({
/**
* Handler for when the sync all data types checkbox is changed.
- * @param {Event} event
+ * @param {!Event} event
* @private
*/
onSyncAllDataTypesChanged_: function(event) {
if (event.target.checked) {
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 (var 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_();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698