| 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 pref_store_->GetValue(kProtectedAtomic, NULL)); | 452 pref_store_->GetValue(kProtectedAtomic, NULL)); |
| 453 VerifyResetRecorded( | 453 VerifyResetRecorded( |
| 454 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); | 454 ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking); |
| 455 | 455 |
| 456 ExpectValidationObserved(kTrackedAtomic); | 456 ExpectValidationObserved(kTrackedAtomic); |
| 457 ExpectValidationObserved(kProtectedAtomic); | 457 ExpectValidationObserved(kProtectedAtomic); |
| 458 } | 458 } |
| 459 | 459 |
| 460 TEST_P(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { | 460 TEST_P(ProfilePrefStoreManagerTest, InitializePrefsFromMasterPrefs) { |
| 461 auto master_prefs = base::MakeUnique<base::DictionaryValue>(); | 461 auto master_prefs = base::MakeUnique<base::DictionaryValue>(); |
| 462 master_prefs->Set(kTrackedAtomic, new base::Value(kFoobar)); | 462 master_prefs->Set(kTrackedAtomic, base::MakeUnique<base::Value>(kFoobar)); |
| 463 master_prefs->Set(kProtectedAtomic, new base::Value(kHelloWorld)); | 463 master_prefs->Set(kProtectedAtomic, |
| 464 base::MakeUnique<base::Value>(kHelloWorld)); |
| 464 EXPECT_TRUE(manager_->InitializePrefsFromMasterPrefs( | 465 EXPECT_TRUE(manager_->InitializePrefsFromMasterPrefs( |
| 465 prefs::CloneTrackedConfiguration(configuration_), kReportingIdCount, | 466 prefs::CloneTrackedConfiguration(configuration_), kReportingIdCount, |
| 466 std::move(master_prefs))); | 467 std::move(master_prefs))); |
| 467 | 468 |
| 468 LoadExistingPrefs(); | 469 LoadExistingPrefs(); |
| 469 | 470 |
| 470 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs | 471 // Verify that InitializePrefsFromMasterPrefs correctly applied the MACs |
| 471 // necessary to authenticate these values. | 472 // necessary to authenticate these values. |
| 472 ExpectStringValueEquals(kTrackedAtomic, kFoobar); | 473 ExpectStringValueEquals(kTrackedAtomic, kFoobar); |
| 473 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 474 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 | 610 |
| 610 // Accessing the value of the previously protected pref didn't trigger its | 611 // Accessing the value of the previously protected pref didn't trigger its |
| 611 // move to the unprotected preferences file, though the loading of the pref | 612 // move to the unprotected preferences file, though the loading of the pref |
| 612 // store should still have caused the MAC store to be recalculated. | 613 // store should still have caused the MAC store to be recalculated. |
| 613 LoadExistingPrefs(); | 614 LoadExistingPrefs(); |
| 614 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); | 615 ExpectStringValueEquals(kProtectedAtomic, kHelloWorld); |
| 615 | 616 |
| 616 // Trigger the logic that migrates it back to the unprotected preferences | 617 // Trigger the logic that migrates it back to the unprotected preferences |
| 617 // file. | 618 // file. |
| 618 pref_store_->SetValue(kProtectedAtomic, | 619 pref_store_->SetValue(kProtectedAtomic, |
| 619 base::WrapUnique(new base::Value(kGoodbyeWorld)), | 620 base::MakeUnique<base::Value>(kGoodbyeWorld), |
| 620 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); | 621 WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); |
| 621 LoadExistingPrefs(); | 622 LoadExistingPrefs(); |
| 622 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); | 623 ExpectStringValueEquals(kProtectedAtomic, kGoodbyeWorld); |
| 623 VerifyResetRecorded(false); | 624 VerifyResetRecorded(false); |
| 624 } | 625 } |
| 625 | 626 |
| 626 // The parameter controls whether the user pref store is created within a | 627 // The parameter controls whether the user pref store is created within a |
| 627 // service. | 628 // service. |
| 628 INSTANTIATE_TEST_CASE_P(ProfilePrefStoreManagerTest, | 629 INSTANTIATE_TEST_CASE_P(ProfilePrefStoreManagerTest, |
| 629 ProfilePrefStoreManagerTest, | 630 ProfilePrefStoreManagerTest, |
| 630 testing::Bool()); | 631 testing::Bool()); |
| OLD | NEW |