OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/sync/driver/sync_prefs.h" | 5 #include "components/sync/base/sync_prefs.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "components/pref_registry/pref_registry_syncable.h" | 11 #include "components/pref_registry/pref_registry_syncable.h" |
12 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
13 #include "components/sync/driver/pref_names.h" | 13 #include "components/sync/base/pref_names.h" |
14 | 14 |
15 namespace syncer { | 15 namespace syncer { |
16 | 16 |
17 SyncPrefObserver::~SyncPrefObserver() {} | 17 SyncPrefObserver::~SyncPrefObserver() {} |
18 | 18 |
19 SyncPrefs::SyncPrefs(PrefService* pref_service) : pref_service_(pref_service) { | 19 SyncPrefs::SyncPrefs(PrefService* pref_service) : pref_service_(pref_service) { |
20 DCHECK(pref_service); | 20 DCHECK(pref_service); |
21 RegisterPrefGroups(); | 21 RegisterPrefGroups(); |
22 // Watch the preference that indicates sync is managed so we can take | 22 // Watch the preference that indicates sync is managed so we can take |
23 // appropriate action. | 23 // appropriate action. |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 void SyncPrefs::SetPassphraseEncryptionTransitionInProgress(bool value) { | 521 void SyncPrefs::SetPassphraseEncryptionTransitionInProgress(bool value) { |
522 pref_service_->SetBoolean( | 522 pref_service_->SetBoolean( |
523 prefs::kSyncPassphraseEncryptionTransitionInProgress, value); | 523 prefs::kSyncPassphraseEncryptionTransitionInProgress, value); |
524 } | 524 } |
525 | 525 |
526 bool SyncPrefs::GetPassphraseEncryptionTransitionInProgress() const { | 526 bool SyncPrefs::GetPassphraseEncryptionTransitionInProgress() const { |
527 return pref_service_->GetBoolean( | 527 return pref_service_->GetBoolean( |
528 prefs::kSyncPassphraseEncryptionTransitionInProgress); | 528 prefs::kSyncPassphraseEncryptionTransitionInProgress); |
529 } | 529 } |
530 | 530 |
531 void SyncPrefs::SetSavedNigoriStateForPassphraseEncryptionTransition( | 531 void SyncPrefs::SetNigoriSpecificsForPassphraseTransition( |
532 const SyncEncryptionHandler::NigoriState& nigori_state) { | 532 const sync_pb::NigoriSpecifics& nigori_specifics) { |
533 std::string encoded; | 533 std::string encoded; |
534 base::Base64Encode(nigori_state.nigori_specifics.SerializeAsString(), | 534 base::Base64Encode(nigori_specifics.SerializeAsString(), &encoded); |
535 &encoded); | |
536 pref_service_->SetString(prefs::kSyncNigoriStateForPassphraseTransition, | 535 pref_service_->SetString(prefs::kSyncNigoriStateForPassphraseTransition, |
537 encoded); | 536 encoded); |
538 } | 537 } |
539 | 538 |
540 std::unique_ptr<SyncEncryptionHandler::NigoriState> | 539 void SyncPrefs::GetNigoriSpecificsForPassphraseTransition( |
541 SyncPrefs::GetSavedNigoriStateForPassphraseEncryptionTransition() const { | 540 sync_pb::NigoriSpecifics* nigori_specifics) const { |
542 const std::string encoded = | 541 const std::string encoded = |
543 pref_service_->GetString(prefs::kSyncNigoriStateForPassphraseTransition); | 542 pref_service_->GetString(prefs::kSyncNigoriStateForPassphraseTransition); |
544 std::string decoded; | 543 std::string decoded; |
545 if (!base::Base64Decode(encoded, &decoded)) | 544 if (base::Base64Decode(encoded, &decoded)) { |
546 return std::unique_ptr<SyncEncryptionHandler::NigoriState>(); | 545 nigori_specifics->ParseFromString(decoded); |
547 | 546 } |
548 std::unique_ptr<SyncEncryptionHandler::NigoriState> result( | |
549 new SyncEncryptionHandler::NigoriState()); | |
550 if (!result->nigori_specifics.ParseFromString(decoded)) | |
551 return std::unique_ptr<SyncEncryptionHandler::NigoriState>(); | |
552 return result; | |
553 } | 547 } |
554 | 548 |
555 } // namespace syncer | 549 } // namespace syncer |
OLD | NEW |