unrecoverable_error_reason_(ERROR_REASON_UNSET),
expect_sync_configuration_aborted_(false),
encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()),
+ encrypt_everything_allowed_(true),
encrypt_everything_(false),
encryption_pending_(false),
configure_status_(DataTypeManager::UNKNOWN),
TrySyncDatatypePrefRecovery();
- last_synced_time_ = sync_prefs_.GetLastSyncedTime();
-
#if defined(OS_CHROMEOS)
std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken();
if (bootstrap_token.empty()) {
}
void ProfileSyncService::UpdateLastSyncedTime() {
- last_synced_time_ = base::Time::Now();
- sync_prefs_.SetLastSyncedTime(last_synced_time_);
+ sync_prefs_.SetLastSyncedTime(base::Time::Now());
}
void ProfileSyncService::NotifyObservers() {
ConsumeCachedPassphraseIfPossible();
// The very first time the backend initializes is effectively the first time
- // we can say we successfully "synced". last_synced_time_ will only be null
- // in this case, because the pref wasn't restored on StartUp.
- if (last_synced_time_.is_null()) {
+ // we can say we successfully "synced". LastSyncedTime will only be null in
+ // this case, because the pref wasn't restored on StartUp.
+ if (sync_prefs_.GetLastSyncedTime().is_null()) {
UpdateLastSyncedTime();
}
bool encrypt_everything) {
encrypted_types_ = encrypted_types;
encrypt_everything_ = encrypt_everything;
+ DCHECK(encrypt_everything_allowed_ || !encrypt_everything_);
DVLOG(1) << "Encrypted types changed to "
<< syncer::ModelTypeSetToString(encrypted_types_)
<< " (encrypt everything is set to "
}
base::string16 ProfileSyncService::GetLastSyncedTimeString() const {
- if (last_synced_time_.is_null())
+ const base::Time last_synced_time = sync_prefs_.GetLastSyncedTime();
+ if (last_synced_time.is_null())
return l10n_util::GetStringUTF16(IDS_SYNC_TIME_NEVER);
- base::TimeDelta last_synced = base::Time::Now() - last_synced_time_;
+ base::TimeDelta time_since_last_sync = base::Time::Now() - last_synced_time;
- if (last_synced < base::TimeDelta::FromMinutes(1))
+ if (time_since_last_sync < base::TimeDelta::FromMinutes(1))
return l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW);
return ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED,
- ui::TimeFormat::LENGTH_SHORT, last_synced);
+ ui::TimeFormat::LENGTH_SHORT,
+ time_since_last_sync);
}
void ProfileSyncService::UpdateSelectedTypesHistogram(
}
}
+bool ProfileSyncService::EncryptEverythingAllowed() const {
+ return encrypt_everything_allowed_;
+}
+
+void ProfileSyncService::SetEncryptEverythingAllowed(bool allowed) {
+ DCHECK(allowed || !backend_initialized_ || !EncryptEverythingEnabled());
+ encrypt_everything_allowed_ = allowed;
+}
+
void ProfileSyncService::EnableEncryptEverything() {
+ DCHECK(EncryptEverythingAllowed());
+
// Tests override sync_initialized() to always return true, so we
// must check that instead of |backend_initialized_|.
// TODO(akalin): Fix the above. :/
DCHECK_EQ(backend_mode_, SYNC);
#if defined(ENABLE_PRE_SYNC_BACKUP)
+ const base::Time last_synced_time = sync_prefs_.GetLastSyncedTime();
// Check backup once a day.
if (!last_backup_time_ &&
- (last_synced_time_.is_null() ||
- base::Time::Now() - last_synced_time_ >=
+ (last_synced_time.is_null() ||
+ base::Time::Now() - last_synced_time >=
base::TimeDelta::FromDays(1))) {
// If sync thread is set, need to serialize check on sync thread after
// closing backup DB.