| Index: chrome/browser/sync/engine/syncapi.cc
|
| diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
|
| index df7e7f510900a85b4c8d31ed7466a1371f06793e..a371ea0160df0b66a67735f705cce3f7bfa91ec5 100644
|
| --- a/chrome/browser/sync/engine/syncapi.cc
|
| +++ b/chrome/browser/sync/engine/syncapi.cc
|
| @@ -2104,12 +2104,18 @@ void SyncManager::SyncInternal::EncryptDataTypes(
|
| Cryptographer* cryptographer = trans.GetCryptographer();
|
|
|
| if (!cryptographer->is_initialized()) {
|
| - NOTREACHED() << "Attempting to encrypt datatypes when cryptographer not "
|
| - << "initialized.";
|
| + VLOG(1) << "Attempting to encrypt datatypes when cryptographer not "
|
| + << "initialized, prompting for passphrase.";
|
| + ObserverList<SyncManager::Observer> temp_obs_list;
|
| + CopyObservers(&temp_obs_list);
|
| + // TODO(zea): this isn't really decryption, but that's the only way we have
|
| + // to prompt the user for a passsphrase. See http://crbug.com/91379.
|
| + FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
|
| + OnPassphraseRequired(sync_api::REASON_DECRYPTION));
|
| return;
|
| }
|
|
|
| - // Update the Nigori node set of encrypted datatypes so other machines notice.
|
| + // Update the Nigori node's set of encrypted datatypes.
|
| // Note, we merge the current encrypted types with those requested. Once a
|
| // datatypes is marked as needing encryption, it is never unmarked.
|
| sync_pb::NigoriSpecifics nigori;
|
| @@ -2120,8 +2126,14 @@ void SyncManager::SyncInternal::EncryptDataTypes(
|
| encrypted_types.begin(), encrypted_types.end(),
|
| std::inserter(newly_encrypted_types,
|
| newly_encrypted_types.begin()));
|
| - if (newly_encrypted_types == current_encrypted_types)
|
| - return; // Set of encrypted types did not change.
|
| + if (newly_encrypted_types == current_encrypted_types) {
|
| + // Set of encrypted types has not changed, just notify and return.
|
| + ObserverList<SyncManager::Observer> temp_obs_list;
|
| + CopyObservers(&temp_obs_list);
|
| + FOR_EACH_OBSERVER(SyncManager::Observer, temp_obs_list,
|
| + OnEncryptionComplete(current_encrypted_types));
|
| + return;
|
| + }
|
| syncable::FillNigoriEncryptedTypes(newly_encrypted_types, &nigori);
|
| node.SetNigoriSpecifics(nigori);
|
|
|
| @@ -2166,7 +2178,7 @@ void SyncManager::SyncInternal::ReEncryptEverything(WriteTransaction* trans) {
|
| WriteNode child(trans);
|
| if (!child.InitByIdLookup(child_id)) {
|
| NOTREACHED();
|
| - return;
|
| + continue;
|
| }
|
| if (child.GetIsFolder()) {
|
| to_visit.push(child.GetFirstChildId());
|
| @@ -2185,20 +2197,19 @@ void SyncManager::SyncInternal::ReEncryptEverything(WriteTransaction* trans) {
|
| ReadNode passwords_root(trans);
|
| std::string passwords_tag =
|
| syncable::ModelTypeToRootTag(syncable::PASSWORDS);
|
| - if (!passwords_root.InitByTagLookup(passwords_tag)) {
|
| - LOG(WARNING) << "No passwords to reencrypt.";
|
| - return;
|
| - }
|
| -
|
| - int64 child_id = passwords_root.GetFirstChildId();
|
| - while (child_id != kInvalidId) {
|
| - WriteNode child(trans);
|
| - if (!child.InitByIdLookup(child_id)) {
|
| - NOTREACHED();
|
| - return;
|
| + // It's possible we'll have the password routing info and not the password
|
| + // root if we attempted to SetPassphrase before passwords was enabled.
|
| + if (passwords_root.InitByTagLookup(passwords_tag)) {
|
| + int64 child_id = passwords_root.GetFirstChildId();
|
| + while (child_id != kInvalidId) {
|
| + WriteNode child(trans);
|
| + if (!child.InitByIdLookup(child_id)) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| + child.SetPasswordSpecifics(child.GetPasswordSpecifics());
|
| + child_id = child.GetSuccessorId();
|
| }
|
| - child.SetPasswordSpecifics(child.GetPasswordSpecifics());
|
| - child_id = child.GetSuccessorId();
|
| }
|
| }
|
|
|
|
|