Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: sync/test/fake_sync_encryption_handler.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/test/fake_sync_encryption_handler.h ('k') | sync/test/local_sync_test_server.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/test/fake_sync_encryption_handler.cc
diff --git a/sync/test/fake_sync_encryption_handler.cc b/sync/test/fake_sync_encryption_handler.cc
deleted file mode 100644
index d524e60b68c0655b94c5ca64c2bb45968675b1f0..0000000000000000000000000000000000000000
--- a/sync/test/fake_sync_encryption_handler.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-// 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.
-
-#include "sync/test/fake_sync_encryption_handler.h"
-
-#include "sync/protocol/nigori_specifics.pb.h"
-#include "sync/syncable/nigori_util.h"
-
-namespace syncer {
-
-FakeSyncEncryptionHandler::FakeSyncEncryptionHandler()
- : encrypted_types_(SensitiveTypes()),
- encrypt_everything_(false),
- passphrase_type_(IMPLICIT_PASSPHRASE),
- cryptographer_(&encryptor_) {
-}
-FakeSyncEncryptionHandler::~FakeSyncEncryptionHandler() {}
-
-void FakeSyncEncryptionHandler::Init() {
- // Set up a basic cryptographer.
- KeyParams keystore_params = {"localhost", "dummy", "keystore_key"};
- cryptographer_.AddKey(keystore_params);
-}
-
-void FakeSyncEncryptionHandler::ApplyNigoriUpdate(
- const sync_pb::NigoriSpecifics& nigori,
- syncable::BaseTransaction* const trans) {
- if (nigori.encrypt_everything())
- EnableEncryptEverything();
- if (nigori.keybag_is_frozen())
- passphrase_type_ = CUSTOM_PASSPHRASE;
-
- // TODO(zea): consider adding fake support for migration.
- if (cryptographer_.CanDecrypt(nigori.encryption_keybag()))
- cryptographer_.InstallKeys(nigori.encryption_keybag());
- else if (nigori.has_encryption_keybag())
- cryptographer_.SetPendingKeys(nigori.encryption_keybag());
-
- if (cryptographer_.has_pending_keys()) {
- DVLOG(1) << "OnPassPhraseRequired Sent";
- sync_pb::EncryptedData pending_keys = cryptographer_.GetPendingKeys();
- FOR_EACH_OBSERVER(SyncEncryptionHandler::Observer, observers_,
- OnPassphraseRequired(REASON_DECRYPTION,
- pending_keys));
- } else if (!cryptographer_.is_ready()) {
- DVLOG(1) << "OnPassphraseRequired sent because cryptographer is not "
- << "ready";
- FOR_EACH_OBSERVER(SyncEncryptionHandler::Observer, observers_,
- OnPassphraseRequired(REASON_ENCRYPTION,
- sync_pb::EncryptedData()));
- }
-}
-
-void FakeSyncEncryptionHandler::UpdateNigoriFromEncryptedTypes(
- sync_pb::NigoriSpecifics* nigori,
- syncable::BaseTransaction* const trans) const {
- syncable::UpdateNigoriFromEncryptedTypes(encrypted_types_,
- encrypt_everything_,
- nigori);
-}
-
-bool FakeSyncEncryptionHandler::NeedKeystoreKey(
- syncable::BaseTransaction* const trans) const {
- return keystore_key_.empty();
-}
-
-bool FakeSyncEncryptionHandler::SetKeystoreKeys(
- const google::protobuf::RepeatedPtrField<google::protobuf::string>& keys,
- syncable::BaseTransaction* const trans) {
- if (keys.size() == 0)
- return false;
- std::string new_key = keys.Get(keys.size()-1);
- if (new_key.empty())
- return false;
- keystore_key_ = new_key;
-
-
- DVLOG(1) << "Keystore bootstrap token updated.";
- FOR_EACH_OBSERVER(SyncEncryptionHandler::Observer, observers_,
- OnBootstrapTokenUpdated(keystore_key_,
- KEYSTORE_BOOTSTRAP_TOKEN));
- return true;
-}
-
-ModelTypeSet FakeSyncEncryptionHandler::GetEncryptedTypes(
- syncable::BaseTransaction* const trans) const {
- return encrypted_types_;
-}
-
-void FakeSyncEncryptionHandler::AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
-}
-
-void FakeSyncEncryptionHandler::RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
-}
-
-void FakeSyncEncryptionHandler::SetEncryptionPassphrase(
- const std::string& passphrase,
- bool is_explicit) {
- if (is_explicit)
- passphrase_type_ = CUSTOM_PASSPHRASE;
-}
-
-void FakeSyncEncryptionHandler::SetDecryptionPassphrase(
- const std::string& passphrase) {
- // Do nothing.
-}
-
-void FakeSyncEncryptionHandler::EnableEncryptEverything() {
- if (encrypt_everything_)
- return;
- encrypt_everything_ = true;
- encrypted_types_ = ModelTypeSet::All();
- FOR_EACH_OBSERVER(
- Observer, observers_,
- OnEncryptedTypesChanged(encrypted_types_, encrypt_everything_));
-}
-
-bool FakeSyncEncryptionHandler::IsEncryptEverythingEnabled() const {
- return encrypt_everything_;
-}
-
-PassphraseType FakeSyncEncryptionHandler::GetPassphraseType() const {
- return passphrase_type_;
-}
-
-} // namespace syncer
« no previous file with comments | « sync/test/fake_sync_encryption_handler.h ('k') | sync/test/local_sync_test_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698