Chromium Code Reviews| 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.define('options', function() { | 5 cr.define('options', function() { |
| 6 const OptionsPage = options.OptionsPage; | 6 /** @const */ var OptionsPage = options.OptionsPage; |
| 7 | 7 |
| 8 // Variable to track if a captcha challenge was issued. If this gets set to | 8 // Variable to track if a captcha challenge was issued. If this gets set to |
| 9 // true, it stays that way until we are told about successful login from | 9 // true, it stays that way until we are told about successful login from |
| 10 // the browser. This means subsequent errors (like invalid password) are | 10 // the browser. This means subsequent errors (like invalid password) are |
| 11 // rendered in the captcha state, which is basically identical except we | 11 // rendered in the captcha state, which is basically identical except we |
| 12 // don't show the top error blurb 'Error Signing in' or the 'Create | 12 // don't show the top error blurb 'Error Signing in' or the 'Create |
| 13 // account' link. | 13 // account' link. |
| 14 var captchaChallengeActive_ = false; | 14 var captchaChallengeActive_ = false; |
| 15 | 15 |
| 16 // True if the synced account uses a custom passphrase. | 16 // True if the synced account uses a custom passphrase. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 showOverlay_: function() { | 67 showOverlay_: function() { |
| 68 OptionsPage.navigateToPage('syncSetup'); | 68 OptionsPage.navigateToPage('syncSetup'); |
| 69 }, | 69 }, |
| 70 | 70 |
| 71 closeOverlay_: function() { | 71 closeOverlay_: function() { |
| 72 OptionsPage.closeOverlay(); | 72 OptionsPage.closeOverlay(); |
| 73 }, | 73 }, |
| 74 | 74 |
| 75 /** @inheritDoc */ | 75 /** @inheritDoc */ |
| 76 didShowPage: function() { | 76 didShowPage: function() { |
| 77 var forceLogin = document.location.hash == "#forceLogin"; | 77 var forceLogin = document.location.hash == '#forceLogin'; |
| 78 var result = JSON.stringify({'forceLogin': forceLogin}); | 78 var result = JSON.stringify({'forceLogin': forceLogin}); |
| 79 chrome.send('SyncSetupAttachHandler', [result]); | 79 chrome.send('SyncSetupAttachHandler', [result]); |
| 80 }, | 80 }, |
| 81 | 81 |
| 82 /** @inheritDoc */ | 82 /** @inheritDoc */ |
| 83 didClosePage: function() { | 83 didClosePage: function() { |
| 84 chrome.send('SyncSetupDidClosePage'); | 84 chrome.send('SyncSetupDidClosePage'); |
| 85 }, | 85 }, |
| 86 | 86 |
|
Dan Beam
2012/04/05 22:24:13
none of these are doc'd?!
| |
| 87 getEncryptionRadioCheckedValue_: function() { | 87 getEncryptionRadioCheckedValue_: function() { |
| 88 var f = $('choose-data-types-form'); | 88 var f = $('choose-data-types-form'); |
| 89 for (var i = 0; i < f.encrypt.length; ++i) { | 89 for (var i = 0; i < f.encrypt.length; ++i) { |
| 90 if (f.encrypt[i].checked) | 90 if (f.encrypt[i].checked) |
| 91 return f.encrypt[i].value; | 91 return f.encrypt[i].value; |
| 92 } | 92 } |
| 93 | 93 |
| 94 return undefined; | 94 return undefined; |
|
Dan Beam
2012/04/05 22:24:13
wat?!
| |
| 95 }, | 95 }, |
| 96 | 96 |
| 97 getPassphraseRadioCheckedValue_: function() { | 97 getPassphraseRadioCheckedValue_: function() { |
| 98 var f = $('choose-data-types-form'); | 98 var f = $('choose-data-types-form'); |
| 99 for (var i = 0; i < f.option.length; ++i) { | 99 for (var i = 0; i < f.option.length; ++i) { |
| 100 if (f.option[i].checked) { | 100 if (f.option[i].checked) { |
| 101 return f.option[i].value; | 101 return f.option[i].value; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 return undefined; | 105 return undefined; |
|
Dan Beam
2012/04/05 22:24:13
ugh
| |
| 106 }, | 106 }, |
| 107 | 107 |
| 108 disableEncryptionRadioGroup_: function() { | 108 disableEncryptionRadioGroup_: function() { |
| 109 var f = $('choose-data-types-form'); | 109 var f = $('choose-data-types-form'); |
| 110 for (var i = 0; i < f.encrypt.length; ++i) | 110 for (var i = 0; i < f.encrypt.length; ++i) |
| 111 f.encrypt[i].disabled = true; | 111 f.encrypt[i].disabled = true; |
| 112 }, | 112 }, |
| 113 | 113 |
| 114 onPassphraseRadioChanged_: function() { | 114 onPassphraseRadioChanged_: function() { |
| 115 var visible = this.getPassphraseRadioCheckedValue_() == 'explicit'; | 115 var visible = this.getPassphraseRadioCheckedValue_() == 'explicit'; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 usePassphrase = false; | 212 usePassphrase = false; |
| 213 } | 213 } |
| 214 | 214 |
| 215 // Don't allow the user to tweak the settings once we send the | 215 // Don't allow the user to tweak the settings once we send the |
| 216 // configuration to the backend. | 216 // configuration to the backend. |
| 217 this.setInputElementsDisabledState_(true); | 217 this.setInputElementsDisabledState_(true); |
| 218 this.animateDisableLink_($('use-default-link'), true, null); | 218 this.animateDisableLink_($('use-default-link'), true, null); |
| 219 | 219 |
| 220 // These values need to be kept in sync with where they are read in | 220 // These values need to be kept in sync with where they are read in |
| 221 // SyncSetupFlow::GetDataTypeChoiceData(). | 221 // SyncSetupFlow::GetDataTypeChoiceData(). |
| 222 var result = JSON.stringify({ | 222 var result = JSON.stringify({ |
|
Dan Beam
2012/04/05 22:24:13
this is needlessly encoded to JSON twice?! </vent>
| |
| 223 'syncAllDataTypes': syncAll, | 223 'syncAllDataTypes': syncAll, |
| 224 'sync_bookmarks': syncAll || $('bookmarks-checkbox').checked, | 224 'sync_bookmarks': syncAll || $('bookmarks-checkbox').checked, |
| 225 'sync_preferences': syncAll || $('preferences-checkbox').checked, | 225 'sync_preferences': syncAll || $('preferences-checkbox').checked, |
| 226 'sync_themes': syncAll || $('themes-checkbox').checked, | 226 'sync_themes': syncAll || $('themes-checkbox').checked, |
| 227 'sync_passwords': syncAll || $('passwords-checkbox').checked, | 227 'sync_passwords': syncAll || $('passwords-checkbox').checked, |
| 228 'sync_autofill': syncAll || $('autofill-checkbox').checked, | 228 'sync_autofill': syncAll || $('autofill-checkbox').checked, |
| 229 'sync_extensions': syncAll || $('extensions-checkbox').checked, | 229 'sync_extensions': syncAll || $('extensions-checkbox').checked, |
| 230 'sync_typed_urls': syncAll || $('typed-urls-checkbox').checked, | 230 'sync_typed_urls': syncAll || $('typed-urls-checkbox').checked, |
| 231 'sync_apps': syncAll || $('apps-checkbox').checked, | 231 'sync_apps': syncAll || $('apps-checkbox').checked, |
| 232 'sync_sessions': syncAll || $('sessions-checkbox').checked, | 232 'sync_sessions': syncAll || $('sessions-checkbox').checked, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 $('sessions-checkbox').checked = args.sync_sessions; | 327 $('sessions-checkbox').checked = args.sync_sessions; |
| 328 $('sessions-item').hidden = false; | 328 $('sessions-item').hidden = false; |
| 329 } else { | 329 } else { |
| 330 $('sessions-item').hidden = true; | 330 $('sessions-item').hidden = true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 this.setCheckboxesToKeepEverythingSynced_(args.syncAllDataTypes); | 333 this.setCheckboxesToKeepEverythingSynced_(args.syncAllDataTypes); |
| 334 }, | 334 }, |
| 335 | 335 |
| 336 setEncryptionRadios_: function(args) { | 336 setEncryptionRadios_: function(args) { |
| 337 if (args['encryptAllData']) { | 337 if (args['encryptAllData']) { |
|
Dan Beam
2012/04/05 22:24:13
better to use . instead of [], :(
| |
| 338 $('encrypt-all-option').checked = true; | 338 $('encrypt-all-option').checked = true; |
| 339 this.disableEncryptionRadioGroup_(); | 339 this.disableEncryptionRadioGroup_(); |
| 340 } else { | 340 } else { |
| 341 $('encrypt-sensitive-option').checked = true; | 341 $('encrypt-sensitive-option').checked = true; |
| 342 } | 342 } |
| 343 }, | 343 }, |
| 344 | 344 |
| 345 setPassphraseRadios_: function(args) { | 345 setPassphraseRadios_: function(args) { |
| 346 if (args['usePassphrase']) { | 346 if (args['usePassphrase']) { |
| 347 $('explicit-option').checked = true; | 347 $('explicit-option').checked = true; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 // Warn the user about their incorrect passphrase if we need a passphrase | 456 // Warn the user about their incorrect passphrase if we need a passphrase |
| 457 // and the passphrase field is non-empty (meaning they tried to set it | 457 // and the passphrase field is non-empty (meaning they tried to set it |
| 458 // previously but failed). | 458 // previously but failed). |
| 459 $('incorrect-passphrase').hidden = | 459 $('incorrect-passphrase').hidden = |
| 460 !(args['usePassphrase'] && args['passphrase_failed']); | 460 !(args['usePassphrase'] && args['passphrase_failed']); |
| 461 | 461 |
| 462 $('sync-passphrase-warning').hidden = false; | 462 $('sync-passphrase-warning').hidden = false; |
| 463 $('passphrase').focus(); | 463 $('passphrase').focus(); |
| 464 }, | 464 }, |
| 465 | 465 |
| 466 /** @private */ | 466 /** @private */ |
|
Dan Beam
2012/04/05 22:24:13
not enough doc!
| |
| 467 showCustomizePage_: function(args, syncEverything) { | 467 showCustomizePage_: function(args, syncEverything) { |
| 468 $('confirm-sync-preferences').hidden = true; | 468 $('confirm-sync-preferences').hidden = true; |
| 469 $('customize-sync-preferences').hidden = false; | 469 $('customize-sync-preferences').hidden = false; |
| 470 | 470 |
| 471 $('sync-custom-passphrase-container').hidden = false; | 471 $('sync-custom-passphrase-container').hidden = false; |
| 472 $('sync-existing-passphrase-container').hidden = true; | 472 $('sync-existing-passphrase-container').hidden = true; |
| 473 | 473 |
| 474 // If the user has selected the 'Customize' page on initial set up, it's | 474 // If the user has selected the 'Customize' page on initial set up, it's |
| 475 // likely he intends to change the data types. Select the | 475 // likely he intends to change the data types. Select the |
| 476 // 'Choose data types' option in this case. | 476 // 'Choose data types' option in this case. |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 }; | 878 }; |
| 879 | 879 |
| 880 SyncSetupOverlay.showStopSyncingUI = function() { | 880 SyncSetupOverlay.showStopSyncingUI = function() { |
| 881 SyncSetupOverlay.getInstance().showStopSyncingUI_(); | 881 SyncSetupOverlay.getInstance().showStopSyncingUI_(); |
| 882 }; | 882 }; |
| 883 | 883 |
| 884 // Export | 884 // Export |
| 885 return { | 885 return { |
| 886 SyncSetupOverlay: SyncSetupOverlay | 886 SyncSetupOverlay: SyncSetupOverlay |
| 887 }; | 887 }; |
| 888 }); | 888 }); |
|
Dan Beam
2012/04/05 22:24:13
tl;dr too much pain
| |
| OLD | NEW |