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

Side by Side Diff: components/sync/test/fake_sync_encryption_handler.cc

Issue 2279713002: Make PassphraseType a "enum class" instead of "enum". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix java Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « components/sync/engine/sync_string_conversions.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/fake_sync_encryption_handler.h" 5 #include "components/sync/test/fake_sync_encryption_handler.h"
6 6
7 #include "components/sync/protocol/nigori_specifics.pb.h" 7 #include "components/sync/protocol/nigori_specifics.pb.h"
8 #include "components/sync/syncable/nigori_util.h" 8 #include "components/sync/syncable/nigori_util.h"
9 9
10 namespace syncer { 10 namespace syncer {
11 11
12 FakeSyncEncryptionHandler::FakeSyncEncryptionHandler() 12 FakeSyncEncryptionHandler::FakeSyncEncryptionHandler()
13 : encrypted_types_(SensitiveTypes()), 13 : encrypted_types_(SensitiveTypes()),
14 encrypt_everything_(false), 14 encrypt_everything_(false),
15 passphrase_type_(IMPLICIT_PASSPHRASE), 15 passphrase_type_(PassphraseType::IMPLICIT_PASSPHRASE),
16 cryptographer_(&encryptor_) {} 16 cryptographer_(&encryptor_) {}
17 FakeSyncEncryptionHandler::~FakeSyncEncryptionHandler() {} 17 FakeSyncEncryptionHandler::~FakeSyncEncryptionHandler() {}
18 18
19 void FakeSyncEncryptionHandler::Init() { 19 void FakeSyncEncryptionHandler::Init() {
20 // Set up a basic cryptographer. 20 // Set up a basic cryptographer.
21 KeyParams keystore_params = {"localhost", "dummy", "keystore_key"}; 21 KeyParams keystore_params = {"localhost", "dummy", "keystore_key"};
22 cryptographer_.AddKey(keystore_params); 22 cryptographer_.AddKey(keystore_params);
23 } 23 }
24 24
25 void FakeSyncEncryptionHandler::ApplyNigoriUpdate( 25 void FakeSyncEncryptionHandler::ApplyNigoriUpdate(
26 const sync_pb::NigoriSpecifics& nigori, 26 const sync_pb::NigoriSpecifics& nigori,
27 syncable::BaseTransaction* const trans) { 27 syncable::BaseTransaction* const trans) {
28 if (nigori.encrypt_everything()) 28 if (nigori.encrypt_everything())
29 EnableEncryptEverything(); 29 EnableEncryptEverything();
30 if (nigori.keybag_is_frozen()) 30 if (nigori.keybag_is_frozen())
31 passphrase_type_ = CUSTOM_PASSPHRASE; 31 passphrase_type_ = PassphraseType::CUSTOM_PASSPHRASE;
32 32
33 // TODO(zea): consider adding fake support for migration. 33 // TODO(zea): consider adding fake support for migration.
34 if (cryptographer_.CanDecrypt(nigori.encryption_keybag())) 34 if (cryptographer_.CanDecrypt(nigori.encryption_keybag()))
35 cryptographer_.InstallKeys(nigori.encryption_keybag()); 35 cryptographer_.InstallKeys(nigori.encryption_keybag());
36 else if (nigori.has_encryption_keybag()) 36 else if (nigori.has_encryption_keybag())
37 cryptographer_.SetPendingKeys(nigori.encryption_keybag()); 37 cryptographer_.SetPendingKeys(nigori.encryption_keybag());
38 38
39 if (cryptographer_.has_pending_keys()) { 39 if (cryptographer_.has_pending_keys()) {
40 DVLOG(1) << "OnPassPhraseRequired Sent"; 40 DVLOG(1) << "OnPassPhraseRequired Sent";
41 sync_pb::EncryptedData pending_keys = cryptographer_.GetPendingKeys(); 41 sync_pb::EncryptedData pending_keys = cryptographer_.GetPendingKeys();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 90
91 void FakeSyncEncryptionHandler::RemoveObserver(Observer* observer) { 91 void FakeSyncEncryptionHandler::RemoveObserver(Observer* observer) {
92 observers_.RemoveObserver(observer); 92 observers_.RemoveObserver(observer);
93 } 93 }
94 94
95 void FakeSyncEncryptionHandler::SetEncryptionPassphrase( 95 void FakeSyncEncryptionHandler::SetEncryptionPassphrase(
96 const std::string& passphrase, 96 const std::string& passphrase,
97 bool is_explicit) { 97 bool is_explicit) {
98 if (is_explicit) 98 if (is_explicit)
99 passphrase_type_ = CUSTOM_PASSPHRASE; 99 passphrase_type_ = PassphraseType::CUSTOM_PASSPHRASE;
100 } 100 }
101 101
102 void FakeSyncEncryptionHandler::SetDecryptionPassphrase( 102 void FakeSyncEncryptionHandler::SetDecryptionPassphrase(
103 const std::string& passphrase) { 103 const std::string& passphrase) {
104 // Do nothing. 104 // Do nothing.
105 } 105 }
106 106
107 void FakeSyncEncryptionHandler::EnableEncryptEverything() { 107 void FakeSyncEncryptionHandler::EnableEncryptEverything() {
108 if (encrypt_everything_) 108 if (encrypt_everything_)
109 return; 109 return;
110 encrypt_everything_ = true; 110 encrypt_everything_ = true;
111 encrypted_types_ = ModelTypeSet::All(); 111 encrypted_types_ = ModelTypeSet::All();
112 FOR_EACH_OBSERVER( 112 FOR_EACH_OBSERVER(
113 Observer, observers_, 113 Observer, observers_,
114 OnEncryptedTypesChanged(encrypted_types_, encrypt_everything_)); 114 OnEncryptedTypesChanged(encrypted_types_, encrypt_everything_));
115 } 115 }
116 116
117 bool FakeSyncEncryptionHandler::IsEncryptEverythingEnabled() const { 117 bool FakeSyncEncryptionHandler::IsEncryptEverythingEnabled() const {
118 return encrypt_everything_; 118 return encrypt_everything_;
119 } 119 }
120 120
121 PassphraseType FakeSyncEncryptionHandler::GetPassphraseType() const { 121 PassphraseType FakeSyncEncryptionHandler::GetPassphraseType() const {
122 return passphrase_type_; 122 return passphrase_type_;
123 } 123 }
124 124
125 } // namespace syncer 125 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine/sync_string_conversions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698