| Index: chrome/browser/sync/engine/syncapi.cc
|
| ===================================================================
|
| --- chrome/browser/sync/engine/syncapi.cc (revision 98772)
|
| +++ chrome/browser/sync/engine/syncapi.cc (working copy)
|
| @@ -1927,7 +1927,6 @@
|
|
|
| allstatus_.SetCryptographerReady(cryptographer->is_ready());
|
| allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys());
|
| - allstatus_.SetEncryptedTypes(cryptographer->GetEncryptedTypes());
|
|
|
| return cryptographer->is_ready();
|
| }
|
| @@ -2115,12 +2114,9 @@
|
| cryptographer->GetKeys(specifics.mutable_encrypted());
|
| specifics.set_using_explicit_passphrase(is_explicit);
|
| node.SetNigoriSpecifics(specifics);
|
| + ReEncryptEverything(&trans);
|
| }
|
|
|
| - // Does nothing if everything is already encrypted or the cryptographer has
|
| - // pending keys.
|
| - ReEncryptEverything(&trans);
|
| -
|
| VLOG(1) << "Passphrase accepted, bootstrapping encryption.";
|
| std::string bootstrap_token;
|
| cryptographer->GetBootstrapToken(&bootstrap_token);
|
| @@ -2158,7 +2154,7 @@
|
|
|
| Cryptographer* cryptographer = trans.GetCryptographer();
|
|
|
| - if (!cryptographer->is_ready()) {
|
| + if (!cryptographer->is_initialized()) {
|
| VLOG(1) << "Attempting to encrypt datatypes when cryptographer not "
|
| << "initialized, prompting for passphrase.";
|
| ObserverList<SyncManager::Observer> temp_obs_list;
|
| @@ -2182,13 +2178,22 @@
|
| std::inserter(newly_encrypted_types,
|
| newly_encrypted_types.begin()));
|
| allstatus_.SetEncryptedTypes(newly_encrypted_types);
|
| + 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);
|
|
|
| cryptographer->SetEncryptedTypes(nigori);
|
|
|
| - // We reencrypt everything regardless of whether the set of encrypted
|
| - // types changed to ensure that any stray unencrypted entries are overwritten.
|
| + // TODO(zea): only reencrypt this datatype? ReEncrypting everything is a
|
| + // safer approach, and should not impact anything that is already encrypted
|
| + // (redundant changes are ignored).
|
| ReEncryptEverything(&trans);
|
| return;
|
| }
|
| @@ -2196,10 +2201,8 @@
|
| // TODO(zea): Add unit tests that ensure no sync changes are made when not
|
| // needed.
|
| void SyncManager::SyncInternal::ReEncryptEverything(WriteTransaction* trans) {
|
| - Cryptographer* cryptographer = trans->GetCryptographer();
|
| - if (!cryptographer || !cryptographer->is_ready())
|
| - return;
|
| - syncable::ModelTypeSet encrypted_types = GetEncryptedTypes(trans);
|
| + syncable::ModelTypeSet encrypted_types =
|
| + GetEncryptedTypes(trans);
|
| ModelSafeRoutingInfo routes;
|
| registrar_->GetModelSafeRoutingInfo(&routes);
|
| std::string tag;
|
|
|