OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_ENCRYPTION_HANDLER_H |
| 6 #define SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_ENCRYPTION_HANDLER_H |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/observer_list.h" |
| 12 #include "sync/internal_api/public/sync_encryption_handler.h" |
| 13 |
| 14 namespace syncer { |
| 15 |
| 16 class Cryptographer; |
| 17 |
| 18 // A fake sync encryption handler capable of keeping track of the encryption |
| 19 // state without opening any transactions or interacting with the nigori node. |
| 20 // Note that this only performs basic interactions with the cryptographer |
| 21 // (setting pending keys, installing keys). |
| 22 // Note: NOT thread safe. If threads attempt to check encryption state |
| 23 // while another thread is modifying it, races can occur. |
| 24 class FakeSyncEncryptionHandler : public SyncEncryptionHandler { |
| 25 public: |
| 26 FakeSyncEncryptionHandler(); |
| 27 virtual ~FakeSyncEncryptionHandler(); |
| 28 |
| 29 void set_cryptographer(Cryptographer* cryptographer) { |
| 30 cryptographer_ = cryptographer; |
| 31 } |
| 32 |
| 33 // SyncEncryptionHandler implementation. |
| 34 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 35 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 36 virtual void ReloadNigori() OVERRIDE; |
| 37 virtual void UpdateFromNigori( |
| 38 const sync_pb::NigoriSpecifics& nigori) OVERRIDE; |
| 39 virtual ModelTypeSet GetEncryptedTypes() const OVERRIDE; |
| 40 virtual void UpdateNigoriFromEncryptedTypes( |
| 41 sync_pb::NigoriSpecifics* nigori) const OVERRIDE; |
| 42 virtual void SetEncryptionPassphrase(const std::string& passphrase, |
| 43 bool is_explicit) OVERRIDE; |
| 44 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE; |
| 45 virtual void EnableEncryptEverything() OVERRIDE; |
| 46 virtual bool EncryptEverythingEnabled() const OVERRIDE; |
| 47 virtual bool IsUsingExplicitPassphrase() const OVERRIDE; |
| 48 |
| 49 private: |
| 50 ObserverList<SyncEncryptionHandler::Observer> observers_; |
| 51 ModelTypeSet encrypted_types_; |
| 52 bool encrypt_everything_; |
| 53 bool explicit_passphrase_; |
| 54 |
| 55 Cryptographer* cryptographer_; |
| 56 }; |
| 57 |
| 58 } // namespace syncer |
| 59 |
| 60 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_FAKE_SYNC_ENCRYPTION_HANDLER_H |
OLD | NEW |