| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.exportPath('options'); | 5 cr.exportPath('options'); |
| 6 | 6 |
| 7 /** @typedef {{appsEnforced: boolean, | 7 /** @typedef {{appsEnforced: boolean, |
| 8 * appsRegistered: boolean, | 8 * appsRegistered: boolean, |
| 9 * appsSynced: boolean, | 9 * appsSynced: boolean, |
| 10 * autofillEnforced: boolean, | 10 * autofillEnforced: boolean, |
| 11 * autofillRegistered: boolean, | 11 * autofillRegistered: boolean, |
| 12 * autofillSynced: boolean, | 12 * autofillSynced: boolean, |
| 13 * bookmarksEnforced: boolean, | 13 * bookmarksEnforced: boolean, |
| 14 * bookmarksRegistered: boolean, | 14 * bookmarksRegistered: boolean, |
| 15 * bookmarksSynced: boolean, | 15 * bookmarksSynced: boolean, |
| 16 * encryptAllData: boolean, | 16 * encryptAllData: boolean, |
| 17 * encryptAllDataAllowed: boolean, | 17 * encryptAllDataAllowed: boolean, |
| 18 * enterGooglePassphraseBody: (string|undefined), | 18 * enterGooglePassphraseBody: (string|undefined), |
| 19 * enterPassphraseBody: (string|undefined), | 19 * enterPassphraseBody: (string|undefined), |
| 20 * extensionsEnforced: boolean, | 20 * extensionsEnforced: boolean, |
| 21 * extensionsRegistered: boolean, | 21 * extensionsRegistered: boolean, |
| 22 * extensionsSynced: boolean, | 22 * extensionsSynced: boolean, |
| 23 * fullEncryptionBody: string, | 23 * fullEncryptionBody: string, |
| 24 * passphraseFailed: boolean, | 24 * passphraseFailed: boolean, |
| 25 * passwordsEnforced: boolean, | 25 * passwordsEnforced: boolean, |
| 26 * passwordsRegistered: boolean, | 26 * passwordsRegistered: boolean, |
| 27 * passwordsSynced: boolean, | 27 * passwordsSynced: boolean, |
| 28 * paymentsIntegrationEnabled: boolean, |
| 28 * preferencesEnforced: boolean, | 29 * preferencesEnforced: boolean, |
| 29 * preferencesRegistered: boolean, | 30 * preferencesRegistered: boolean, |
| 30 * preferencesSynced: boolean, | 31 * preferencesSynced: boolean, |
| 31 * showPassphrase: boolean, | 32 * showPassphrase: boolean, |
| 32 * syncAllDataTypes: boolean, | 33 * syncAllDataTypes: boolean, |
| 33 * syncNothing: boolean, | 34 * syncNothing: boolean, |
| 34 * tabsEnforced: boolean, | 35 * tabsEnforced: boolean, |
| 35 * tabsRegistered: boolean, | 36 * tabsRegistered: boolean, |
| 36 * tabsSynced: boolean, | 37 * tabsSynced: boolean, |
| 37 * themesEnforced: boolean, | 38 * themesEnforced: boolean, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 }; | 153 }; |
| 153 $('stop-syncing-ok').onclick = function() { | 154 $('stop-syncing-ok').onclick = function() { |
| 154 var deleteProfile = $('delete-profile') != undefined && | 155 var deleteProfile = $('delete-profile') != undefined && |
| 155 $('delete-profile').checked; | 156 $('delete-profile').checked; |
| 156 chrome.send('SyncSetupStopSyncing', [deleteProfile]); | 157 chrome.send('SyncSetupStopSyncing', [deleteProfile]); |
| 157 self.closeOverlay_(); | 158 self.closeOverlay_(); |
| 158 }; | 159 }; |
| 159 $('use-default-link').onclick = function() { | 160 $('use-default-link').onclick = function() { |
| 160 self.showSyncEverythingPage_(); | 161 self.showSyncEverythingPage_(); |
| 161 }; | 162 }; |
| 163 $('autofill-checkbox').onclick = function() { |
| 164 var autofillSyncEnabled = $('autofill-checkbox').checked; |
| 165 $('payments-integration-checkbox').checked = autofillSyncEnabled; |
| 166 $('payments-integration-checkbox').disabled = !autofillSyncEnabled; |
| 167 }; |
| 162 }, | 168 }, |
| 163 | 169 |
| 164 /** @private */ | 170 /** @private */ |
| 165 showOverlay_: function() { | 171 showOverlay_: function() { |
| 166 PageManager.showPageByName('syncSetup'); | 172 PageManager.showPageByName('syncSetup'); |
| 167 }, | 173 }, |
| 168 | 174 |
| 169 /** @private */ | 175 /** @private */ |
| 170 closeOverlay_: function() { | 176 closeOverlay_: function() { |
| 171 this.syncConfigureArgs_ = null; | 177 this.syncConfigureArgs_ = null; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 * @private | 209 * @private |
| 204 */ | 210 */ |
| 205 checkAllDataTypeCheckboxes_: function(value) { | 211 checkAllDataTypeCheckboxes_: function(value) { |
| 206 // Only check / uncheck the visible ones (since there's no way to uncheck | 212 // Only check / uncheck the visible ones (since there's no way to uncheck |
| 207 // / check the invisible ones). | 213 // / check the invisible ones). |
| 208 var checkboxes = $('choose-data-types-body').querySelectorAll( | 214 var checkboxes = $('choose-data-types-body').querySelectorAll( |
| 209 '.sync-type-checkbox:not([hidden]) input'); | 215 '.sync-type-checkbox:not([hidden]) input'); |
| 210 for (var i = 0; i < checkboxes.length; i++) { | 216 for (var i = 0; i < checkboxes.length; i++) { |
| 211 checkboxes[i].checked = value; | 217 checkboxes[i].checked = value; |
| 212 } | 218 } |
| 219 $('payments-integration-checkbox').checked = value; |
| 213 }, | 220 }, |
| 214 | 221 |
| 215 /** | 222 /** |
| 216 * Restores the checked states of the sync data type checkboxes in the | 223 * Restores the checked states of the sync data type checkboxes in the |
| 217 * advanced sync settings dialog. Called when "Choose what to sync" is | 224 * advanced sync settings dialog. Called when "Choose what to sync" is |
| 218 * selected. Required because all the checkboxes are checked when | 225 * selected. Required because all the checkboxes are checked when |
| 219 * "Sync everything" is selected, and unchecked when "Sync nothing" is | 226 * "Sync everything" is selected, and unchecked when "Sync nothing" is |
| 220 * selected. Note: We only restore checkboxes for data types that are | 227 * selected. Note: We only restore checkboxes for data types that are |
| 221 * actually visible and whose old values are found in the cache, since it's | 228 * actually visible and whose old values are found in the cache, since it's |
| 222 * possible for some data types to not be registered, and therefore, their | 229 * possible for some data types to not be registered, and therefore, their |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 // configuration to the backend. | 330 // configuration to the backend. |
| 324 this.setInputElementsDisabledState_(true); | 331 this.setInputElementsDisabledState_(true); |
| 325 $('use-default-link').hidden = true; | 332 $('use-default-link').hidden = true; |
| 326 | 333 |
| 327 // These values need to be kept in sync with where they are read in | 334 // These values need to be kept in sync with where they are read in |
| 328 // sync_setup_handler.cc:GetConfiguration(). | 335 // sync_setup_handler.cc:GetConfiguration(). |
| 329 var syncAll = $('sync-select-datatypes').selectedIndex == | 336 var syncAll = $('sync-select-datatypes').selectedIndex == |
| 330 options.DataTypeSelection.SYNC_EVERYTHING; | 337 options.DataTypeSelection.SYNC_EVERYTHING; |
| 331 var syncNothing = $('sync-select-datatypes').selectedIndex == | 338 var syncNothing = $('sync-select-datatypes').selectedIndex == |
| 332 options.DataTypeSelection.SYNC_NOTHING; | 339 options.DataTypeSelection.SYNC_NOTHING; |
| 340 var autofillSynced = syncAll || $('autofill-checkbox').checked; |
| 333 var result = JSON.stringify({ | 341 var result = JSON.stringify({ |
| 334 'syncAllDataTypes': syncAll, | 342 'syncAllDataTypes': syncAll, |
| 335 'syncNothing': syncNothing, | 343 'syncNothing': syncNothing, |
| 336 'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked, | 344 'bookmarksSynced': syncAll || $('bookmarks-checkbox').checked, |
| 337 'preferencesSynced': syncAll || $('preferences-checkbox').checked, | 345 'preferencesSynced': syncAll || $('preferences-checkbox').checked, |
| 338 'themesSynced': syncAll || $('themes-checkbox').checked, | 346 'themesSynced': syncAll || $('themes-checkbox').checked, |
| 339 'passwordsSynced': syncAll || $('passwords-checkbox').checked, | 347 'passwordsSynced': syncAll || $('passwords-checkbox').checked, |
| 340 'autofillSynced': syncAll || $('autofill-checkbox').checked, | 348 'autofillSynced': autofillSynced, |
| 341 'extensionsSynced': syncAll || $('extensions-checkbox').checked, | 349 'extensionsSynced': syncAll || $('extensions-checkbox').checked, |
| 342 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked, | 350 'typedUrlsSynced': syncAll || $('typed-urls-checkbox').checked, |
| 343 'appsSynced': syncAll || $('apps-checkbox').checked, | 351 'appsSynced': syncAll || $('apps-checkbox').checked, |
| 344 'tabsSynced': syncAll || $('tabs-checkbox').checked, | 352 'tabsSynced': syncAll || $('tabs-checkbox').checked, |
| 345 'wifiCredentialsSynced': syncAll || | 353 'wifiCredentialsSynced': |
| 346 $('wifi-credentials-checkbox').checked, | 354 syncAll || $('wifi-credentials-checkbox').checked, |
| 355 'paymentsIntegrationEnabled': syncAll || |
| 356 (autofillSynced && $('payments-integration-checkbox').checked), |
| 347 'encryptAllData': encryptAllData, | 357 'encryptAllData': encryptAllData, |
| 348 'usePassphrase': usePassphrase, | 358 'usePassphrase': usePassphrase, |
| 349 'isGooglePassphrase': googlePassphrase, | 359 'isGooglePassphrase': googlePassphrase, |
| 350 'passphrase': customPassphrase | 360 'passphrase': customPassphrase |
| 351 }); | 361 }); |
| 352 chrome.send('SyncSetupConfigure', [result]); | 362 chrome.send('SyncSetupConfigure', [result]); |
| 353 }, | 363 }, |
| 354 | 364 |
| 355 /** | 365 /** |
| 356 * Sets the disabled property of all input elements within the 'Customize | 366 * Sets the disabled property of all input elements within the 'Customize |
| 357 * Sync Preferences' screen. This is used to prohibit the user from changing | 367 * Sync Preferences' screen. This is used to prohibit the user from changing |
| 358 * the inputs after confirming the customized sync preferences, or resetting | 368 * the inputs after confirming the customized sync preferences, or resetting |
| 359 * the state when re-showing the dialog. | 369 * the state when re-showing the dialog. |
| 360 * @param {boolean} disabled True if controls should be set to disabled. | 370 * @param {boolean} disabled True if controls should be set to disabled. |
| 361 * @private | 371 * @private |
| 362 */ | 372 */ |
| 363 setInputElementsDisabledState_: function(disabled) { | 373 setInputElementsDisabledState_: function(disabled) { |
| 364 var self = this; | 374 var self = this; |
| 365 var configureElements = | 375 var configureElements = |
| 366 $('customize-sync-preferences').querySelectorAll('input'); | 376 $('customize-sync-preferences').querySelectorAll('input'); |
| 367 for (var i = 0; i < configureElements.length; i++) | 377 for (var i = 0; i < configureElements.length; i++) |
| 368 configureElements[i].disabled = disabled; | 378 configureElements[i].disabled = disabled; |
| 369 $('sync-select-datatypes').disabled = disabled; | 379 $('sync-select-datatypes').disabled = disabled; |
| 380 $('payments-integration-checkbox').disabled = disabled; |
| 370 | 381 |
| 371 $('customize-link').hidden = disabled; | 382 $('customize-link').hidden = disabled; |
| 372 $('customize-link').disabled = disabled; | 383 $('customize-link').disabled = disabled; |
| 373 $('customize-link').onclick = disabled ? null : function() { | 384 $('customize-link').onclick = disabled ? null : function() { |
| 374 SyncSetupOverlay.showCustomizePage(self.syncConfigureArgs_, | 385 SyncSetupOverlay.showCustomizePage(self.syncConfigureArgs_, |
| 375 options.DataTypeSelection.SYNC_EVERYTHING); | 386 options.DataTypeSelection.SYNC_EVERYTHING); |
| 376 return false; | 387 return false; |
| 377 }; | 388 }; |
| 378 }, | 389 }, |
| 379 | 390 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 args.passwordsEnforced; | 424 args.passwordsEnforced; |
| 414 $('passwords-item').hidden = false; | 425 $('passwords-item').hidden = false; |
| 415 } else { | 426 } else { |
| 416 $('passwords-item').hidden = true; | 427 $('passwords-item').hidden = true; |
| 417 } | 428 } |
| 418 if (args.autofillRegistered) { | 429 if (args.autofillRegistered) { |
| 419 $('autofill-checkbox').checked = args.autofillSynced; | 430 $('autofill-checkbox').checked = args.autofillSynced; |
| 420 this.dataTypeBoxesChecked_['autofill-checkbox'] = args.autofillSynced; | 431 this.dataTypeBoxesChecked_['autofill-checkbox'] = args.autofillSynced; |
| 421 this.dataTypeBoxesDisabled_['autofill-checkbox'] = | 432 this.dataTypeBoxesDisabled_['autofill-checkbox'] = |
| 422 args.autofillEnforced; | 433 args.autofillEnforced; |
| 434 this.dataTypeBoxesChecked_['payments-integration-checkbox'] = |
| 435 args.autofillSynced && args.paymentsIntegrationEnabled; |
| 436 this.dataTypeBoxesDisabled_['payments-integration-checkbox'] = |
| 437 !args.autofillSynced; |
| 423 $('autofill-item').hidden = false; | 438 $('autofill-item').hidden = false; |
| 439 $('payments-integration-setting-area').hidden = false; |
| 424 } else { | 440 } else { |
| 425 $('autofill-item').hidden = true; | 441 $('autofill-item').hidden = true; |
| 442 $('payments-integration-setting-area').hidden = true; |
| 426 } | 443 } |
| 427 if (args.extensionsRegistered) { | 444 if (args.extensionsRegistered) { |
| 428 $('extensions-checkbox').checked = args.extensionsSynced; | 445 $('extensions-checkbox').checked = args.extensionsSynced; |
| 429 this.dataTypeBoxesChecked_['extensions-checkbox'] = | 446 this.dataTypeBoxesChecked_['extensions-checkbox'] = |
| 430 args.extensionsSynced; | 447 args.extensionsSynced; |
| 431 this.dataTypeBoxesDisabled_['extensions-checkbox'] = | 448 this.dataTypeBoxesDisabled_['extensions-checkbox'] = |
| 432 args.extensionsEnforced; | 449 args.extensionsEnforced; |
| 433 $('extensions-item').hidden = false; | 450 $('extensions-item').hidden = false; |
| 434 } else { | 451 } else { |
| 435 $('extensions-item').hidden = true; | 452 $('extensions-item').hidden = true; |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 'showSyncSetupPage', | 866 'showSyncSetupPage', |
| 850 'showCustomizePage', | 867 'showCustomizePage', |
| 851 'showStopSyncingUI', | 868 'showStopSyncingUI', |
| 852 ]); | 869 ]); |
| 853 | 870 |
| 854 // Export | 871 // Export |
| 855 return { | 872 return { |
| 856 SyncSetupOverlay: SyncSetupOverlay | 873 SyncSetupOverlay: SyncSetupOverlay |
| 857 }; | 874 }; |
| 858 }); | 875 }); |
| OLD | NEW |