Chromium Code Reviews| Index: chrome/browser/resources/options/sync_setup_overlay.js |
| diff --git a/chrome/browser/resources/options/sync_setup_overlay.js b/chrome/browser/resources/options/sync_setup_overlay.js |
| index 0af88fa5268e320526ebb5c6f5cc8e595974202e..5ba73991d69013ae3d6033f6202d849534011da7 100644 |
| --- a/chrome/browser/resources/options/sync_setup_overlay.js |
| +++ b/chrome/browser/resources/options/sync_setup_overlay.js |
| @@ -94,13 +94,6 @@ cr.define('options', function() { |
| chrome.send('SyncSetupDidClosePage'); |
| }, |
| - sendPassphraseAndClose_: function() { |
| - var f = $('choose-data-types-form'); |
| - var result = JSON.stringify({"passphrase": f.passphrase.value}); |
| - chrome.send('SyncSetupPassphrase', [result]); |
| - return false; |
| - }, |
| - |
| getEncryptionRadioCheckedValue_: function() { |
| var f = $('choose-data-types-form'); |
| for (var i = 0; i < f.encrypt.length; ++i) { |
| @@ -192,8 +185,9 @@ cr.define('options', function() { |
| var f = $('choose-data-types-form'); |
| if (this.getPassphraseRadioCheckedValue_() != "explicit" || |
| - f.option[0].disabled) |
| + $('google-option').disabled) { |
| return true; |
| + } |
| var customPassphrase = $('custom-passphrase'); |
| if (customPassphrase.value.length == 0) { |
| @@ -221,8 +215,10 @@ cr.define('options', function() { |
| } |
| var f = $('choose-data-types-form'); |
| - if (!this.checkPassphraseMatch_()) |
| + // Must be done before we disable input elements. |
| + if (!this.checkPassphraseMatch_()) { |
|
James Hawkins
2011/07/21 19:20:09
No braces for single-line logic blocks, here and e
Nicolas Zea
2011/07/21 19:34:57
Done.
|
| return; |
| + } |
| // Don't allow the user to tweak the settings once we send the |
| // configuration to the backend. |
| @@ -233,6 +229,21 @@ cr.define('options', function() { |
| var usePassphrase = this.getPassphraseRadioCheckedValue_() == 'explicit'; |
| var encryptAllData = this.getEncryptionRadioCheckedValue_() == 'all'; |
| + var customPassphrase = ""; |
|
James Hawkins
2011/07/21 19:20:09
No need to initialize to empty string.
Nicolas Zea
2011/07/21 19:34:57
Done.
|
| + if (!$('sync-existing-passphrase-container').hidden) { |
| + // We were prompted for an existing passphrase, use it. |
| + customPassphrase = f.passphrase.value; |
| + } else { |
| + customPassphrase = $('custom-passphrase').value; |
| + } |
| + |
| + // If the user has not actually entered a passphrase (for example on |
| + // customize when the passphrase box is hidden), we don't attempt to reset |
| + // the passphrase. |
| + if (customPassphrase.length == 0) { |
| + usePassphrase = false; |
| + } |
| + |
| // These values need to be kept in sync with where they are read in |
| // SyncSetupFlow::GetDataTypeChoiceData(). |
| var result = JSON.stringify({ |
| @@ -248,7 +259,7 @@ cr.define('options', function() { |
| "syncSessions": syncAll || $('sessions-checkbox').checked, |
| "encryptAllData": encryptAllData, |
| "usePassphrase": usePassphrase, |
| - "passphrase": $('custom-passphrase').value |
| + "passphrase": customPassphrase |
| }); |
| chrome.send('SyncSetupConfigure', [result]); |
| }, |
| @@ -446,16 +457,14 @@ cr.define('options', function() { |
| }, |
| /** |
| - * Reveals the UI for entering a custom passphrase after initial setup. This |
| - * may happen if the user forgot to enter the correct (or any) custom |
| - * passphrase during initial setup. |
| + * Reveals the UI for entering a custom passphrase during initial setup. |
| + * This happens if the user has previously enabled a custom passphrase on a |
| + * different machine. |
| * @param {Array} args The args that contain the passphrase UI |
| * configuration. |
| * @private |
| */ |
| showPassphraseContainer_: function(args) { |
| - $('choose-data-types-form').onsubmit = |
| - this.sendPassphraseAndClose_.bind(this); |
| $('sync-custom-passphrase-container').hidden = true; |
| $('sync-existing-passphrase-container').hidden = false; |