| Index: chrome/browser/sync/glue/sync_backend_host.cc
|
| diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
|
| index 679dad943280fc2d38073485a73cbfe23882a4f7..adfa8f6cd21a1781dda33dda68a45840f06912bd 100644
|
| --- a/chrome/browser/sync/glue/sync_backend_host.cc
|
| +++ b/chrome/browser/sync/glue/sync_backend_host.cc
|
| @@ -48,6 +48,7 @@
|
| #include "sync/internal_api/public/read_transaction.h"
|
| #include "sync/internal_api/public/sync_manager_factory.h"
|
| #include "sync/internal_api/public/util/experiments.h"
|
| +#include "sync/internal_api/public/util/sync_string_conversions.h"
|
| #include "sync/notifier/sync_notifier.h"
|
| #include "sync/protocol/encryption.pb.h"
|
| #include "sync/protocol/sync.pb.h"
|
| @@ -115,6 +116,7 @@ class SyncBackendHost::Core
|
| virtual void OnEncryptionComplete() OVERRIDE;
|
| virtual void OnCryptographerStateChanged(
|
| syncer::Cryptographer* cryptographer) OVERRIDE;
|
| + virtual void OnPassphraseStateChanged(syncer::PassphraseState state) OVERRIDE;
|
|
|
| // syncer::SyncNotifierObserver implementation.
|
| virtual void OnNotificationsEnabled() OVERRIDE;
|
| @@ -325,7 +327,8 @@ SyncBackendHost::SyncBackendHost(
|
| profile_->GetRequestContext()),
|
| content::GetUserAgent(GURL()),
|
| invalidator_storage),
|
| - frontend_(NULL) {
|
| + frontend_(NULL),
|
| + cached_passphrase_state_(syncer::IMPLICIT_PASSPHRASE) {
|
| }
|
|
|
| SyncBackendHost::SyncBackendHost(Profile* profile)
|
| @@ -340,7 +343,8 @@ SyncBackendHost::SyncBackendHost(Profile* profile)
|
| profile_->GetRequestContext()),
|
| content::GetUserAgent(GURL()),
|
| base::WeakPtr<syncer::InvalidationStateTracker>()),
|
| - frontend_(NULL) {
|
| + frontend_(NULL),
|
| + cached_passphrase_state_(syncer::IMPLICIT_PASSPHRASE) {
|
| }
|
|
|
| SyncBackendHost::~SyncBackendHost() {
|
| @@ -762,11 +766,11 @@ bool SyncBackendHost::IsUsingExplicitPassphrase() {
|
| // otherwise we have no idea what kind of passphrase we are using. This will
|
| // NOTREACH in sync_manager and return false if we fail to load the nigori
|
| // node.
|
| - // TODO(zea): cache this value here, then make the encryption handler
|
| - // NonThreadSafe and only accessible from the sync thread.
|
| - return IsNigoriEnabled() &&
|
| - core_->sync_manager()->GetEncryptionHandler()->
|
| - IsUsingExplicitPassphrase();
|
| + // TODO(zea): expose whether the custom passphrase is a frozen implicit
|
| + // passphrase or not to provide better messaging.
|
| + return IsNigoriEnabled() && (
|
| + cached_passphrase_state_ == syncer::CUSTOM_PASSPHRASE ||
|
| + cached_passphrase_state_ == syncer::FROZEN_IMPLICIT_PASSPHRASE);
|
| }
|
|
|
| bool SyncBackendHost::IsCryptographerReady(
|
| @@ -1025,6 +1029,14 @@ void SyncBackendHost::Core::OnCryptographerStateChanged(
|
| // Do nothing.
|
| }
|
|
|
| +void SyncBackendHost::Core::OnPassphraseStateChanged(
|
| + syncer::PassphraseState state) {
|
| + host_.Call(
|
| + FROM_HERE,
|
| + &SyncBackendHost::HandlePassphraseStateChangedOnFrontendLoop,
|
| + state);
|
| +}
|
| +
|
| void SyncBackendHost::Core::OnActionableError(
|
| const syncer::SyncProtocolError& sync_error) {
|
| if (!sync_loop_)
|
| @@ -1166,6 +1178,9 @@ void SyncBackendHost::Core::DoAssociateNigori() {
|
| sync_manager_->GetEncryptionHandler()->AddObserver(this);
|
| sync_manager_->GetEncryptionHandler()->Init();
|
| host_.Call(FROM_HERE,
|
| + &SyncBackendHost::HandlePassphraseStateChangedOnFrontendLoop,
|
| + sync_manager_->GetEncryptionHandler()->GetPassphraseState());
|
| + host_.Call(FROM_HERE,
|
| &SyncBackendHost::HandleInitializationCompletedOnFrontendLoop,
|
| true);
|
| }
|
| @@ -1519,6 +1534,14 @@ void SyncBackendHost::NotifyEncryptionComplete() {
|
| frontend_->OnEncryptionComplete();
|
| }
|
|
|
| +void SyncBackendHost::HandlePassphraseStateChangedOnFrontendLoop(
|
| + syncer::PassphraseState state) {
|
| + DCHECK_EQ(MessageLoop::current(), frontend_loop_);
|
| + DVLOG(1) << "Passphrase state changed to "
|
| + << syncer::PassphraseStateToString(state);
|
| + cached_passphrase_state_ = state;
|
| +}
|
| +
|
| void SyncBackendHost::HandleStopSyncingPermanentlyOnFrontendLoop() {
|
| if (!frontend_)
|
| return;
|
|
|