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

Side by Side Diff: chrome/browser/sync/util/cryptographer.cc

Issue 8919021: [Sync] Rename ModelEnumSet to ModelTypeSet (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "chrome/browser/sync/util/cryptographer.h" 8 #include "chrome/browser/sync/util/cryptographer.h"
9 #include "chrome/browser/password_manager/encryptor.h" 9 #include "chrome/browser/password_manager/encryptor.h"
10 10
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return Cryptographer::SUCCESS; 266 return Cryptographer::SUCCESS;
267 } else { 267 } else {
268 SetPendingKeys(nigori.encrypted()); 268 SetPendingKeys(nigori.encrypted());
269 return Cryptographer::NEEDS_PASSPHRASE; 269 return Cryptographer::NEEDS_PASSPHRASE;
270 } 270 }
271 } 271 }
272 return Cryptographer::SUCCESS; 272 return Cryptographer::SUCCESS;
273 } 273 }
274 274
275 // Static 275 // Static
276 syncable::ModelEnumSet Cryptographer::SensitiveTypes() { 276 syncable::ModelTypeSet Cryptographer::SensitiveTypes() {
277 // Both of these have their own encryption schemes, but we include them 277 // Both of these have their own encryption schemes, but we include them
278 // anyways. 278 // anyways.
279 syncable::ModelEnumSet types; 279 syncable::ModelTypeSet types;
280 types.Put(syncable::PASSWORDS); 280 types.Put(syncable::PASSWORDS);
281 types.Put(syncable::NIGORI); 281 types.Put(syncable::NIGORI);
282 return types; 282 return types;
283 } 283 }
284 284
285 void Cryptographer::UpdateEncryptedTypesFromNigori( 285 void Cryptographer::UpdateEncryptedTypesFromNigori(
286 const sync_pb::NigoriSpecifics& nigori) { 286 const sync_pb::NigoriSpecifics& nigori) {
287 if (nigori.encrypt_everything()) { 287 if (nigori.encrypt_everything()) {
288 set_encrypt_everything(); 288 set_encrypt_everything();
289 return; 289 return;
290 } 290 }
291 291
292 syncable::ModelEnumSet encrypted_types(SensitiveTypes()); 292 syncable::ModelTypeSet encrypted_types(SensitiveTypes());
293 if (nigori.encrypt_bookmarks()) 293 if (nigori.encrypt_bookmarks())
294 encrypted_types.Put(syncable::BOOKMARKS); 294 encrypted_types.Put(syncable::BOOKMARKS);
295 if (nigori.encrypt_preferences()) 295 if (nigori.encrypt_preferences())
296 encrypted_types.Put(syncable::PREFERENCES); 296 encrypted_types.Put(syncable::PREFERENCES);
297 if (nigori.encrypt_autofill_profile()) 297 if (nigori.encrypt_autofill_profile())
298 encrypted_types.Put(syncable::AUTOFILL_PROFILE); 298 encrypted_types.Put(syncable::AUTOFILL_PROFILE);
299 if (nigori.encrypt_autofill()) 299 if (nigori.encrypt_autofill())
300 encrypted_types.Put(syncable::AUTOFILL); 300 encrypted_types.Put(syncable::AUTOFILL);
301 if (nigori.encrypt_themes()) 301 if (nigori.encrypt_themes())
302 encrypted_types.Put(syncable::THEMES); 302 encrypted_types.Put(syncable::THEMES);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 nigori->set_encrypt_sessions(encrypted_types_.Has(syncable::SESSIONS)); 351 nigori->set_encrypt_sessions(encrypted_types_.Has(syncable::SESSIONS));
352 nigori->set_encrypt_app_settings( 352 nigori->set_encrypt_app_settings(
353 encrypted_types_.Has(syncable::APP_SETTINGS)); 353 encrypted_types_.Has(syncable::APP_SETTINGS));
354 nigori->set_encrypt_apps(encrypted_types_.Has(syncable::APPS)); 354 nigori->set_encrypt_apps(encrypted_types_.Has(syncable::APPS));
355 nigori->set_encrypt_app_notifications( 355 nigori->set_encrypt_app_notifications(
356 encrypted_types_.Has(syncable::APP_NOTIFICATIONS)); 356 encrypted_types_.Has(syncable::APP_NOTIFICATIONS));
357 } 357 }
358 358
359 void Cryptographer::set_encrypt_everything() { 359 void Cryptographer::set_encrypt_everything() {
360 if (encrypt_everything_) { 360 if (encrypt_everything_) {
361 DCHECK(encrypted_types_.Equals(syncable::ModelEnumSet::All())); 361 DCHECK(encrypted_types_.Equals(syncable::ModelTypeSet::All()));
362 return; 362 return;
363 } 363 }
364 encrypt_everything_ = true; 364 encrypt_everything_ = true;
365 // Change |encrypted_types_| directly to avoid sending more than one 365 // Change |encrypted_types_| directly to avoid sending more than one
366 // notification. 366 // notification.
367 encrypted_types_ = syncable::ModelEnumSet::All(); 367 encrypted_types_ = syncable::ModelTypeSet::All();
368 EmitEncryptedTypesChangedNotification(); 368 EmitEncryptedTypesChangedNotification();
369 } 369 }
370 370
371 bool Cryptographer::encrypt_everything() const { 371 bool Cryptographer::encrypt_everything() const {
372 return encrypt_everything_; 372 return encrypt_everything_;
373 } 373 }
374 374
375 syncable::ModelEnumSet Cryptographer::GetEncryptedTypes() const { 375 syncable::ModelTypeSet Cryptographer::GetEncryptedTypes() const {
376 return encrypted_types_; 376 return encrypted_types_;
377 } 377 }
378 378
379 void Cryptographer::MergeEncryptedTypesForTest( 379 void Cryptographer::MergeEncryptedTypesForTest(
380 syncable::ModelEnumSet encrypted_types) { 380 syncable::ModelTypeSet encrypted_types) {
381 MergeEncryptedTypes(encrypted_types); 381 MergeEncryptedTypes(encrypted_types);
382 } 382 }
383 383
384 void Cryptographer::MergeEncryptedTypes( 384 void Cryptographer::MergeEncryptedTypes(
385 syncable::ModelEnumSet encrypted_types) { 385 syncable::ModelTypeSet encrypted_types) {
386 if (encrypted_types_.HasAll(encrypted_types)) { 386 if (encrypted_types_.HasAll(encrypted_types)) {
387 return; 387 return;
388 } 388 }
389 encrypted_types_ = encrypted_types; 389 encrypted_types_ = encrypted_types;
390 EmitEncryptedTypesChangedNotification(); 390 EmitEncryptedTypesChangedNotification();
391 } 391 }
392 392
393 void Cryptographer::EmitEncryptedTypesChangedNotification() { 393 void Cryptographer::EmitEncryptedTypesChangedNotification() {
394 FOR_EACH_OBSERVER( 394 FOR_EACH_OBSERVER(
395 Observer, observers_, 395 Observer, observers_,
(...skipping 15 matching lines...) Expand all
411 continue; 411 continue;
412 } 412 }
413 nigoris_[key.name()] = make_linked_ptr(new_nigori.release()); 413 nigoris_[key.name()] = make_linked_ptr(new_nigori.release());
414 } 414 }
415 } 415 }
416 DCHECK(nigoris_.end() != nigoris_.find(default_key_name)); 416 DCHECK(nigoris_.end() != nigoris_.find(default_key_name));
417 default_nigori_ = &*nigoris_.find(default_key_name); 417 default_nigori_ = &*nigoris_.find(default_key_name);
418 } 418 }
419 419
420 } // namespace browser_sync 420 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/util/cryptographer.h ('k') | chrome/browser/sync/util/cryptographer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698