| OLD | NEW |
| 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} |
| 11 */ | 11 */ |
| 12 var RadioButtonNames = { | 12 var RadioButtonNames = { |
| 13 ENCRYPT_WITH_GOOGLE: 'encrypt-with-google', | 13 ENCRYPT_WITH_GOOGLE: 'encrypt-with-google', |
| 14 ENCRYPT_WITH_PASSPHRASE: 'encrypt-with-passphrase', | 14 ENCRYPT_WITH_PASSPHRASE: 'encrypt-with-passphrase', |
| 15 }; | 15 }; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Names of the individual data type properties to be cached from |
| 19 * settings.SyncPrefs when the user checks 'Sync All'. |
| 20 * @type {!Array<string>} |
| 21 */ |
| 22 var SyncPrefsIndividualDataTypes = [ |
| 23 'appsSynced', |
| 24 'extensionsSynced', |
| 25 'preferencesSynced', |
| 26 'autofillSynced', |
| 27 'typedUrlsSynced', |
| 28 'themesSynced', |
| 29 'bookmarksSynced', |
| 30 'passwordsSynced', |
| 31 'tabsSynced', |
| 32 'paymentsIntegrationEnabled', |
| 33 ]; |
| 34 |
| 35 /** |
| 18 * @fileoverview | 36 * @fileoverview |
| 19 * 'settings-sync-page' is the settings page containing sync settings. | 37 * 'settings-sync-page' is the settings page containing sync settings. |
| 20 * | 38 * |
| 21 * Example: | 39 * Example: |
| 22 * | 40 * |
| 23 * <iron-animated-pages> | 41 * <iron-animated-pages> |
| 24 * <settings-sync-page></settings-sync-page> | 42 * <settings-sync-page></settings-sync-page> |
| 25 * ... other pages ... | 43 * ... other pages ... |
| 26 * </iron-animated-pages> | 44 * </iron-animated-pages> |
| 27 */ | 45 */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 78 |
| 61 /** | 79 /** |
| 62 * The current sync preferences, supplied by SyncBrowserProxy. | 80 * The current sync preferences, supplied by SyncBrowserProxy. |
| 63 * @type {?settings.SyncPrefs} | 81 * @type {?settings.SyncPrefs} |
| 64 */ | 82 */ |
| 65 syncPrefs: { | 83 syncPrefs: { |
| 66 type: Object, | 84 type: Object, |
| 67 }, | 85 }, |
| 68 | 86 |
| 69 /** | 87 /** |
| 88 * Caches the individually selected synced data types. This is used to |
| 89 * be able to restore the selections after checking and unchecking Sync All. |
| 90 * @private |
| 91 */ |
| 92 cachedSyncPrefs_: { |
| 93 type: Object, |
| 94 }, |
| 95 |
| 96 /** |
| 70 * Whether the "create passphrase" inputs should be shown. These inputs | 97 * Whether the "create passphrase" inputs should be shown. These inputs |
| 71 * give the user the opportunity to use a custom passphrase instead of | 98 * give the user the opportunity to use a custom passphrase instead of |
| 72 * authenticating with his Google credentials. | 99 * authenticating with his Google credentials. |
| 73 * @private | 100 * @private |
| 74 */ | 101 */ |
| 75 creatingNewPassphrase_: { | 102 creatingNewPassphrase_: { |
| 76 type: Boolean, | 103 type: Boolean, |
| 77 value: false, | 104 value: false, |
| 78 }, | 105 }, |
| 79 | 106 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (!this.syncPrefs.autofillRegistered || !this.syncPrefs.autofillSynced) | 204 if (!this.syncPrefs.autofillRegistered || !this.syncPrefs.autofillSynced) |
| 178 this.set('syncPrefs.paymentsIntegrationEnabled', false); | 205 this.set('syncPrefs.paymentsIntegrationEnabled', false); |
| 179 | 206 |
| 180 // Hide the new passphrase box if the sync data has been encrypted. | 207 // Hide the new passphrase box if the sync data has been encrypted. |
| 181 if (this.syncPrefs.encryptAllData) | 208 if (this.syncPrefs.encryptAllData) |
| 182 this.creatingNewPassphrase_ = false; | 209 this.creatingNewPassphrase_ = false; |
| 183 }, | 210 }, |
| 184 | 211 |
| 185 /** | 212 /** |
| 186 * Handler for when the sync all data types checkbox is changed. | 213 * Handler for when the sync all data types checkbox is changed. |
| 187 * @param {Event} event | 214 * @param {!Event} event |
| 188 * @private | 215 * @private |
| 189 */ | 216 */ |
| 190 onSyncAllDataTypesChanged_: function(event) { | 217 onSyncAllDataTypesChanged_: function(event) { |
| 191 if (event.target.checked) { | 218 if (event.target.checked) { |
| 192 this.set('syncPrefs.syncAllDataTypes', true); | 219 this.set('syncPrefs.syncAllDataTypes', true); |
| 193 this.set('syncPrefs.appsSynced', true); | 220 |
| 194 this.set('syncPrefs.extensionsSynced', true); | 221 // Cache the previously selected preference before checking every box. |
| 195 this.set('syncPrefs.preferencesSynced', true); | 222 this.cachedSyncPrefs_ = {}; |
| 196 this.set('syncPrefs.autofillSynced', true); | 223 for (var dataType of SyncPrefsIndividualDataTypes) { |
| 197 this.set('syncPrefs.typedUrlsSynced', true); | 224 // These are all booleans, so this shallow copy is sufficient. |
| 198 this.set('syncPrefs.themesSynced', true); | 225 this.cachedSyncPrefs_[dataType] = this.syncPrefs[dataType]; |
| 199 this.set('syncPrefs.bookmarksSynced', true); | 226 |
| 200 this.set('syncPrefs.passwordsSynced', true); | 227 this.set(['syncPrefs', dataType], true); |
| 201 this.set('syncPrefs.tabsSynced', true); | 228 } |
| 202 this.set('syncPrefs.paymentsIntegrationEnabled', true); | 229 } else if (this.cachedSyncPrefs_) { |
| 230 // Restore the previously selected preference. |
| 231 for (dataType of SyncPrefsIndividualDataTypes) { |
| 232 this.set(['syncPrefs', dataType], this.cachedSyncPrefs_[dataType]); |
| 233 } |
| 203 } | 234 } |
| 204 | 235 |
| 205 this.onSingleSyncDataTypeChanged_(); | 236 this.onSingleSyncDataTypeChanged_(); |
| 206 }, | 237 }, |
| 207 | 238 |
| 208 /** | 239 /** |
| 209 * Handler for when any sync data type checkbox is changed (except autofill). | 240 * Handler for when any sync data type checkbox is changed (except autofill). |
| 210 * @private | 241 * @private |
| 211 */ | 242 */ |
| 212 onSingleSyncDataTypeChanged_: function() { | 243 onSingleSyncDataTypeChanged_: function() { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 396 |
| 366 passphraseInput.invalid = emptyPassphrase; | 397 passphraseInput.invalid = emptyPassphrase; |
| 367 passphraseConfirmationInput.invalid = | 398 passphraseConfirmationInput.invalid = |
| 368 !emptyPassphrase && mismatchedPassphrase; | 399 !emptyPassphrase && mismatchedPassphrase; |
| 369 | 400 |
| 370 return !emptyPassphrase && !mismatchedPassphrase; | 401 return !emptyPassphrase && !mismatchedPassphrase; |
| 371 }, | 402 }, |
| 372 }); | 403 }); |
| 373 | 404 |
| 374 })(); | 405 })(); |
| OLD | NEW |