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

Side by Side 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: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 6
7 /** 7 /**
8 * Names of the radio buttons which allow the user to choose his encryption 8 * Names of the radio buttons which allow the user to choose his encryption
9 * mechanism. 9 * mechanism.
10 * @enum {string} 10 * @enum {string}
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 /** 61 /**
62 * The current sync preferences, supplied by SyncBrowserProxy. 62 * The current sync preferences, supplied by SyncBrowserProxy.
63 * @type {?settings.SyncPrefs} 63 * @type {?settings.SyncPrefs}
64 */ 64 */
65 syncPrefs: { 65 syncPrefs: {
66 type: Object, 66 type: Object,
67 }, 67 },
68 68
69 /** 69 /**
70 * Caches the individually selected synced data types. This is used to
71 * be able to restore the selections after checking and unchecking Sync All.
dpapad 2016/06/28 22:23:32 @private
tommycli 2016/06/29 00:04:07 Done.
72 */
73 cachedSyncPrefs_: {
74 type: Object,
75 },
76
77 /**
70 * Whether the "create passphrase" inputs should be shown. These inputs 78 * Whether the "create passphrase" inputs should be shown. These inputs
71 * give the user the opportunity to use a custom passphrase instead of 79 * give the user the opportunity to use a custom passphrase instead of
72 * authenticating with his Google credentials. 80 * authenticating with his Google credentials.
73 * @private 81 * @private
74 */ 82 */
75 creatingNewPassphrase_: { 83 creatingNewPassphrase_: {
76 type: Boolean, 84 type: Boolean,
77 value: false, 85 value: false,
78 }, 86 },
79 87
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (this.syncPrefs.encryptAllData) 189 if (this.syncPrefs.encryptAllData)
182 this.creatingNewPassphrase_ = false; 190 this.creatingNewPassphrase_ = false;
183 }, 191 },
184 192
185 /** 193 /**
186 * Handler for when the sync all data types checkbox is changed. 194 * Handler for when the sync all data types checkbox is changed.
187 * @param {Event} event 195 * @param {Event} event
188 * @private 196 * @private
189 */ 197 */
190 onSyncAllDataTypesChanged_: function(event) { 198 onSyncAllDataTypesChanged_: function(event) {
199 var SyncPrefsIndividualDataTypes = [
dpapad 2016/06/28 22:23:33 Can this array be moved outside this function as a
tommycli 2016/06/29 00:04:07 Done.
200 'appsSynced',
201 'extensionsSynced',
202 'preferencesSynced',
203 'autofillSynced',
204 'typedUrlsSynced',
205 'themesSynced',
206 'bookmarksSynced',
207 'passwordsSynced',
208 'tabsSynced',
209 'paymentsIntegrationEnabled',
210 ];
211
191 if (event.target.checked) { 212 if (event.target.checked) {
192 this.set('syncPrefs.syncAllDataTypes', true); 213 this.set('syncPrefs.syncAllDataTypes', true);
193 this.set('syncPrefs.appsSynced', true); 214
194 this.set('syncPrefs.extensionsSynced', true); 215 // Cache the previously selected preference before checking every box.
195 this.set('syncPrefs.preferencesSynced', true); 216 this.cachedSyncPrefs_ = {};
196 this.set('syncPrefs.autofillSynced', true); 217 for (dataType of SyncPrefsIndividualDataTypes) {
197 this.set('syncPrefs.typedUrlsSynced', true); 218 this.cachedSyncPrefs_[dataType] = this.syncPrefs[dataType];
dpapad 2016/06/28 22:23:33 What is the key/value pair of syncPrefs look like?
tommycli 2016/06/29 00:04:07 Done. I added a comment.
198 this.set('syncPrefs.themesSynced', true); 219
199 this.set('syncPrefs.bookmarksSynced', true); 220 this.set(['syncPrefs', dataType], true);
200 this.set('syncPrefs.passwordsSynced', true); 221 }
201 this.set('syncPrefs.tabsSynced', true); 222 } else if (this.cachedSyncPrefs_) {
202 this.set('syncPrefs.paymentsIntegrationEnabled', true); 223 // Restore the previously selected preference.
224 for (dataType of SyncPrefsIndividualDataTypes) {
225 this.set(['syncPrefs', dataType], this.cachedSyncPrefs_[dataType]);
226 }
203 } 227 }
204 228
205 this.onSingleSyncDataTypeChanged_(); 229 this.onSingleSyncDataTypeChanged_();
206 }, 230 },
207 231
208 /** 232 /**
209 * Handler for when any sync data type checkbox is changed (except autofill). 233 * Handler for when any sync data type checkbox is changed (except autofill).
210 * @private 234 * @private
211 */ 235 */
212 onSingleSyncDataTypeChanged_: function() { 236 onSingleSyncDataTypeChanged_: function() {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 389
366 passphraseInput.invalid = emptyPassphrase; 390 passphraseInput.invalid = emptyPassphrase;
367 passphraseConfirmationInput.invalid = 391 passphraseConfirmationInput.invalid =
368 !emptyPassphrase && mismatchedPassphrase; 392 !emptyPassphrase && mismatchedPassphrase;
369 393
370 return !emptyPassphrase && !mismatchedPassphrase; 394 return !emptyPassphrase && !mismatchedPassphrase;
371 }, 395 },
372 }); 396 });
373 397
374 })(); 398 })();
OLDNEW
« 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