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

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

Issue 10795018: [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiix indent Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/util/cryptographer.h ('k') | sync/util/cryptographer_unittest.cc » ('j') | 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 "sync/util/cryptographer.h" 5 #include "sync/util/cryptographer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 return Cryptographer::SUCCESS; 302 return Cryptographer::SUCCESS;
303 } else { 303 } else {
304 SetPendingKeys(nigori.encrypted()); 304 SetPendingKeys(nigori.encrypted());
305 return Cryptographer::NEEDS_PASSPHRASE; 305 return Cryptographer::NEEDS_PASSPHRASE;
306 } 306 }
307 } 307 }
308 return Cryptographer::SUCCESS; 308 return Cryptographer::SUCCESS;
309 } 309 }
310 310
311 // Static 311 // Static
312 syncer::ModelTypeSet Cryptographer::SensitiveTypes() { 312 ModelTypeSet Cryptographer::SensitiveTypes() {
313 // Both of these have their own encryption schemes, but we include them 313 // Both of these have their own encryption schemes, but we include them
314 // anyways. 314 // anyways.
315 syncer::ModelTypeSet types; 315 ModelTypeSet types;
316 types.Put(syncer::PASSWORDS); 316 types.Put(PASSWORDS);
317 types.Put(syncer::NIGORI); 317 types.Put(NIGORI);
318 return types; 318 return types;
319 } 319 }
320 320
321 void Cryptographer::UpdateEncryptedTypesFromNigori( 321 void Cryptographer::UpdateEncryptedTypesFromNigori(
322 const sync_pb::NigoriSpecifics& nigori) { 322 const sync_pb::NigoriSpecifics& nigori) {
323 if (nigori.encrypt_everything()) { 323 if (nigori.encrypt_everything()) {
324 set_encrypt_everything(); 324 set_encrypt_everything();
325 return; 325 return;
326 } 326 }
327 327
328 syncer::ModelTypeSet encrypted_types(SensitiveTypes()); 328 ModelTypeSet encrypted_types(SensitiveTypes());
329 if (nigori.encrypt_bookmarks()) 329 if (nigori.encrypt_bookmarks())
330 encrypted_types.Put(syncer::BOOKMARKS); 330 encrypted_types.Put(BOOKMARKS);
331 if (nigori.encrypt_preferences()) 331 if (nigori.encrypt_preferences())
332 encrypted_types.Put(syncer::PREFERENCES); 332 encrypted_types.Put(PREFERENCES);
333 if (nigori.encrypt_autofill_profile()) 333 if (nigori.encrypt_autofill_profile())
334 encrypted_types.Put(syncer::AUTOFILL_PROFILE); 334 encrypted_types.Put(AUTOFILL_PROFILE);
335 if (nigori.encrypt_autofill()) 335 if (nigori.encrypt_autofill())
336 encrypted_types.Put(syncer::AUTOFILL); 336 encrypted_types.Put(AUTOFILL);
337 if (nigori.encrypt_themes()) 337 if (nigori.encrypt_themes())
338 encrypted_types.Put(syncer::THEMES); 338 encrypted_types.Put(THEMES);
339 if (nigori.encrypt_typed_urls()) 339 if (nigori.encrypt_typed_urls())
340 encrypted_types.Put(syncer::TYPED_URLS); 340 encrypted_types.Put(TYPED_URLS);
341 if (nigori.encrypt_extension_settings()) 341 if (nigori.encrypt_extension_settings())
342 encrypted_types.Put(syncer::EXTENSION_SETTINGS); 342 encrypted_types.Put(EXTENSION_SETTINGS);
343 if (nigori.encrypt_extensions()) 343 if (nigori.encrypt_extensions())
344 encrypted_types.Put(syncer::EXTENSIONS); 344 encrypted_types.Put(EXTENSIONS);
345 if (nigori.encrypt_search_engines()) 345 if (nigori.encrypt_search_engines())
346 encrypted_types.Put(syncer::SEARCH_ENGINES); 346 encrypted_types.Put(SEARCH_ENGINES);
347 if (nigori.encrypt_sessions()) 347 if (nigori.encrypt_sessions())
348 encrypted_types.Put(syncer::SESSIONS); 348 encrypted_types.Put(SESSIONS);
349 if (nigori.encrypt_app_settings()) 349 if (nigori.encrypt_app_settings())
350 encrypted_types.Put(syncer::APP_SETTINGS); 350 encrypted_types.Put(APP_SETTINGS);
351 if (nigori.encrypt_apps()) 351 if (nigori.encrypt_apps())
352 encrypted_types.Put(syncer::APPS); 352 encrypted_types.Put(APPS);
353 if (nigori.encrypt_app_notifications()) 353 if (nigori.encrypt_app_notifications())
354 encrypted_types.Put(syncer::APP_NOTIFICATIONS); 354 encrypted_types.Put(APP_NOTIFICATIONS);
355 355
356 // Note: the initial version with encryption did not support the 356 // Note: the initial version with encryption did not support the
357 // encrypt_everything field. If anything more than the sensitive types were 357 // encrypt_everything field. If anything more than the sensitive types were
358 // encrypted, it meant we were encrypting everything. 358 // encrypted, it meant we were encrypting everything.
359 if (!nigori.has_encrypt_everything() && 359 if (!nigori.has_encrypt_everything() &&
360 !Difference(encrypted_types, SensitiveTypes()).Empty()) { 360 !Difference(encrypted_types, SensitiveTypes()).Empty()) {
361 set_encrypt_everything(); 361 set_encrypt_everything();
362 return; 362 return;
363 } 363 }
364 364
365 MergeEncryptedTypes(encrypted_types); 365 MergeEncryptedTypes(encrypted_types);
366 } 366 }
367 367
368 void Cryptographer::UpdateNigoriFromEncryptedTypes( 368 void Cryptographer::UpdateNigoriFromEncryptedTypes(
369 sync_pb::NigoriSpecifics* nigori) const { 369 sync_pb::NigoriSpecifics* nigori) const {
370 nigori->set_encrypt_everything(encrypt_everything_); 370 nigori->set_encrypt_everything(encrypt_everything_);
371 nigori->set_encrypt_bookmarks( 371 nigori->set_encrypt_bookmarks(
372 encrypted_types_.Has(syncer::BOOKMARKS)); 372 encrypted_types_.Has(BOOKMARKS));
373 nigori->set_encrypt_preferences( 373 nigori->set_encrypt_preferences(
374 encrypted_types_.Has(syncer::PREFERENCES)); 374 encrypted_types_.Has(PREFERENCES));
375 nigori->set_encrypt_autofill_profile( 375 nigori->set_encrypt_autofill_profile(
376 encrypted_types_.Has(syncer::AUTOFILL_PROFILE)); 376 encrypted_types_.Has(AUTOFILL_PROFILE));
377 nigori->set_encrypt_autofill(encrypted_types_.Has(syncer::AUTOFILL)); 377 nigori->set_encrypt_autofill(encrypted_types_.Has(AUTOFILL));
378 nigori->set_encrypt_themes(encrypted_types_.Has(syncer::THEMES)); 378 nigori->set_encrypt_themes(encrypted_types_.Has(THEMES));
379 nigori->set_encrypt_typed_urls( 379 nigori->set_encrypt_typed_urls(
380 encrypted_types_.Has(syncer::TYPED_URLS)); 380 encrypted_types_.Has(TYPED_URLS));
381 nigori->set_encrypt_extension_settings( 381 nigori->set_encrypt_extension_settings(
382 encrypted_types_.Has(syncer::EXTENSION_SETTINGS)); 382 encrypted_types_.Has(EXTENSION_SETTINGS));
383 nigori->set_encrypt_extensions( 383 nigori->set_encrypt_extensions(
384 encrypted_types_.Has(syncer::EXTENSIONS)); 384 encrypted_types_.Has(EXTENSIONS));
385 nigori->set_encrypt_search_engines( 385 nigori->set_encrypt_search_engines(
386 encrypted_types_.Has(syncer::SEARCH_ENGINES)); 386 encrypted_types_.Has(SEARCH_ENGINES));
387 nigori->set_encrypt_sessions(encrypted_types_.Has(syncer::SESSIONS)); 387 nigori->set_encrypt_sessions(encrypted_types_.Has(SESSIONS));
388 nigori->set_encrypt_app_settings( 388 nigori->set_encrypt_app_settings(
389 encrypted_types_.Has(syncer::APP_SETTINGS)); 389 encrypted_types_.Has(APP_SETTINGS));
390 nigori->set_encrypt_apps(encrypted_types_.Has(syncer::APPS)); 390 nigori->set_encrypt_apps(encrypted_types_.Has(APPS));
391 nigori->set_encrypt_app_notifications( 391 nigori->set_encrypt_app_notifications(
392 encrypted_types_.Has(syncer::APP_NOTIFICATIONS)); 392 encrypted_types_.Has(APP_NOTIFICATIONS));
393 } 393 }
394 394
395 void Cryptographer::set_encrypt_everything() { 395 void Cryptographer::set_encrypt_everything() {
396 if (encrypt_everything_) { 396 if (encrypt_everything_) {
397 DCHECK(encrypted_types_.Equals(syncer::ModelTypeSet::All())); 397 DCHECK(encrypted_types_.Equals(ModelTypeSet::All()));
398 return; 398 return;
399 } 399 }
400 encrypt_everything_ = true; 400 encrypt_everything_ = true;
401 // Change |encrypted_types_| directly to avoid sending more than one 401 // Change |encrypted_types_| directly to avoid sending more than one
402 // notification. 402 // notification.
403 encrypted_types_ = syncer::ModelTypeSet::All(); 403 encrypted_types_ = ModelTypeSet::All();
404 EmitEncryptedTypesChangedNotification(); 404 EmitEncryptedTypesChangedNotification();
405 } 405 }
406 406
407 bool Cryptographer::encrypt_everything() const { 407 bool Cryptographer::encrypt_everything() const {
408 return encrypt_everything_; 408 return encrypt_everything_;
409 } 409 }
410 410
411 syncer::ModelTypeSet Cryptographer::GetEncryptedTypes() const { 411 ModelTypeSet Cryptographer::GetEncryptedTypes() const {
412 return encrypted_types_; 412 return encrypted_types_;
413 } 413 }
414 414
415 void Cryptographer::MergeEncryptedTypesForTest( 415 void Cryptographer::MergeEncryptedTypesForTest(ModelTypeSet encrypted_types) {
416 syncer::ModelTypeSet encrypted_types) {
417 MergeEncryptedTypes(encrypted_types); 416 MergeEncryptedTypes(encrypted_types);
418 } 417 }
419 418
420 void Cryptographer::MergeEncryptedTypes( 419 void Cryptographer::MergeEncryptedTypes(ModelTypeSet encrypted_types) {
421 syncer::ModelTypeSet encrypted_types) {
422 if (encrypted_types_.HasAll(encrypted_types)) { 420 if (encrypted_types_.HasAll(encrypted_types)) {
423 return; 421 return;
424 } 422 }
425 encrypted_types_ = encrypted_types; 423 encrypted_types_ = encrypted_types;
426 EmitEncryptedTypesChangedNotification(); 424 EmitEncryptedTypesChangedNotification();
427 } 425 }
428 426
429 void Cryptographer::EmitEncryptedTypesChangedNotification() { 427 void Cryptographer::EmitEncryptedTypesChangedNotification() {
430 FOR_EACH_OBSERVER( 428 FOR_EACH_OBSERVER(
431 Observer, observers_, 429 Observer, observers_,
(...skipping 12 matching lines...) Expand all
444 key.mac_key())) { 442 key.mac_key())) {
445 NOTREACHED(); 443 NOTREACHED();
446 continue; 444 continue;
447 } 445 }
448 nigoris_[key.name()] = make_linked_ptr(new_nigori.release()); 446 nigoris_[key.name()] = make_linked_ptr(new_nigori.release());
449 } 447 }
450 } 448 }
451 } 449 }
452 450
453 } // namespace syncer 451 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/util/cryptographer.h ('k') | sync/util/cryptographer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698