| 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 #include "chrome/browser/ui/webui/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 if (!configuration.passphrase_is_gaia && | 713 if (!configuration.passphrase_is_gaia && |
| 714 !service->IsUsingSecondaryPassphrase()) { | 714 !service->IsUsingSecondaryPassphrase()) { |
| 715 // User passed us a secondary passphrase, and the data is encrypted | 715 // User passed us a secondary passphrase, and the data is encrypted |
| 716 // with a GAIA passphrase so they must want to encrypt. | 716 // with a GAIA passphrase so they must want to encrypt. |
| 717 service->SetEncryptionPassphrase(configuration.passphrase, | 717 service->SetEncryptionPassphrase(configuration.passphrase, |
| 718 ProfileSyncService::EXPLICIT); | 718 ProfileSyncService::EXPLICIT); |
| 719 } | 719 } |
| 720 } | 720 } |
| 721 } | 721 } |
| 722 | 722 |
| 723 bool user_was_prompted_for_passphrase = |
| 724 service->IsPassphraseRequiredForDecryption(); |
| 723 service->OnUserChoseDatatypes(configuration.sync_everything, | 725 service->OnUserChoseDatatypes(configuration.sync_everything, |
| 724 configuration.data_types); | 726 configuration.data_types); |
| 725 | 727 |
| 726 // Need to call IsPassphraseRequiredForDecryption() *after* calling | 728 // Need to call IsPassphraseRequiredForDecryption() *after* calling |
| 727 // OnUserChoseDatatypes() because the user may have just disabled the | 729 // OnUserChoseDatatypes() because the user may have just disabled the |
| 728 // encrypted datatypes. | 730 // encrypted datatypes (in which case we just want to exit, not prompt the |
| 731 // user for a passphrase). |
| 729 if (passphrase_failed || service->IsPassphraseRequiredForDecryption()) { | 732 if (passphrase_failed || service->IsPassphraseRequiredForDecryption()) { |
| 730 // We need a passphrase, or the user's attempt to set a passphrase failed - | 733 // We need a passphrase, or the user's attempt to set a passphrase failed - |
| 731 // prompt them again. | 734 // prompt them again. This covers a few subtle cases: |
| 732 DisplayConfigureSync(true, passphrase_failed); | 735 // 1) The user enters an incorrect passphrase *and* disabled the encrypted |
| 736 // data types. In that case we want to notify the user that the |
| 737 // passphrase was incorrect even though there are no longer any encrypted |
| 738 // types enabled (IsPassphraseRequiredForDecryption() == false). |
| 739 // 2) The user doesn't enter any passphrase. In this case, we won't call |
| 740 // SetDecryptionPassphrase() (passphrase_failed == false), but we still |
| 741 // want to display an error message to let the user know that their |
| 742 // blank passphrase entry is not acceptable. |
| 743 // 3) The user just enabled an encrypted data type - in this case we don't |
| 744 // want to display an "invalid passphrase" error, since it's the first |
| 745 // time the user is seeing the prompt. |
| 746 DisplayConfigureSync( |
| 747 true, passphrase_failed || user_was_prompted_for_passphrase); |
| 733 } else { | 748 } else { |
| 734 // No passphrase is required from the user so mark the configuration as | 749 // No passphrase is required from the user so mark the configuration as |
| 735 // complete and close the sync setup overlay. | 750 // complete and close the sync setup overlay. |
| 736 ConfigureSyncDone(); | 751 ConfigureSyncDone(); |
| 737 } | 752 } |
| 738 | 753 |
| 739 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CUSTOMIZE); | 754 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_CUSTOMIZE); |
| 740 if (configuration.encrypt_all) | 755 if (configuration.encrypt_all) |
| 741 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_ENCRYPT); | 756 ProfileMetrics::LogProfileSyncInfo(ProfileMetrics::SYNC_ENCRYPT); |
| 742 if (configuration.passphrase_is_gaia && !configuration.passphrase.empty()) | 757 if (configuration.passphrase_is_gaia && !configuration.passphrase.empty()) |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 if (i != current_profile_index && AreUserNamesEqual( | 967 if (i != current_profile_index && AreUserNamesEqual( |
| 953 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { | 968 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { |
| 954 *error_message = l10n_util::GetStringUTF16( | 969 *error_message = l10n_util::GetStringUTF16( |
| 955 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 970 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
| 956 return false; | 971 return false; |
| 957 } | 972 } |
| 958 } | 973 } |
| 959 | 974 |
| 960 return true; | 975 return true; |
| 961 } | 976 } |
| OLD | NEW |