OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/prefs/profile_pref_store_manager.h" | 5 #include "chrome/browser/prefs/profile_pref_store_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 pref_store_->GetValue(kProtectedAtomic, NULL)); | 458 pref_store_->GetValue(kProtectedAtomic, NULL)); |
459 VerifyResetRecorded( | 459 VerifyResetRecorded( |
460 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); | 460 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); |
461 | 461 |
462 ExpectValidationObserved(kTrackedAtomic); | 462 ExpectValidationObserved(kTrackedAtomic); |
463 ExpectValidationObserved(kProtectedAtomic); | 463 ExpectValidationObserved(kProtectedAtomic); |
464 } | 464 } |
465 | 465 |
466 TEST_P(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { | 466 TEST_P(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { |
467 auto master_prefs = base::MakeUnique<base::DictionaryValue>(); | 467 auto master_prefs = base::MakeUnique<base::DictionaryValue>(); |
468 master_prefs->Set(kTrackedAtomic, base::MakeUnique<base::Value>(kFoobar)); | 468 master_prefs->Set(kTrackedAtomic, new base::Value(kFoobar)); |
469 master_prefs->Set(kProtectedAtomic, | 469 master_prefs->Set(kProtectedAtomic, new base::Value(kHelloWorld)); |
470 base::MakeUnique<base::Value>(kHelloWorld)); | |
471 EXPECT_TRUE(manager_->InitializePrefsFromMasterPrefs( | 470 EXPECT_TRUE(manager_->InitializePrefsFromMasterPrefs( |
472 prefs::CloneTrackedConfiguration(configuration_), kReportingIdCount, | 471 prefs::CloneTrackedConfiguration(configuration_), kReportingIdCount, |
473 std::move(master_prefs))); | 472 std::move(master_prefs))); |
474 | 473 |
475 LoadExistingPrefs(); | 474 LoadExistingPrefs(); |
476 | 475 |
477 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs | 476 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs |
478 // necessary to authenticate these values. | 477 // necessary to authenticate these values. |
479 ExpectStringValueEquals(kTrackedAtomic, kFoobar); | 478 ExpectStringValueEquals(kTrackedAtomic, kFoobar); |
480 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 479 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 615 |
617 // Accessing the value of the previously protected pref didn't trigger its | 616 // Accessing the value of the previously protected pref didn't trigger its |
618 // move to the unprotected preferences file, though the loading of the pref | 617 // move to the unprotected preferences file, though the loading of the pref |
619 // store should still have caused the MAC store to be recalculated. | 618 // store should still have caused the MAC store to be recalculated. |
620 LoadExistingPrefs(); | 619 LoadExistingPrefs(); |
621 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 620 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
622 | 621 |
623 // Trigger the logic that migrates it back to the unprotected preferences | 622 // Trigger the logic that migrates it back to the unprotected preferences |
624 // file. | 623 // file. |
625 pref_store_->SetValue(kProtectedAtomic, | 624 pref_store_->SetValue(kProtectedAtomic, |
626 base::MakeUnique<base::Value>(kGoodbyeWorld), | 625 base::WrapUnique(new base::Value(kGoodbyeWorld)), |
627 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 626 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
628 LoadExistingPrefs(); | 627 LoadExistingPrefs(); |
629 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); | 628 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); |
630 VerifyResetRecorded(false); | 629 VerifyResetRecorded(false); |
631 } | 630 } |
632 | 631 |
633 // The parameter controls whether the user pref store is created within a | 632 // The parameter controls whether the user pref store is created within a |
634 // service. | 633 // service. |
635 INSTANTIATE_TEST_CASE_P(ProfilePrefStoreManagerTest, | 634 INSTANTIATE_TEST_CASE_P(ProfilePrefStoreManagerTest, |
636 ProfilePrefStoreManagerTest, | 635 ProfilePrefStoreManagerTest, |
637 testing::Bool()); | 636 testing::Bool()); |
OLD | NEW |