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