diff options
Diffstat (limited to 'chrome/browser/sync/util/cryptographer.cc')
-rw-r--r-- | chrome/browser/sync/util/cryptographer.cc | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/chrome/browser/sync/util/cryptographer.cc b/chrome/browser/sync/util/cryptographer.cc index 59e9610..0f04a01 100644 --- a/chrome/browser/sync/util/cryptographer.cc +++ b/chrome/browser/sync/util/cryptographer.cc @@ -22,10 +22,8 @@ Cryptographer::Observer::~Observer() {} Cryptographer::Cryptographer() : default_nigori_(NULL), - encrypt_everything_(false) { - syncable::ModelTypeSet sensitive_types = SensitiveTypes(); - encrypted_types_.insert(sensitive_types.begin(), sensitive_types.end()); -} + encrypted_types_(SensitiveTypes()), + encrypt_everything_(false) {} Cryptographer::~Cryptographer() {} @@ -275,12 +273,12 @@ Cryptographer::UpdateResult Cryptographer::Update( } // Static -syncable::ModelTypeSet Cryptographer::SensitiveTypes() { - syncable::ModelTypeSet types; +syncable::ModelEnumSet Cryptographer::SensitiveTypes() { // Both of these have their own encryption schemes, but we include them // anyways. - types.insert(syncable::PASSWORDS); - types.insert(syncable::NIGORI); + syncable::ModelEnumSet types; + types.Put(syncable::PASSWORDS); + types.Put(syncable::NIGORI); return types; } @@ -291,39 +289,39 @@ void Cryptographer::UpdateEncryptedTypesFromNigori( return; } - syncable::ModelTypeSet encrypted_types(SensitiveTypes()); + syncable::ModelEnumSet encrypted_types(SensitiveTypes()); if (nigori.encrypt_bookmarks()) - encrypted_types.insert(syncable::BOOKMARKS); + encrypted_types.Put(syncable::BOOKMARKS); if (nigori.encrypt_preferences()) - encrypted_types.insert(syncable::PREFERENCES); + encrypted_types.Put(syncable::PREFERENCES); if (nigori.encrypt_autofill_profile()) - encrypted_types.insert(syncable::AUTOFILL_PROFILE); + encrypted_types.Put(syncable::AUTOFILL_PROFILE); if (nigori.encrypt_autofill()) - encrypted_types.insert(syncable::AUTOFILL); + encrypted_types.Put(syncable::AUTOFILL); if (nigori.encrypt_themes()) - encrypted_types.insert(syncable::THEMES); + encrypted_types.Put(syncable::THEMES); if (nigori.encrypt_typed_urls()) - encrypted_types.insert(syncable::TYPED_URLS); + encrypted_types.Put(syncable::TYPED_URLS); if (nigori.encrypt_extension_settings()) - encrypted_types.insert(syncable::EXTENSION_SETTINGS); + encrypted_types.Put(syncable::EXTENSION_SETTINGS); if (nigori.encrypt_extensions()) - encrypted_types.insert(syncable::EXTENSIONS); + encrypted_types.Put(syncable::EXTENSIONS); if (nigori.encrypt_search_engines()) - encrypted_types.insert(syncable::SEARCH_ENGINES); + encrypted_types.Put(syncable::SEARCH_ENGINES); if (nigori.encrypt_sessions()) - encrypted_types.insert(syncable::SESSIONS); + encrypted_types.Put(syncable::SESSIONS); if (nigori.encrypt_app_settings()) - encrypted_types.insert(syncable::APP_SETTINGS); + encrypted_types.Put(syncable::APP_SETTINGS); if (nigori.encrypt_apps()) - encrypted_types.insert(syncable::APPS); + encrypted_types.Put(syncable::APPS); if (nigori.encrypt_app_notifications()) - encrypted_types.insert(syncable::APP_NOTIFICATIONS); + encrypted_types.Put(syncable::APP_NOTIFICATIONS); // Note: the initial version with encryption did not support the // encrypt_everything field. If anything more than the sensitive types were // encrypted, it meant we were encrypting everything. if (!nigori.has_encrypt_everything() && - encrypted_types.size() > SensitiveTypes().size()) { + !Difference(encrypted_types, SensitiveTypes()).Empty()) { set_encrypt_everything(); return; } @@ -335,38 +333,38 @@ void Cryptographer::UpdateNigoriFromEncryptedTypes( sync_pb::NigoriSpecifics* nigori) const { nigori->set_encrypt_everything(encrypt_everything_); nigori->set_encrypt_bookmarks( - encrypted_types_.count(syncable::BOOKMARKS) > 0); + encrypted_types_.Has(syncable::BOOKMARKS)); nigori->set_encrypt_preferences( - encrypted_types_.count(syncable::PREFERENCES) > 0); + encrypted_types_.Has(syncable::PREFERENCES)); nigori->set_encrypt_autofill_profile( - encrypted_types_.count(syncable::AUTOFILL_PROFILE) > 0); - nigori->set_encrypt_autofill(encrypted_types_.count(syncable::AUTOFILL) > 0); - nigori->set_encrypt_themes(encrypted_types_.count(syncable::THEMES) > 0); + encrypted_types_.Has(syncable::AUTOFILL_PROFILE)); + nigori->set_encrypt_autofill(encrypted_types_.Has(syncable::AUTOFILL)); + nigori->set_encrypt_themes(encrypted_types_.Has(syncable::THEMES)); nigori->set_encrypt_typed_urls( - encrypted_types_.count(syncable::TYPED_URLS) > 0); + encrypted_types_.Has(syncable::TYPED_URLS)); nigori->set_encrypt_extension_settings( - encrypted_types_.count(syncable::EXTENSION_SETTINGS) > 0); + encrypted_types_.Has(syncable::EXTENSION_SETTINGS)); nigori->set_encrypt_extensions( - encrypted_types_.count(syncable::EXTENSIONS) > 0); + encrypted_types_.Has(syncable::EXTENSIONS)); nigori->set_encrypt_search_engines( - encrypted_types_.count(syncable::SEARCH_ENGINES) > 0); - nigori->set_encrypt_sessions(encrypted_types_.count(syncable::SESSIONS) > 0); + encrypted_types_.Has(syncable::SEARCH_ENGINES)); + nigori->set_encrypt_sessions(encrypted_types_.Has(syncable::SESSIONS)); nigori->set_encrypt_app_settings( - encrypted_types_.count(syncable::APP_SETTINGS) > 0); - nigori->set_encrypt_apps(encrypted_types_.count(syncable::APPS) > 0); + encrypted_types_.Has(syncable::APP_SETTINGS)); + nigori->set_encrypt_apps(encrypted_types_.Has(syncable::APPS)); nigori->set_encrypt_app_notifications( - encrypted_types_.count(syncable::APP_NOTIFICATIONS) > 0); + encrypted_types_.Has(syncable::APP_NOTIFICATIONS)); } void Cryptographer::set_encrypt_everything() { if (encrypt_everything_) { - DCHECK(encrypted_types_ == syncable::GetAllRealModelTypes()); + DCHECK(encrypted_types_.Equals(syncable::ModelEnumSet::All())); return; } encrypt_everything_ = true; // Change |encrypted_types_| directly to avoid sending more than one // notification. - encrypted_types_ = syncable::GetAllRealModelTypes(); + encrypted_types_ = syncable::ModelEnumSet::All(); EmitEncryptedTypesChangedNotification(); } @@ -374,19 +372,18 @@ bool Cryptographer::encrypt_everything() const { return encrypt_everything_; } -syncable::ModelTypeSet Cryptographer::GetEncryptedTypes() const { +syncable::ModelEnumSet Cryptographer::GetEncryptedTypes() const { return encrypted_types_; } void Cryptographer::MergeEncryptedTypesForTest( - const syncable::ModelTypeSet& encrypted_types) { + syncable::ModelEnumSet encrypted_types) { MergeEncryptedTypes(encrypted_types); } void Cryptographer::MergeEncryptedTypes( - const syncable::ModelTypeSet& encrypted_types) { - if (std::includes(encrypted_types_.begin(), encrypted_types_.end(), - encrypted_types.begin(), encrypted_types.end())) { + syncable::ModelEnumSet encrypted_types) { + if (encrypted_types_.HasAll(encrypted_types)) { return; } encrypted_types_ = encrypted_types; |