Index: chrome/browser/sync/profile_sync_service.cc |
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc |
index 500ec0910b7cd9fdebfcd47073c033a2c8064401..60b4fa6182e797e12c0095749c09986539abf0f7 100644 |
--- a/chrome/browser/sync/profile_sync_service.cc |
+++ b/chrome/browser/sync/profile_sync_service.cc |
@@ -111,6 +111,8 @@ ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory, |
scoped_runnable_method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
expect_sync_configuration_aborted_(false), |
clear_server_data_state_(CLEAR_NOT_STARTED), |
+ encrypted_types_(browser_sync::Cryptographer::SensitiveTypes()), |
+ encrypt_everything_(false), |
encryption_pending_(false), |
auto_start_enabled_(false), |
failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
@@ -423,6 +425,8 @@ void ProfileSyncService::Shutdown(bool sync_disabled) { |
backend_initialized_ = false; |
cached_passphrases_ = CachedPassphrases(); |
encryption_pending_ = false; |
+ encrypt_everything_ = false; |
+ encrypted_types_ = browser_sync::Cryptographer::SensitiveTypes(); |
passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED; |
last_attempted_user_email_.clear(); |
last_auth_error_ = GoogleServiceAuthError::None(); |
@@ -555,6 +559,13 @@ void ProfileSyncService::OnBackendInitialized( |
backend_initialized_ = true; |
+ // Get initial encrypted types and encrypt everything setting. |
+ // TODO(akalin): Ideally these would be parameters to |
+ // OnBackendInitialized(). |
+ encrypted_types_ = backend_->GetEncryptedDataTypes(); |
+ DCHECK_GT(encrypted_types_.count(syncable::PASSWORDS), 0u); |
+ encrypt_everything_ = backend_->EncryptEverythingEnabled(); |
+ |
sync_js_controller_.AttachJsBackend(js_backend); |
// The very first time the backend initializes is effectively the first time |
@@ -835,7 +846,15 @@ void ProfileSyncService::ResolvePassphraseRequired() { |
} |
void ProfileSyncService::OnEncryptionComplete( |
- const syncable::ModelTypeSet& encrypted_types) { |
+ const syncable::ModelTypeSet& encrypted_types, |
+ bool encrypt_everything) { |
+ encrypted_types_ = encrypted_types; |
+ encrypt_everything_ = encrypt_everything; |
+ VLOG(2) << "Encryption complete for " |
+ << syncable::ModelTypeSetToString(encrypted_types) |
+ << " (encrypt everything is set to " |
+ << (encrypt_everything_ ? "true" : "false") << ")"; |
+ DCHECK_GT(encrypted_types_.count(syncable::PASSWORDS), 0u); |
if (encryption_pending_) { |
syncable::ModelTypeSet registered_types; |
GetRegisteredDataTypes(®istered_types); |
@@ -1321,6 +1340,7 @@ void ProfileSyncService::SetPassphrase(const std::string& passphrase, |
void ProfileSyncService::SetEncryptEverything(bool encrypt_everything) { |
encryption_pending_ = encrypt_everything; |
+ encrypt_everything_ = false; |
Nicolas Zea
2011/10/20 18:40:41
presumably encrypt_everything_ should already be f
akalin
2011/10/21 02:24:17
Done.
|
} |
bool ProfileSyncService::encryption_pending() const { |
@@ -1335,22 +1355,11 @@ bool ProfileSyncService::EncryptEverythingEnabled() const { |
return backend_->EncryptEverythingEnabled(); |
} |
-// This will open a transaction to get the encrypted types. Do not call this |
-// if you already have a transaction open. |
void ProfileSyncService::GetEncryptedDataTypes( |
syncable::ModelTypeSet* encrypted_types) const { |
CHECK(encrypted_types); |
- if (backend_.get()) { |
- *encrypted_types = backend_->GetEncryptedDataTypes(); |
- DCHECK(encrypted_types->count(syncable::PASSWORDS)); |
- } else { |
- // Either we are in an unrecoverable error or the sync is not yet done |
- // initializing. In either case just return the sensitive types. During |
- // sync initialization the UI might need to know what our encrypted |
- // types are. |
- *encrypted_types = browser_sync::Cryptographer::SensitiveTypes(); |
- DCHECK(encrypted_types->count(syncable::PASSWORDS)); |
- } |
+ *encrypted_types = encrypted_types_; |
Nicolas Zea
2011/10/20 18:40:41
Is it valid to call this before the backend is ini
akalin
2011/10/21 02:24:17
Yeah, the UI functions call it. Sigh.
|
+ DCHECK_GT(encrypted_types->count(syncable::PASSWORDS), 0u); |
} |
void ProfileSyncService::OnSyncManagedPrefChange(bool is_sync_managed) { |