diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-19 04:12:18 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-19 04:12:18 +0000 |
commit | f7f6100c83efab633fd95ead88dad16d6cde0cd7 (patch) | |
tree | c2b9aa312b54f37fa5c4a7705c6d381f02508946 /sync | |
parent | 8bc8d498b83137e38df86e194fba0a85dcc63d97 (diff) | |
download | chromium_src-f7f6100c83efab633fd95ead88dad16d6cde0cd7.zip chromium_src-f7f6100c83efab633fd95ead88dad16d6cde0cd7.tar.gz chromium_src-f7f6100c83efab633fd95ead88dad16d6cde0cd7.tar.bz2 |
[Sync] Add keystore encryption info to about:sync
This patch adds the following fields under the encryption section of about:sync
- Has Keystore Key: whether the encryption handler has a keystore encryption key
- Migration Time: the time migration was performed, or "Not Migrated" if
migration hasn't been performed yet
- Passphrase Type: the actual passphrase type (provides more detail than
Is Using Explicit Passphrase, but stored at a diff layer)
Added sync/api/time.h, which just includes sync/util/time.h but is accessible
from chrome/
BUG=129665
Review URL: https://chromiumcodereview.appspot.com/10917246
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157499 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/api/DEPS | 2 | ||||
-rw-r--r-- | sync/api/time.h | 13 | ||||
-rw-r--r-- | sync/engine/all_status.cc | 15 | ||||
-rw-r--r-- | sync/engine/all_status.h | 3 | ||||
-rw-r--r-- | sync/internal_api/public/engine/sync_status.cc | 4 | ||||
-rw-r--r-- | sync/internal_api/public/engine/sync_status.h | 4 | ||||
-rw-r--r-- | sync/internal_api/sync_encryption_handler_impl.cc | 23 | ||||
-rw-r--r-- | sync/internal_api/sync_encryption_handler_impl.h | 9 | ||||
-rw-r--r-- | sync/internal_api/sync_encryption_handler_impl_unittest.cc | 75 | ||||
-rw-r--r-- | sync/internal_api/sync_manager_impl.cc | 11 | ||||
-rw-r--r-- | sync/sync.gyp | 1 |
11 files changed, 113 insertions, 47 deletions
diff --git a/sync/api/DEPS b/sync/api/DEPS index f6dca6a..c3b8bac 100644 --- a/sync/api/DEPS +++ b/sync/api/DEPS @@ -2,5 +2,5 @@ include_rules = [ "+sync/internal_api/base_node.h", "+sync/internal_api/public", "+sync/protocol", - "+sync/util/immutable.h", + "+sync/util", ] diff --git a/sync/api/time.h b/sync/api/time.h new file mode 100644 index 0000000..5df108b --- /dev/null +++ b/sync/api/time.h @@ -0,0 +1,13 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Publicly accessible header for time-related sync functions. +// See sync/util/time.h for implemenation. + +#ifndef SYNC_API_TIME_H_ +#define SYNC_API_TIME_H_ + +#include "sync/util/time.h" + +#endif // SYNC_API_TIME_H_ diff --git a/sync/engine/all_status.cc b/sync/engine/all_status.cc index 3df6c29..656d6e0 100644 --- a/sync/engine/all_status.cc +++ b/sync/engine/all_status.cc @@ -154,6 +154,21 @@ void AllStatus::SetCryptoHasPendingKeys(bool has_pending_keys) { status_.crypto_has_pending_keys = has_pending_keys; } +void AllStatus::SetPassphraseType(PassphraseType type) { + ScopedStatusLock lock(this); + status_.passphrase_type = type; +} + +void AllStatus::SetHasKeystoreKey(bool has_keystore_key) { + ScopedStatusLock lock(this); + status_.has_keystore_key = has_keystore_key; +} + +void AllStatus::SetKeystoreMigrationTime(const base::Time& migration_time) { + ScopedStatusLock lock(this); + status_.keystore_migration_time = migration_time; +} + void AllStatus::SetUniqueId(const std::string& guid) { ScopedStatusLock lock(this); status_.unique_id = guid; diff --git a/sync/engine/all_status.h b/sync/engine/all_status.h index e350f57..9649a35 100644 --- a/sync/engine/all_status.h +++ b/sync/engine/all_status.h @@ -53,6 +53,9 @@ class AllStatus : public SyncEngineEventListener { void SetEncryptedTypes(ModelTypeSet types); void SetCryptographerReady(bool ready); void SetCryptoHasPendingKeys(bool has_pending_keys); + void SetPassphraseType(PassphraseType type); + void SetHasKeystoreKey(bool has_keystore_key); + void SetKeystoreMigrationTime(const base::Time& migration_time); void SetUniqueId(const std::string& guid); diff --git a/sync/internal_api/public/engine/sync_status.cc b/sync/internal_api/public/engine/sync_status.cc index 9ed3bf3..4018a74 100644 --- a/sync/internal_api/public/engine/sync_status.cc +++ b/sync/internal_api/public/engine/sync_status.cc @@ -30,7 +30,9 @@ SyncStatus::SyncStatus() useless_sync_cycles(0), useful_sync_cycles(0), cryptographer_ready(false), - crypto_has_pending_keys(false) { + crypto_has_pending_keys(false), + has_keystore_key(false), + passphrase_type(IMPLICIT_PASSPHRASE) { } SyncStatus::~SyncStatus() { diff --git a/sync/internal_api/public/engine/sync_status.h b/sync/internal_api/public/engine/sync_status.h index dfd9603..3b9229f 100644 --- a/sync/internal_api/public/engine/sync_status.h +++ b/sync/internal_api/public/engine/sync_status.h @@ -9,6 +9,7 @@ #include "sync/base/sync_export.h" #include "sync/internal_api/public/base/model_type.h" +#include "sync/internal_api/public/sync_encryption_handler.h" #include "sync/protocol/sync_protocol_error.h" namespace syncer { @@ -84,6 +85,9 @@ struct SYNC_EXPORT SyncStatus { ModelTypeSet encrypted_types; bool cryptographer_ready; bool crypto_has_pending_keys; + bool has_keystore_key; + base::Time keystore_migration_time; + PassphraseType passphrase_type; // Per-datatype throttled status. ModelTypeSet throttled_types; diff --git a/sync/internal_api/sync_encryption_handler_impl.cc b/sync/internal_api/sync_encryption_handler_impl.cc index c8e26d2..2f15348 100644 --- a/sync/internal_api/sync_encryption_handler_impl.cc +++ b/sync/internal_api/sync_encryption_handler_impl.cc @@ -128,8 +128,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); @@ -594,6 +593,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 @@ -674,7 +677,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()); @@ -1142,10 +1146,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_; @@ -1189,13 +1190,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); diff --git a/sync/internal_api/sync_encryption_handler_impl.h b/sync/internal_api/sync_encryption_handler_impl.h index f54055b..27f7080 100644 --- a/sync/internal_api/sync_encryption_handler_impl.h +++ b/sync/internal_api/sync_encryption_handler_impl.h @@ -9,6 +9,7 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" +#include "base/time.h" #include "base/threading/thread_checker.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" @@ -62,9 +63,6 @@ class SyncEncryptionHandlerImpl virtual bool EncryptEverythingEnabled() const OVERRIDE; virtual PassphraseType GetPassphraseType() const OVERRIDE; - // TODO(zea): provide a method for getting the time at which the nigori - // node was migrated. - // NigoriHandler implementation. // Note: all methods are invoked while the caller holds a transaction. virtual void ApplyNigoriUpdate( @@ -88,6 +86,7 @@ class SyncEncryptionHandlerImpl ModelTypeSet GetEncryptedTypesUnsafe(); bool MigratedToKeystore(); + base::Time migration_time() const; private: FRIEND_TEST_ALL_PREFIXES(SyncEncryptionHandlerImplTest, @@ -287,8 +286,8 @@ class SyncEncryptionHandlerImpl // instantiation. int nigori_overwrite_count_; - // The time (in ms) the nigori was migrated to support keystore encryption. - int64 migration_time_ms_; + // The time the nigori was migrated to support keystore encryption. + base::Time migration_time_; DISALLOW_COPY_AND_ASSIGN(SyncEncryptionHandlerImpl); }; diff --git a/sync/internal_api/sync_encryption_handler_impl_unittest.cc b/sync/internal_api/sync_encryption_handler_impl_unittest.cc index b07c1fe..aa9b9de 100644 --- a/sync/internal_api/sync_encryption_handler_impl_unittest.cc +++ b/sync/internal_api/sync_encryption_handler_impl_unittest.cc @@ -32,6 +32,7 @@ namespace syncer { namespace { using ::testing::_; +using ::testing::AnyNumber; using ::testing::Mock; using ::testing::SaveArg; using ::testing::StrictMock; @@ -384,7 +385,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldNigori) { current_nigori_specifics.mutable_encryption_keybag()); current_nigori_specifics.set_encrypt_everything(true); - EXPECT_CALL(*observer(), OnCryptographerStateChanged(_)); + EXPECT_CALL(*observer(), OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged( HasModelTypes(UserTypes()), true)); { @@ -401,7 +402,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldNigori) { sync_pb::NigoriSpecifics old_nigori; other_cryptographer.GetKeys(old_nigori.mutable_encryption_keybag()); - EXPECT_CALL(*observer(), OnCryptographerStateChanged(_)); + EXPECT_CALL(*observer(), OnCryptographerStateChanged(_)).Times(AnyNumber()); { // Update the encryption handler. WriteTransaction trans(FROM_HERE, user_share()); @@ -512,7 +513,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnDecryptImplicitPass) { nigori.set_keybag_is_frozen(false); nigori.set_encrypt_everything(false); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnPassphraseRequired(_, _)); encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans()); @@ -524,7 +525,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnDecryptImplicitPass) { Mock::VerifyAndClearExpectations(observer()); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnPassphraseAccepted()); EXPECT_CALL(*observer(), @@ -568,7 +569,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnDecryptCustomPass) { nigori.set_keybag_is_frozen(true); nigori.set_encrypt_everything(false); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnPassphraseRequired(_, _)); EXPECT_CALL(*observer(), @@ -582,7 +583,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnDecryptCustomPass) { Mock::VerifyAndClearExpectations(observer()); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnPassphraseAccepted()); EXPECT_CALL(*observer(), @@ -606,7 +607,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnKeystoreKeyAvailableImplicit) { KeyParams current_key = {"localhost", "dummy", kCurKey}; GetCryptographer()->AddKey(current_key); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, false)); EXPECT_CALL(*observer(), @@ -618,6 +619,8 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnKeystoreKeyAvailableImplicit) { ReadTransaction trans(FROM_HERE, user_share()); // Once we provide a keystore key, we should perform the migration. EXPECT_CALL(*observer(), + OnCryptographerStateChanged(_)).Times(AnyNumber()); + EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN)); encryption_handler()->SetKeystoreKey(kRawKeystoreKey, trans.GetWrappedTrans()); @@ -642,7 +645,7 @@ TEST_F(SyncEncryptionHandlerImplTest, KeyParams current_key = {"localhost", "dummy", kCurKey}; GetCryptographer()->AddKey(current_key); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, false)); EXPECT_CALL(*observer(), @@ -660,6 +663,8 @@ TEST_F(SyncEncryptionHandlerImplTest, ReadTransaction trans(FROM_HERE, user_share()); // Once we provide a keystore key, we should perform the migration. EXPECT_CALL(*observer(), + OnCryptographerStateChanged(_)).Times(AnyNumber()); + EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN)); encryption_handler()->SetKeystoreKey(kRawKeystoreKey, trans.GetWrappedTrans()); @@ -682,7 +687,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnKeystoreKeyAvailableCustomWithEncryption) { const char kCurKey[] = "cur"; EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)).Times(2); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnPassphraseRequired(_, _)); EXPECT_CALL(*observer(), @@ -710,6 +715,8 @@ TEST_F(SyncEncryptionHandlerImplTest, ReadTransaction trans(FROM_HERE, user_share()); // Once we provide a keystore key, we should perform the migration. EXPECT_CALL(*observer(), + OnCryptographerStateChanged(_)).Times(AnyNumber()); + EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN)); encryption_handler()->SetKeystoreKey(kRawKeystoreKey, trans.GetWrappedTrans()); @@ -730,7 +737,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnKeystoreKeyAvailableCustomNoEncryption) { const char kCurKey[] = "cur"; EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)).Times(2); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnPassphraseRequired(_, _)); EXPECT_CALL(*observer(), @@ -751,6 +758,8 @@ TEST_F(SyncEncryptionHandlerImplTest, ReadTransaction trans(FROM_HERE, user_share()); // Once we provide a keystore key, we should perform the migration. EXPECT_CALL(*observer(), + OnCryptographerStateChanged(_)).Times(AnyNumber()); + EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN)); encryption_handler()->SetKeystoreKey(kRawKeystoreKey, trans.GetWrappedTrans()); @@ -808,7 +817,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriKeystorePass) { EXPECT_CALL(*observer(), OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)).Times(2); + OnCryptographerStateChanged(_)).Times(AnyNumber()); encryption_handler()->SetKeystoreKey(kRawKeystoreKey, trans.GetWrappedTrans()); encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans()); @@ -864,7 +873,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriFrozenImplicitPass) { EXPECT_CALL(*observer(), OnPassphraseRequired(_, _)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, true)); WriteTransaction trans(FROM_HERE, user_share()); @@ -893,7 +902,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriFrozenImplicitPass) { EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptionComplete()); EXPECT_CALL(*observer(), @@ -943,7 +952,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriCustomPass) { EXPECT_CALL(*observer(), OnPassphraseRequired(_, _)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, true)); WriteTransaction trans(FROM_HERE, user_share()); @@ -970,7 +979,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriCustomPass) { EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptionComplete()); EXPECT_CALL(*observer(), @@ -1023,7 +1032,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveUnmigratedNigoriAfterMigration) { EXPECT_CALL(*observer(), OnPassphraseTypeChanged(CUSTOM_PASSPHRASE)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, true)).Times(2); EXPECT_CALL(*observer(), @@ -1047,7 +1056,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveUnmigratedNigoriAfterMigration) { // Now build an old unmigrated nigori node with old encrypted types. We should // properly overwrite it with the migrated + encrypt everything state. EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); { Cryptographer other_cryptographer(GetCryptographer()->encryptor()); other_cryptographer.AddKey(old_key); @@ -1101,7 +1110,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldMigratedNigori) { EXPECT_CALL(*observer(), OnPassphraseTypeChanged(CUSTOM_PASSPHRASE)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, true)).Times(2); EXPECT_CALL(*observer(), @@ -1125,7 +1134,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldMigratedNigori) { // Now build an old keystore nigori node with old encrypted types. We should // properly overwrite it with the migrated + encrypt everything state. EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); { WriteTransaction trans(FROM_HERE, user_share()); WriteNode nigori_node(&trans); @@ -1190,7 +1199,7 @@ TEST_F(SyncEncryptionHandlerImplTest, SetKeystoreAfterReceivingMigratedNigori) { EXPECT_CALL(*observer(), OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnPassphraseRequired(_, _)); encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans()); @@ -1205,7 +1214,7 @@ TEST_F(SyncEncryptionHandlerImplTest, SetKeystoreAfterReceivingMigratedNigori) { Mock::VerifyAndClearExpectations(observer()); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); { @@ -1275,7 +1284,7 @@ TEST_F(SyncEncryptionHandlerImplTest, SetCustomPassAfterMigration) { EXPECT_CALL(*observer(), OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)).Times(2); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, false)); EXPECT_CALL(*observer(), @@ -1291,7 +1300,7 @@ TEST_F(SyncEncryptionHandlerImplTest, SetCustomPassAfterMigration) { const char kNewKey[] = "new_key"; EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnPassphraseTypeChanged(CUSTOM_PASSPHRASE)); EXPECT_CALL(*observer(), @@ -1372,7 +1381,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EXPECT_CALL(*observer(), OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, false)); encryption_handler()->Init(); @@ -1385,7 +1394,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EXPECT_CALL(*observer(), OnPassphraseAccepted()); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); EXPECT_CALL(*observer(), @@ -1397,7 +1406,7 @@ TEST_F(SyncEncryptionHandlerImplTest, const char kNewKey[] = "new_key"; EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnPassphraseTypeChanged(CUSTOM_PASSPHRASE)); EXPECT_CALL(*observer(), @@ -1478,7 +1487,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EXPECT_CALL(*observer(), OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, false)); encryption_handler()->Init(); @@ -1491,7 +1500,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EXPECT_CALL(*observer(), OnPassphraseAccepted()); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); EXPECT_CALL(*observer(), @@ -1572,7 +1581,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EXPECT_CALL(*observer(), OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE)); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, false)); encryption_handler()->Init(); @@ -1585,7 +1594,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EXPECT_CALL(*observer(), OnPassphraseAccepted()); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); EXPECT_CALL(*observer(), @@ -1599,6 +1608,8 @@ TEST_F(SyncEncryptionHandlerImplTest, OnEncryptionComplete()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, true)); + EXPECT_CALL(*observer(), + OnCryptographerStateChanged(_)).Times(AnyNumber()); encryption_handler()->EnableEncryptEverything(); Mock::VerifyAndClearExpectations(observer()); @@ -1642,7 +1653,7 @@ TEST_F(SyncEncryptionHandlerImplTest, EXPECT_TRUE(other_cryptographer.is_ready()); EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); EXPECT_CALL(*observer(), OnEncryptedTypesChanged(_, false)); EXPECT_CALL(*observer(), @@ -1668,7 +1679,7 @@ TEST_F(SyncEncryptionHandlerImplTest, // Now build an old keystore passphrase nigori node. EXPECT_CALL(*observer(), - OnCryptographerStateChanged(_)); + OnCryptographerStateChanged(_)).Times(AnyNumber()); { WriteTransaction trans(FROM_HERE, user_share()); WriteNode nigori_node(&trans); diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc index 5e0a0c3..20852f4 100644 --- a/sync/internal_api/sync_manager_impl.cc +++ b/sync/internal_api/sync_manager_impl.cc @@ -383,6 +383,8 @@ void SyncManagerImpl::Init( unrecoverable_error_handler_ = unrecoverable_error_handler; report_unrecoverable_error_function_ = report_unrecoverable_error_function; + allstatus_.SetHasKeystoreKey( + !restored_keystore_key_for_bootstrapping.empty()); sync_encryption_handler_.reset(new SyncEncryptionHandlerImpl( &share_, encryptor, @@ -534,7 +536,8 @@ void SyncManagerImpl::OnPassphraseAccepted() { void SyncManagerImpl::OnBootstrapTokenUpdated( const std::string& bootstrap_token, BootstrapTokenType type) { - // Does nothing. + if (type == KEYSTORE_BOOTSTRAP_TOKEN) + allstatus_.SetHasKeystoreKey(true); } void SyncManagerImpl::OnEncryptedTypesChanged(ModelTypeSet encrypted_types, @@ -550,10 +553,14 @@ void SyncManagerImpl::OnCryptographerStateChanged( Cryptographer* cryptographer) { allstatus_.SetCryptographerReady(cryptographer->is_ready()); allstatus_.SetCryptoHasPendingKeys(cryptographer->has_pending_keys()); + allstatus_.SetKeystoreMigrationTime( + sync_encryption_handler_->migration_time()); } void SyncManagerImpl::OnPassphraseTypeChanged(PassphraseType type) { - // Does nothing. + allstatus_.SetPassphraseType(type); + allstatus_.SetKeystoreMigrationTime( + sync_encryption_handler_->migration_time()); } void SyncManagerImpl::StartSyncingNormally( diff --git a/sync/sync.gyp b/sync/sync.gyp index 1d29098..cdbbd16 100644 --- a/sync/sync.gyp +++ b/sync/sync.gyp @@ -402,6 +402,7 @@ 'api/sync_error.cc', 'api/sync_error_factory.h', 'api/sync_error_factory.cc', + 'api/time.h', ], }, |