Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1092)

Unified Diff: sync/internal_api/sync_encryption_handler_impl.cc

Issue 10917246: [Sync] Add keystore encryption info to about:sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + address comments Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sync/internal_api/sync_encryption_handler_impl.cc
diff --git a/sync/internal_api/sync_encryption_handler_impl.cc b/sync/internal_api/sync_encryption_handler_impl.cc
index 5617df9582b0509aac86a5e5f84a8403e4307dc2..564b1e007d7dc6acdc39662ce0b97ab05cd901c2 100644
--- a/sync/internal_api/sync_encryption_handler_impl.cc
+++ b/sync/internal_api/sync_encryption_handler_impl.cc
@@ -19,6 +19,7 @@
#include "sync/internal_api/public/write_node.h"
#include "sync/internal_api/public/write_transaction.h"
#include "sync/internal_api/public/util/sync_string_conversions.h"
+#include "sync/internal_api/public/util/time.h"
#include "sync/protocol/encryption.pb.h"
#include "sync/protocol/nigori_specifics.pb.h"
#include "sync/protocol/sync.pb.h"
@@ -27,7 +28,6 @@
#include "sync/syncable/entry.h"
#include "sync/syncable/nigori_util.h"
#include "sync/util/cryptographer.h"
-#include "sync/util/time.h"
namespace syncer {
@@ -127,8 +127,7 @@ SyncEncryptionHandlerImpl::SyncEncryptionHandlerImpl(
encrypt_everything_(false),
passphrase_type_(IMPLICIT_PASSPHRASE),
keystore_key_(restored_keystore_key_for_bootstrapping),
- nigori_overwrite_count_(0),
- migration_time_ms_(0) {
+ nigori_overwrite_count_(0) {
// We only bootstrap the user provided passphrase. The keystore key is handled
// at Init time once we're sure the nigori is downloaded.
vault_unsafe_.cryptographer.Bootstrap(restored_key_for_bootstrapping);
@@ -588,6 +587,10 @@ bool SyncEncryptionHandlerImpl::MigratedToKeystore() {
return IsNigoriMigratedToKeystore(nigori_node.GetNigoriSpecifics());
}
+base::Time SyncEncryptionHandlerImpl::migration_time() const {
+ return migration_time_;
+}
+
// This function iterates over all encrypted types. There are many scenarios in
// which data for some or all types is not currently available. In that case,
// the lookup of the root node will fail and we will skip encryption for that
@@ -668,7 +671,8 @@ bool SyncEncryptionHandlerImpl::ApplyNigoriUpdateImpl(
trans);
bool is_nigori_migrated = IsNigoriMigratedToKeystore(nigori);
if (is_nigori_migrated) {
- migration_time_ms_ = nigori.keystore_migration_time();
+ DCHECK(nigori.has_keystore_migration_time());
+ migration_time_ = ProtoTimeToTime(nigori.keystore_migration_time());
PassphraseType nigori_passphrase_type =
ProtoPassphraseTypeToEnum(nigori.passphrase_type());
@@ -1136,10 +1140,7 @@ bool SyncEncryptionHandlerImpl::AttemptToMigrateNigoriToKeystore(
return false;
DVLOG(1) << "Starting nigori migration to keystore support.";
- if (migration_time_ms_ == 0)
- migration_time_ms_ = TimeToProtoTime(base::Time::Now());
sync_pb::NigoriSpecifics migrated_nigori(old_nigori);
- migrated_nigori.set_keystore_migration_time(migration_time_ms_);
PassphraseType new_passphrase_type = passphrase_type_;
bool new_encrypt_everything = encrypt_everything_;
@@ -1183,13 +1184,23 @@ bool SyncEncryptionHandlerImpl::AttemptToMigrateNigoriToKeystore(
return false;
}
+ if (migration_time_.is_null())
+ migration_time_ = base::Time::Now();
+ migrated_nigori.set_keystore_migration_time(TimeToProtoTime(migration_time_));
+
DVLOG(1) << "Completing nigori migration to keystore support.";
nigori_node->SetNigoriSpecifics(migrated_nigori);
+
+ FOR_EACH_OBSERVER(
+ SyncEncryptionHandler::Observer,
+ observers_,
+ OnCryptographerStateChanged(cryptographer));
if (passphrase_type_ != new_passphrase_type) {
passphrase_type_ = new_passphrase_type;
FOR_EACH_OBSERVER(SyncEncryptionHandler::Observer, observers_,
OnPassphraseTypeChanged(passphrase_type_));
}
+
if (new_encrypt_everything && !encrypt_everything_) {
EnableEncryptEverythingImpl(trans->GetWrappedTrans());
ReEncryptEverything(trans);

Powered by Google App Engine
This is Rietveld 408576698